4856-worker.time-control #1375
|
@ -159,6 +159,8 @@ export default class Calendar extends FormInput {
|
|||
|
||||
this.repaint();
|
||||
this.emit('move', {$date: date});
|
||||
|
||||
this.getStates({$day: date});
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -235,6 +237,7 @@ ngModule.vnComponent('vnCalendar', {
|
|||
bindings: {
|
||||
defaultDate: '=?',
|
||||
hasEvents: '&?',
|
||||
getStates: '&?',
|
||||
getClass: '&?',
|
||||
formatDay: '&?',
|
||||
formatWeek: '&?',
|
||||
|
|
|
@ -259,11 +259,11 @@
|
|||
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
||||
"Failed to upload file": "Error al subir archivo",
|
||||
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
|
||||
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
|
||||
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
|
||||
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
||||
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
|
||||
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
|
||||
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
||||
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
|
||||
"There is no assigned email for this client": "No hay correo asignado para este cliente",
|
||||
"This locker has already been assigned": "Esta taquilla ya ha sido asignada"
|
||||
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
|
||||
"You must indicate the reason": "You must indicate the reason"
|
||||
}
|
||||
|
||||
|
|
|
@ -78,26 +78,29 @@
|
|||
</vn-table>
|
||||
</vn-card>
|
||||
|
||||
<vn-button-bar ng-show="$ctrl.state" class="vn-pa-xs vn-w-lg">
|
||||
<vn-button-bar ng-show="$ctrl.state" class="vn-w-lg">
|
||||
<vn-button
|
||||
label="Satisfied"
|
||||
disabled="$ctrl.state == 'CONFIRMED'"
|
||||
ng-if="$ctrl.isHimSelf"
|
||||
ng-click="$ctrl.isSatisfied()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Not satisfied"
|
||||
disabled="$ctrl.state == 'REVISE'"
|
||||
ng-if="$ctrl.isHimSelf"
|
||||
ng-click="reason.show()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Reason"
|
||||
ng-if="$ctrl.reason"
|
||||
ng-if="$ctrl.reason && ($ctrl.isHimSelf || $ctrl.isHr)"
|
||||
ng-click="reason.show()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Resend"
|
||||
ng-click="$ctrl.resendEmail()"
|
||||
ng-click="sendEmailConfirmation.show()"
|
||||
class="right"
|
||||
vn-tooltip="Resend email of this week to the user"
|
||||
ng-show="::$ctrl.isHr">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
|
@ -120,6 +123,7 @@
|
|||
class="vn-pt-md"
|
||||
ng-model="$ctrl.date"
|
||||
format-week="$ctrl.formatWeek($element)"
|
||||
get-states="$ctrl.getStates($day)"
|
||||
has-events="$ctrl.hasEvents($day)">
|
||||
</vn-calendar>
|
||||
</div>
|
||||
|
@ -180,15 +184,31 @@
|
|||
vn-id="reason"
|
||||
on-accept="$ctrl.isUnsatisfied()">
|
||||
<tpl-body>
|
||||
<vn-textarea
|
||||
label="Reason"
|
||||
ng-model="$ctrl.reason"
|
||||
required="true"
|
||||
rows="3">
|
||||
</vn-textarea>
|
||||
<div class="reasonDialog">
|
||||
<vn-textarea
|
||||
label="Reason"
|
||||
ng-model="$ctrl.reason"
|
||||
disabled="!$ctrl.isHimSelf"
|
||||
rows="5"
|
||||
required="true">
|
||||
</vn-textarea>
|
||||
</div>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<tpl-buttons ng-if="$ctrl.isHimSelf">
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
|
||||
<vn-dialog
|
||||
vn-id="sendEmailConfirmation"
|
||||
on-accept="$ctrl.resendEmail()"
|
||||
message="Send time control email">
|
||||
<tpl-body style="min-width: 500px;">
|
||||
<span translate>Are you sure you want to send it?</span>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Confirm</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
import UserError from 'core/lib/user-error';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $, vnWeekDays) {
|
||||
|
@ -25,102 +26,18 @@ class Controller extends Section {
|
|||
|
||||
this.date = initialDate;
|
||||
|
||||
const filterTime = {
|
||||
fields: ['week'],
|
||||
where: {
|
||||
month: this.date.getMonth() + 1,
|
||||
year: this.date.getFullYear()
|
||||
}
|
||||
};
|
||||
this.$http.get('Times', {filter: filterTime})
|
||||
.then(res => {
|
||||
const weeks = res.data.map(time => time.week);
|
||||
const weekNumbersSet = new Set(weeks);
|
||||
const weekNumbers = Array.from(weekNumbersSet);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
workerFk: this.$params.id,
|
||||
year: this.date.getFullYear(),
|
||||
week: {inq: weekNumbers}
|
||||
}
|
||||
};
|
||||
this.$http.get('WorkerTimeControlMails', {filter})
|
||||
.then(res => {
|
||||
const workerTimeControlMails = res.data;
|
||||
console.log(workerTimeControlMails);
|
||||
for (const workerTimeControlMail of workerTimeControlMails) {
|
||||
// const [data] = res.data;
|
||||
// if (!data) {
|
||||
// if (this.weekNumber == weekNumberValue) this.state = null;
|
||||
// return;
|
||||
// }
|
||||
|
||||
const state = workerTimeControlMail.state;
|
||||
|
||||
console.log(workerTimeControlMail.week, this.weekNumberValue);
|
||||
if (workerTimeControlMail.week == this.weekNumberValue) {
|
||||
this.state = state;
|
||||
this.reason = workerTimeControlMail.reason;
|
||||
}
|
||||
if (state == 'CONFIRMED') {
|
||||
this.weekNumberHTML.classList.add('confirmed');
|
||||
this.weekNumberHTML.setAttribute('title', 'Conforme');
|
||||
}
|
||||
if (state == 'REVISE') {
|
||||
this.weekNumberHTML.classList.add('revise');
|
||||
this.weekNumberHTML.setAttribute('title', 'No conforme');
|
||||
}
|
||||
if (state == 'SENDED') {
|
||||
this.weekNumberHTML.classList.add('sended');
|
||||
this.weekNumberHTML.setAttribute('title', 'Pendiente');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// console.log(this.weekNumbers);
|
||||
// const filter = {
|
||||
// where: {
|
||||
// workerFk: this.$params.id,
|
||||
// year: this.date.getFullYear(),
|
||||
// week: {inq: this.weekNumbers}
|
||||
// }
|
||||
// };
|
||||
// this.$http.get('WorkerTimeControlMails', {filter})
|
||||
// .then(res => {
|
||||
// console.log(res.data);
|
||||
// // const [data] = res.data;
|
||||
// // if (!data) {
|
||||
// // if (this.weekNumber == weekNumberValue) this.state = null;
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// // const state = data.state;
|
||||
// // if (this.weekNumber == weekNumberValue) {
|
||||
// // this.state = state;
|
||||
// // this.reason = data.reason;
|
||||
// // }
|
||||
|
||||
// // if (state == 'CONFIRMED') {
|
||||
// // weekNumber.classList.add('confirmed');
|
||||
// // weekNumber.setAttribute('title', 'Conforme');
|
||||
// // }
|
||||
// // if (state == 'REVISE') {
|
||||
// // weekNumber.classList.add('revise');
|
||||
// // weekNumber.setAttribute('title', 'No conforme');
|
||||
// // }
|
||||
// // if (state == 'SENDED') {
|
||||
// // weekNumber.classList.add('sended');
|
||||
// // weekNumber.setAttribute('title', 'Pendiente');
|
||||
// // }
|
||||
// });
|
||||
this.getStates(this.date);
|
||||
}
|
||||
|
||||
get isHr() {
|
||||
return this.aclService.hasAny(['hr']);
|
||||
}
|
||||
|
||||
get isHimSelf() {
|
||||
const userId = window.localStorage.currentUserWorkerId;
|
||||
return userId == this.$params.id;
|
||||
}
|
||||
|
||||
get worker() {
|
||||
return this._worker;
|
||||
}
|
||||
|
@ -171,6 +88,27 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
this.fetchHours();
|
||||
this.getWeekData();
|
||||
}
|
||||
|
||||
getWeekData() {
|
||||
const filter = {
|
||||
where: {
|
||||
workerFk: this.$params.id,
|
||||
year: this._date.getFullYear(),
|
||||
week: this.getWeekNumber(this._date)
|
||||
}
|
||||
};
|
||||
this.$http.get('WorkerTimeControlMails', {filter})
|
||||
.then(res => {
|
||||
const [workerTimeControlMail] = res.data;
|
||||
if (!workerTimeControlMail) {
|
||||
this.state = null;
|
||||
return;
|
||||
}
|
||||
this.state = workerTimeControlMail.state;
|
||||
this.reason = workerTimeControlMail.reason;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -417,12 +355,15 @@ class Controller extends Section {
|
|||
};
|
||||
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
|
||||
this.$http.post(query, params).then(() => {
|
||||
this.getStates(this.date);
|
||||
this.getWeekData();
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.$state.reload();
|
||||
});
|
||||
}
|
||||
|
||||
isUnsatisfied() {
|
||||
if (!this.reason) throw new UserError(`You must indicate a reason`);
|
||||
|
||||
const params = {
|
||||
workerId: this.worker.id,
|
||||
year: this.date.getFullYear(),
|
||||
|
@ -432,11 +373,18 @@ class Controller extends Section {
|
|||
};
|
||||
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
|
||||
this.$http.post(query, params).then(() => {
|
||||
this.getStates(this.date);
|
||||
this.getWeekData();
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.$state.reload();
|
||||
});
|
||||
}
|
||||
|
||||
changeState(state, reason) {
|
||||
this.state = state;
|
||||
this.reason = reason;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
save() {
|
||||
try {
|
||||
const entry = this.selectedRow;
|
||||
|
@ -453,48 +401,6 @@ class Controller extends Section {
|
|||
}
|
||||
}
|
||||
|
||||
formatWeek($element) {
|
||||
this.weekNumberHTML = $element.firstElementChild;
|
||||
console.log(this.weekNumberHTML);
|
||||
this.weekNumberValue = $element.firstElementChild.innerHTML;
|
||||
|
||||
// const filter = {
|
||||
// where: {
|
||||
// workerFk: this.$params.id,
|
||||
// year: this.date.getFullYear(),
|
||||
// week: weekNumberValue
|
||||
// }
|
||||
// };
|
||||
|
||||
// this.$http.get('WorkerTimeControlMails', {filter})
|
||||
// .then(res => {
|
||||
// const [data] = res.data;
|
||||
// if (!data) {
|
||||
// if (this.weekNumber == weekNumberValue) this.state = null;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const state = data.state;
|
||||
// if (this.weekNumber == weekNumberValue) {
|
||||
// this.state = state;
|
||||
// this.reason = data.reason;
|
||||
// }
|
||||
|
||||
// if (state == 'CONFIRMED') {
|
||||
// weekNumber.classList.add('confirmed');
|
||||
// weekNumber.setAttribute('title', 'Conforme');
|
||||
// }
|
||||
// if (state == 'REVISE') {
|
||||
// weekNumber.classList.add('revise');
|
||||
// weekNumber.setAttribute('title', 'No conforme');
|
||||
// }
|
||||
// if (state == 'SENDED') {
|
||||
// weekNumber.classList.add('sended');
|
||||
// weekNumber.setAttribute('title', 'Pendiente');
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
resendEmail() {
|
||||
const timestamp = this.date.getTime() / 1000;
|
||||
const url = `${window.location.origin}/#!/worker/${this.worker.id}/time-control?timestamp=${timestamp}`;
|
||||
|
@ -514,6 +420,73 @@ class Controller extends Section {
|
|||
const [hours, minutes, seconds] = timeString.split(':');
|
||||
return [parseInt(hours), parseInt(minutes), parseInt(seconds)];
|
||||
}
|
||||
|
||||
getStates(day) {
|
||||
const filterTime = {
|
||||
fields: ['week'],
|
||||
where: {
|
||||
month: day.getMonth() + 1,
|
||||
year: day.getFullYear()
|
||||
}
|
||||
};
|
||||
this.$http.get('Times', {filter: filterTime})
|
||||
.then(res => {
|
||||
const weeks = res.data.map(time => time.week);
|
||||
const weekNumbersSet = new Set(weeks);
|
||||
const weekNumbers = Array.from(weekNumbersSet);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
workerFk: this.$params.id,
|
||||
year: day.getFullYear(),
|
||||
week: {inq: weekNumbers}
|
||||
}
|
||||
};
|
||||
this.$http.get('WorkerTimeControlMails', {filter})
|
||||
.then(res => {
|
||||
this.workerTimeControlMails = res.data;
|
||||
this.repaint();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
formatWeek($element) {
|
||||
const weekNumberHTML = $element.firstElementChild;
|
||||
const weekNumberValue = weekNumberHTML.innerHTML;
|
||||
|
||||
if (!this.workerTimeControlMails) return;
|
||||
const workerTimeControlMail = this.workerTimeControlMails.find(
|
||||
workerTimeControlMail => workerTimeControlMail.week == weekNumberValue
|
||||
);
|
||||
|
||||
if (!workerTimeControlMail) return;
|
||||
const state = workerTimeControlMail.state;
|
||||
|
||||
if (state == 'CONFIRMED') {
|
||||
weekNumberHTML.classList.remove('revise');
|
||||
weekNumberHTML.classList.remove('sended');
|
||||
|
||||
weekNumberHTML.classList.add('confirmed');
|
||||
weekNumberHTML.setAttribute('title', 'Conforme');
|
||||
}
|
||||
if (state == 'REVISE') {
|
||||
weekNumberHTML.classList.remove('confirmed');
|
||||
weekNumberHTML.classList.remove('sended');
|
||||
|
||||
weekNumberHTML.classList.add('revise');
|
||||
weekNumberHTML.setAttribute('title', 'No conforme');
|
||||
}
|
||||
if (state == 'SENDED') {
|
||||
weekNumberHTML.classList.add('sended');
|
||||
weekNumberHTML.setAttribute('title', 'Pendiente');
|
||||
}
|
||||
}
|
||||
|
||||
repaint() {
|
||||
let calendars = this.element.querySelectorAll('vn-calendar');
|
||||
for (let calendar of calendars)
|
||||
calendar.$ctrl.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
||||
|
|
|
@ -16,3 +16,7 @@ Not satisfied: No conforme
|
|||
Reason: Motivo
|
||||
Resend: Reenviar
|
||||
Email sended: Email enviado
|
||||
You must indicate a reason: Debes indicar un motivo
|
||||
Send time control email: Enviar email control horario
|
||||
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
|
||||
Resend email of this week to the user: Reenviar email de esta semana al usuario
|
||||
|
|
|
@ -24,6 +24,11 @@ vn-worker-time-control {
|
|||
.totalBox {
|
||||
max-width: none
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.reasonDialog{
|
||||
min-width: 500px;
|
||||
}
|
||||
|
||||
.edit-time-entry {
|
||||
|
|
Loading…
Reference in New Issue