diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js
index 2796931a07..f30878b9f8 100644
--- a/front/salix/components/log/index.js
+++ b/front/salix/components/log/index.js
@@ -37,7 +37,7 @@ export default class Controller extends Section {
const validations = window.validations;
value.forEach(log => {
- const locale = validations[log.changedModel].locale ? validations[log.changedModel].locale : {};
+ const locale = validations[log.changedModel] && validations[log.changedModel].locale ? validations[log.changedModel].locale : {};
log.oldProperties = this.getInstance(log.oldInstance, locale);
log.newProperties = this.getInstance(log.newInstance, locale);
diff --git a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js
new file mode 100644
index 0000000000..7825f38b84
--- /dev/null
+++ b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js
@@ -0,0 +1,181 @@
+const Imap = require('imap');
+module.exports = Self => {
+ Self.remoteMethod('checkInbox', {
+ description: 'Check an email inbox and process it',
+ accessType: 'READ',
+ returns:
+ {
+ arg: 'body',
+ type: 'file',
+ root: true
+ },
+ http: {
+ path: `/checkInbox`,
+ verb: 'POST'
+ }
+ });
+
+ Self.checkInbox = async() => {
+ let imapConfig = await Self.app.models.WorkerTimeControlParams.findOne();
+ let imap = new Imap({
+ user: imapConfig.mailUser,
+ password: imapConfig.mailPass,
+ host: imapConfig.mailHost,
+ port: 993,
+ tls: true
+ });
+ let isEmailOk;
+ let uid;
+ let emailBody;
+
+ function openInbox(cb) {
+ imap.openBox('INBOX', true, cb);
+ }
+
+ imap.once('ready', function() {
+ openInbox(function(err, box) {
+ if (err) throw err;
+ const totalMessages = box.messages.total;
+ if (totalMessages == 0)
+ imap.end();
+
+ let f = imap.seq.fetch('1:*', {
+ bodies: ['HEADER.FIELDS (FROM SUBJECT)', '1'],
+ struct: true
+ });
+ f.on('message', function(msg, seqno) {
+ isEmailOk = false;
+ msg.on('body', function(stream, info) {
+ let buffer = '';
+ let bufferCopy = '';
+ stream.on('data', function(chunk) {
+ buffer = chunk.toString('utf8');
+ if (info.which === '1' && bufferCopy.length == 0)
+ bufferCopy = buffer.replace(/\s/g, ' ');
+ });
+ stream.on('end', function() {
+ if (bufferCopy.length > 0) {
+ emailBody = bufferCopy.toUpperCase().trim();
+
+ const bodyPositionOK = emailBody.match(/\bOK\b/i);
+ if (bodyPositionOK != null && (bodyPositionOK.index == 0 || bodyPositionOK.index == 122))
+ isEmailOk = true;
+ else
+ isEmailOk = false;
+ }
+ });
+ msg.once('attributes', function(attrs) {
+ uid = attrs.uid;
+ });
+ msg.once('end', function() {
+ if (info.which === 'HEADER.FIELDS (FROM SUBJECT)') {
+ if (isEmailOk) {
+ imap.move(uid, 'exito', function(err) {
+ });
+ emailConfirm(buffer);
+ } else {
+ imap.move(uid, 'error', function(err) {
+ });
+ emailReply(buffer, emailBody);
+ }
+ }
+ });
+ });
+ });
+ f.once('end', function() {
+ imap.end();
+ });
+ });
+ });
+
+ imap.connect();
+ return 'Leer emails de gestion horaria';
+ };
+
+ async function emailConfirm(buffer) {
+ const now = new Date();
+ const from = JSON.stringify(Imap.parseHeader(buffer).from);
+ const subject = JSON.stringify(Imap.parseHeader(buffer).subject);
+
+ const timeControlDate = await getEmailDate(subject);
+ const week = timeControlDate[0];
+ const year = timeControlDate[1];
+ const user = await getUser(from);
+ let workerMail;
+
+ if (user.id != null) {
+ workerMail = await Self.app.models.WorkerTimeControlMail.findOne({
+ where: {
+ week: week,
+ year: year,
+ workerFk: user.id
+ }
+ });
+ }
+ if (workerMail != null) {
+ await workerMail.updateAttributes({
+ updated: now,
+ state: 'CONFIRMED'
+ });
+ }
+ }
+
+ async function emailReply(buffer, emailBody) {
+ const now = new Date();
+ const from = JSON.stringify(Imap.parseHeader(buffer).from);
+ const subject = JSON.stringify(Imap.parseHeader(buffer).subject);
+
+ const timeControlDate = await getEmailDate(subject);
+ const week = timeControlDate[0];
+ const year = timeControlDate[1];
+ const user = await getUser(from);
+ let workerMail;
+
+ if (user.id != null) {
+ workerMail = await Self.app.models.WorkerTimeControlMail.findOne({
+ where: {
+ week: week,
+ year: year,
+ workerFk: user.id
+ }
+ });
+
+ if (workerMail != null) {
+ await workerMail.updateAttributes({
+ updated: now,
+ state: 'REVISE',
+ reason: emailBody
+ });
+ } else
+ await sendMail(user, subject, emailBody);
+ }
+ }
+
+ async function getUser(workerEmail) {
+ const userEmail = workerEmail.match(/(?<=<)(.*?)(?=>)/);
+
+ let [user] = await Self.rawSql(`SELECT u.id,u.name FROM account.user u
+ LEFT JOIN account.mailForward m on m.account = u.id
+ WHERE forwardTo =? OR
+ CONCAT(u.name,'@verdnatura.es') = ?`,
+ [userEmail[0], userEmail[0]]);
+
+ return user;
+ }
+
+ async function getEmailDate(subject) {
+ const date = subject.match(/\d+/g);
+ return date;
+ }
+
+ async function sendMail(user, subject, emailBody) {
+ const sendTo = 'rrhh@verdnatura.es';
+ const emailSubject = subject + ' ' + user.name;
+
+ await Self.app.models.Mail.create({
+ receiver: sendTo,
+ subject: emailSubject,
+ body: emailBody
+ });
+ }
+};
diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js
index 2f9559b3a1..cd9cacbd75 100644
--- a/modules/worker/back/methods/worker-time-control/sendMail.js
+++ b/modules/worker/back/methods/worker-time-control/sendMail.js
@@ -133,7 +133,7 @@ module.exports = Self => {
tb.permissionRate,
d.isTeleworking
FROM tmp.timeBusinessCalculate tb
- JOIN user u ON u.id = tb.userFk
+ JOIN account.user u ON u.id = tb.userFk
JOIN department d ON d.id = tb.departmentFk
JOIN business b ON b.id = tb.businessFk
LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated
@@ -143,7 +143,7 @@ module.exports = Self => {
IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)),
TRUE))isTeleworkingWeek
FROM tmp.timeBusinessCalculate tb
- LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk
+ LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk
AND tc.dated = tb.dated
GROUP BY tb.userFk
HAVING isTeleworkingWeek > 0
diff --git a/modules/worker/back/models/worker-time-control-mail.js b/modules/worker/back/models/worker-time-control-mail.js
new file mode 100644
index 0000000000..36f3851b6d
--- /dev/null
+++ b/modules/worker/back/models/worker-time-control-mail.js
@@ -0,0 +1,3 @@
+module.exports = Self => {
+ require('../methods/worker-time-control-mail/checkInbox')(Self);
+};
diff --git a/print/common/css/misc.css b/print/common/css/misc.css
index df8bf571ae..ce6c641a01 100644
--- a/print/common/css/misc.css
+++ b/print/common/css/misc.css
@@ -49,4 +49,10 @@
.page-break-after {
page-break-after: always;
+}
+
+.ellipsize {
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
}
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/assets/css/style.css b/print/templates/reports/collection-label/assets/css/style.css
index fe1975445d..597921c92c 100644
--- a/print/templates/reports/collection-label/assets/css/style.css
+++ b/print/templates/reports/collection-label/assets/css/style.css
@@ -1,6 +1,6 @@
html {
font-family: "Roboto";
- margin-top: -7px;
+ margin-top: -6px;
}
* {
box-sizing: border-box;
@@ -9,7 +9,7 @@ html {
}
#vertical {
writing-mode: vertical-rl;
- height: 226px;
+ height: 240px;
margin-left: -13px;
}
.outline {
@@ -18,6 +18,7 @@ html {
}
#nickname {
font-size: 22px;
+ max-width: 50px;
}
#agencyDescripton {
font-size: 32px;
diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html
index eeb82ac4a5..6716d1fe51 100644
--- a/print/templates/reports/collection-label/collection-label.html
+++ b/print/templates/reports/collection-label/collection-label.html
@@ -1,35 +1,36 @@
-
-
-
-
-
-
-
-
- {{labelData.levelV}}
- {{labelData.ticketFk}} ⬸ {{labelData.clientFk}}
- {{labelData.shipped}}
-
-
-
- {{labelData.workerCode}}
-
-
- {{labelData.labelCount}}
-
-
- {{labelData.size}}
-
-
-
- {{labelData.lineCount}}
-
-
-
- {{labelData.nickName}}
- {{labelData.agencyHour}}
-
+ {{labelData.collectionFk ? `${labelData.collectionFk} ~ ${labelData.wagon}-${labelData.level}` : '-'.repeat(23)}} + | ++ {{labelData.clientFk ? `${labelData.ticketFk} « ${labelData.clientFk}` : labelData.ticketFk}} + | +{{labelData.shipped ? labelData.shipped : '---'}} | +|
+ | {{labelData.workerCode ? labelData.workerCode : '---'}} | +||
{{labelData.labelCount ? labelData.labelCount : 0}} | +|||
{{labelData.code == 'plant' ? labelData.size + 'cm' : labelData.volume + 'm³'}} | +|||
{{labelData.agencyDescription}} |
+ {{labelData.lineCount ? labelData.lineCount : 0}} | +||
{{labelData.nickName ? labelData.nickName : '---'}} | +{{labelData.shipped ? labelData.shippedHour : labelData.zoneHour}} | +