4856-worker.time-control #1375
|
@ -159,6 +159,8 @@ export default class Calendar extends FormInput {
|
||||||
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
this.emit('move', {$date: date});
|
this.emit('move', {$date: date});
|
||||||
|
|
||||||
|
this.getStates({$day: date});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -235,6 +237,7 @@ ngModule.vnComponent('vnCalendar', {
|
||||||
bindings: {
|
bindings: {
|
||||||
defaultDate: '=?',
|
defaultDate: '=?',
|
||||||
hasEvents: '&?',
|
hasEvents: '&?',
|
||||||
|
getStates: '&?',
|
||||||
getClass: '&?',
|
getClass: '&?',
|
||||||
formatDay: '&?',
|
formatDay: '&?',
|
||||||
formatWeek: '&?',
|
formatWeek: '&?',
|
||||||
|
|
|
@ -264,6 +264,6 @@
|
||||||
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
"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.",
|
"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",
|
"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-table>
|
||||||
</vn-card>
|
</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
|
<vn-button
|
||||||
label="Satisfied"
|
label="Satisfied"
|
||||||
disabled="$ctrl.state == 'CONFIRMED'"
|
disabled="$ctrl.state == 'CONFIRMED'"
|
||||||
|
ng-if="$ctrl.isHimSelf"
|
||||||
ng-click="$ctrl.isSatisfied()">
|
ng-click="$ctrl.isSatisfied()">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
<vn-button
|
<vn-button
|
||||||
label="Not satisfied"
|
label="Not satisfied"
|
||||||
disabled="$ctrl.state == 'REVISE'"
|
disabled="$ctrl.state == 'REVISE'"
|
||||||
|
ng-if="$ctrl.isHimSelf"
|
||||||
ng-click="reason.show()">
|
ng-click="reason.show()">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
<vn-button
|
<vn-button
|
||||||
label="Reason"
|
label="Reason"
|
||||||
ng-if="$ctrl.reason"
|
ng-if="$ctrl.reason && ($ctrl.isHimSelf || $ctrl.isHr)"
|
||||||
ng-click="reason.show()">
|
ng-click="reason.show()">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
<vn-button
|
<vn-button
|
||||||
label="Resend"
|
label="Resend"
|
||||||
ng-click="$ctrl.resendEmail()"
|
ng-click="sendEmailConfirmation.show()"
|
||||||
class="right"
|
class="right"
|
||||||
|
vn-tooltip="Resend email of this week to the user"
|
||||||
ng-show="::$ctrl.isHr">
|
ng-show="::$ctrl.isHr">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
|
@ -120,6 +123,7 @@
|
||||||
class="vn-pt-md"
|
class="vn-pt-md"
|
||||||
ng-model="$ctrl.date"
|
ng-model="$ctrl.date"
|
||||||
format-week="$ctrl.formatWeek($element)"
|
format-week="$ctrl.formatWeek($element)"
|
||||||
|
get-states="$ctrl.getStates($day)"
|
||||||
has-events="$ctrl.hasEvents($day)">
|
has-events="$ctrl.hasEvents($day)">
|
||||||
</vn-calendar>
|
</vn-calendar>
|
||||||
</div>
|
</div>
|
||||||
|
@ -180,15 +184,31 @@
|
||||||
vn-id="reason"
|
vn-id="reason"
|
||||||
on-accept="$ctrl.isUnsatisfied()">
|
on-accept="$ctrl.isUnsatisfied()">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
|
<div class="reasonDialog">
|
||||||
<vn-textarea
|
<vn-textarea
|
||||||
label="Reason"
|
label="Reason"
|
||||||
ng-model="$ctrl.reason"
|
ng-model="$ctrl.reason"
|
||||||
required="true"
|
disabled="!$ctrl.isHimSelf"
|
||||||
rows="3">
|
rows="5"
|
||||||
|
required="true">
|
||||||
</vn-textarea>
|
</vn-textarea>
|
||||||
|
</div>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
<tpl-buttons>
|
<tpl-buttons ng-if="$ctrl.isHimSelf">
|
||||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||||
<button response="accept" translate>Save</button>
|
<button response="accept" translate>Save</button>
|
||||||
</tpl-buttons>
|
</tpl-buttons>
|
||||||
</vn-dialog>
|
</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 ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
import UserError from 'core/lib/user-error';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $, vnWeekDays) {
|
constructor($element, $, vnWeekDays) {
|
||||||
|
@ -25,102 +26,18 @@ class Controller extends Section {
|
||||||
|
|
||||||
this.date = initialDate;
|
this.date = initialDate;
|
||||||
|
|
||||||
const filterTime = {
|
this.getStates(this.date);
|
||||||
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');
|
|
||||||
// // }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get isHr() {
|
get isHr() {
|
||||||
return this.aclService.hasAny(['hr']);
|
return this.aclService.hasAny(['hr']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isHimSelf() {
|
||||||
|
const userId = window.localStorage.currentUserWorkerId;
|
||||||
|
return userId == this.$params.id;
|
||||||
|
}
|
||||||
|
|
||||||
get worker() {
|
get worker() {
|
||||||
return this._worker;
|
return this._worker;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +88,27 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchHours();
|
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`;
|
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
|
||||||
this.$http.post(query, params).then(() => {
|
this.$http.post(query, params).then(() => {
|
||||||
|
this.getStates(this.date);
|
||||||
|
this.getWeekData();
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
this.$state.reload();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isUnsatisfied() {
|
isUnsatisfied() {
|
||||||
|
if (!this.reason) throw new UserError(`You must indicate a reason`);
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
workerId: this.worker.id,
|
workerId: this.worker.id,
|
||||||
year: this.date.getFullYear(),
|
year: this.date.getFullYear(),
|
||||||
|
@ -432,11 +373,18 @@ class Controller extends Section {
|
||||||
};
|
};
|
||||||
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
|
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
|
||||||
this.$http.post(query, params).then(() => {
|
this.$http.post(query, params).then(() => {
|
||||||
|
this.getStates(this.date);
|
||||||
|
this.getWeekData();
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
this.$state.reload();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeState(state, reason) {
|
||||||
|
this.state = state;
|
||||||
|
this.reason = reason;
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
try {
|
try {
|
||||||
const entry = this.selectedRow;
|
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() {
|
resendEmail() {
|
||||||
const timestamp = this.date.getTime() / 1000;
|
const timestamp = this.date.getTime() / 1000;
|
||||||
const url = `${window.location.origin}/#!/worker/${this.worker.id}/time-control?timestamp=${timestamp}`;
|
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(':');
|
const [hours, minutes, seconds] = timeString.split(':');
|
||||||
return [parseInt(hours), parseInt(minutes), parseInt(seconds)];
|
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'];
|
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
||||||
|
|
|
@ -16,3 +16,7 @@ Not satisfied: No conforme
|
||||||
Reason: Motivo
|
Reason: Motivo
|
||||||
Resend: Reenviar
|
Resend: Reenviar
|
||||||
Email sended: Email enviado
|
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 {
|
.totalBox {
|
||||||
max-width: none
|
max-width: none
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.reasonDialog{
|
||||||
|
min-width: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-time-entry {
|
.edit-time-entry {
|
||||||
|
|
Loading…
Reference in New Issue