diff --git a/db/changes/234601/00-sectorBackUpLabelerFk.sql b/db/changes/234601/00-sectorBackUpLabelerFk.sql
new file mode 100644
index 000000000..ac512493c
--- /dev/null
+++ b/db/changes/234601/00-sectorBackUpLabelerFk.sql
@@ -0,0 +1,19 @@
+ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` tinyint(3) unsigned DEFAULT NULL NULL;
+
+ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY `notificationSubscription_ibfk_1`;
+ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY `nnotificationQueue_ibfk_1`;
+ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY `notificationAcl_ibfk_1`;
+
+ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL;
+
+ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`);
+ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`);
+ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`);
+
+DELETE FROM `util`.`notification`
+ WHERE `name` = 'not-main-printer-configured';
+
+INSERT INTO `util`.`notification`
+ SET `id` = 15,
+ `name` = 'backup-printer-selected',
+ `description` = 'The worker has selected the backup printer for their sector';
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index d70279e7d..0fab05bda 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -174,19 +174,16 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
-
-INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
- VALUES
- (1, 'First sector', 1, 1, 'FIRST'),
- (2, 'Second sector', 2, 0, 'SECOND');
-
INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`)
VALUES
(1, 'printer1', 'path1', 0, 1 , NULL),
(2, 'printer2', 'path2', 1, 1 , NULL),
(4, 'printer4', 'path4', 0, NULL, '10.1.10.4');
-UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
+INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `backupPrinterFk`)
+ VALUES
+ (1, 'First sector', 1, 1, 'FIRST', 1),
+ (2, 'Second sector', 2, 0, 'SECOND', NULL);
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
VALUES
@@ -2780,11 +2777,13 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
VALUES
(1, 'print-email', 'notification fixture one'),
(2, 'invoice-electronic', 'A electronic invoice has been generated'),
- (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
(5, 'modified-entry', 'An entry has been modified'),
(6, 'book-entry-deleted', 'accounting entries deleted');
+INSERT IGNORE INTO `util`.`notification` (`id`, `name`, `description`)
+ VALUES (3, 'backup-printer-selected', 'A printer distinct than main has been configured');
+
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES
(1, 9),
diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json
index 47d66bd8d..36a25ed3b 100644
--- a/modules/shelving/back/models/sector.json
+++ b/modules/shelving/back/models/sector.json
@@ -56,7 +56,7 @@
"type": "number",
"required": false
},
- "mainPrinterFk": {
+ "backupPrinterFk": {
"type": "number",
"required": false
},
diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js
index 1253be474..2d402b0d1 100644
--- a/modules/worker/back/methods/operator/spec/operator.spec.js
+++ b/modules/worker/back/methods/operator/spec/operator.spec.js
@@ -4,7 +4,7 @@ describe('Operator', () => {
const authorFk = 9;
const sectorId = 1;
const mainPrinter = 1;
- const notificationName = 'not-main-printer-configured';
+ const notificationName = 'backup-printer-selected';
const operator = {
workerFk: 1,
trainFk: 1,
diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js
index db1ac7e49..f51a6431c 100644
--- a/modules/worker/back/models/operator.js
+++ b/modules/worker/back/models/operator.js
@@ -1,5 +1,5 @@
module.exports = function(Self) {
- Self.observe('after save', async function(ctx) {
+ Self.observe('after save', async ctx => {
const instance = ctx.data || ctx.instance;
const models = Self.app.models;
const options = ctx.options;
@@ -7,13 +7,13 @@ module.exports = function(Self) {
if (!instance?.sectorFk || !instance?.labelerFk) return;
const sector = await models.Sector.findById(instance.sectorFk, {
- fields: ['mainPrinterFk']
+ fields: ['backupPrinterFk']
}, options);
- if (sector.mainPrinterFk && sector.mainPrinterFk != instance.labelerFk) {
- const userId = ctx.options.accessToken.userId;
+ if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) {
+ const {userId} = ctx.options.accessToken;
await models.NotificationQueue.create({
- notificationFk: 'not-main-printer-configured',
+ notificationFk: 'backup-printer-selected',
authorFk: userId,
params: JSON.stringify(
{
diff --git a/print/templates/email/not-main-printer-configured/assets/css/import.js b/print/templates/email/backup-printer-selected/assets/css/import.js
similarity index 100%
rename from print/templates/email/not-main-printer-configured/assets/css/import.js
rename to print/templates/email/backup-printer-selected/assets/css/import.js
diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.html b/print/templates/email/backup-printer-selected/backup-printer-selected.html
new file mode 100644
index 000000000..51fb41773
--- /dev/null
+++ b/print/templates/email/backup-printer-selected/backup-printer-selected.html
@@ -0,0 +1,14 @@
+
+
+
diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js
similarity index 92%
rename from print/templates/email/not-main-printer-configured/not-main-printer-configured.js
rename to print/templates/email/backup-printer-selected/backup-printer-selected.js
index c381991fa..0e56396db 100755
--- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js
+++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js
@@ -2,7 +2,7 @@ const Component = require(`vn-print/core/component`);
const emailBody = new Component('email-body');
module.exports = {
- name: 'not-main-printer-configured',
+ name: 'backup-printer-selected',
async serverPrefetch() {
this.sector = await this.findOneFromDef('sector', [this.sectorId]);
@@ -10,7 +10,7 @@ module.exports = {
throw new Error('Something went wrong');
this.labeler = await this.findOneFromDef('printer', [this.labelerId]);
- this.mainPrinter = await this.findOneFromDef('printer', [this.sector.mainPrinterFk]);
+ this.mainPrinter = await this.findOneFromDef('printer', [this.sector.backupPrinterFk]);
this.worker = await this.findOneFromDef('worker', [this.workerId]);
},
components: {
diff --git a/print/templates/email/backup-printer-selected/locale/en.yml b/print/templates/email/backup-printer-selected/locale/en.yml
new file mode 100644
index 000000000..917881641
--- /dev/null
+++ b/print/templates/email/backup-printer-selected/locale/en.yml
@@ -0,0 +1,3 @@
+subject: Not main printer configured
+title: Not main printer configured
+description: 'The worker #{0} is using the backup printer {1} for their sector {2}.'
diff --git a/print/templates/email/backup-printer-selected/locale/es.yml b/print/templates/email/backup-printer-selected/locale/es.yml
new file mode 100644
index 000000000..a250ba20f
--- /dev/null
+++ b/print/templates/email/backup-printer-selected/locale/es.yml
@@ -0,0 +1,3 @@
+subject: Configurada impresora no principal
+title: Configurada impresora no principal
+description: 'El trabajador #{0} esta utilizando la impresora de repuesto {1} su sector {2}.'
diff --git a/print/templates/email/not-main-printer-configured/sql/printer.sql b/print/templates/email/backup-printer-selected/sql/printer.sql
similarity index 63%
rename from print/templates/email/not-main-printer-configured/sql/printer.sql
rename to print/templates/email/backup-printer-selected/sql/printer.sql
index 265818129..2a98a8f08 100644
--- a/print/templates/email/not-main-printer-configured/sql/printer.sql
+++ b/print/templates/email/backup-printer-selected/sql/printer.sql
@@ -1,3 +1,4 @@
-SELECT id, name
+SELECT id,
+ name
FROM vn.printer
WHERE id = ?
diff --git a/print/templates/email/backup-printer-selected/sql/sector.sql b/print/templates/email/backup-printer-selected/sql/sector.sql
new file mode 100644
index 000000000..9514c4e38
--- /dev/null
+++ b/print/templates/email/backup-printer-selected/sql/sector.sql
@@ -0,0 +1,5 @@
+SELECT id,
+ description,
+ backupPrinterFk
+ FROM vn.sector
+ WHERE id = ?
diff --git a/print/templates/email/not-main-printer-configured/sql/worker.sql b/print/templates/email/backup-printer-selected/sql/worker.sql
similarity index 100%
rename from print/templates/email/not-main-printer-configured/sql/worker.sql
rename to print/templates/email/backup-printer-selected/sql/worker.sql
diff --git a/print/templates/email/not-main-printer-configured/locale/en.yml b/print/templates/email/not-main-printer-configured/locale/en.yml
deleted file mode 100644
index 2a3051145..000000000
--- a/print/templates/email/not-main-printer-configured/locale/en.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-subject: Not main printer configured
-title: Not main printer configured
-description: 'Printer #{0} {1} has been configured in sector #{2} {3} (the main printer for that sector is #{4} {5}). Ask the worker {6}.'
diff --git a/print/templates/email/not-main-printer-configured/locale/es.yml b/print/templates/email/not-main-printer-configured/locale/es.yml
deleted file mode 100644
index b6fe5f9a0..000000000
--- a/print/templates/email/not-main-printer-configured/locale/es.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-subject: Configurada impresora no principal
-title: Configurada impresora no principal
-description: 'Se ha configurado la impresora #{0} {1} en el sector #{2} {3} (la impresora principal de ese sector es la #{4} {5}). Preguntar al trabajador {6}.'
diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html
deleted file mode 100644
index 1e9ffed7a..000000000
--- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/print/templates/email/not-main-printer-configured/sql/sector.sql b/print/templates/email/not-main-printer-configured/sql/sector.sql
deleted file mode 100644
index 5d54eeeb9..000000000
--- a/print/templates/email/not-main-printer-configured/sql/sector.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-SELECT id, description, mainPrinterFk
- FROM vn.sector
- WHERE id = ?