Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
# 37 arrumando filtro por dia
Browse files Browse the repository at this point in the history
Assinado fora: Beatriz Hanae <beatriz.hanae@gmail.com>
Assinado fora: Ezequiel de Oliveira <ezequiel1de1oliveira@gmail.com>

Co-autor: Beatriz Hanae <beatriz.hanae@gmail.com>
Co-Autorado: Ezequiel de Oliveira <ezequiel1de1oliveira@gmail.com>
  • Loading branch information
EzequielDeOliveira committed May 12, 2018
1 parent 7e89823 commit 60f0d82
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Schedule/Server/schedule.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

var seneca = require('seneca');
var currentWeekNumber = require('current-week-number');

Expand Down Expand Up @@ -37,6 +38,15 @@ seneca()
schedule.month = JSON.stringify(schedule.month);
schedule.week = currentWeekNumber(date);
schedule.week = JSON.stringify(schedule.week);
schedule.list$({ date: schedule.date, employee: schedule.employee }, function (err, list) {
list.forEach(function (time) {
if (Date.parse(schedule.start_time) >= Date.parse(time.start_time) && Date.parse(schedule.start_time) <= Date.parse(time.end_time)) {
respond(null, { success: false, message: 'Este funcionário possui uma escala em conflito com o horário selecionado' })
} else if (Date.parse(schedule.end_time) >= Date.parse(time.start_time) && Date.parse(schedule.end_time) <= Date.parse(time.end_time)) {
respond(null, { success: false, message: 'Este funcionário possui uma escala em conflito com o horário selecionado' })
} else if (Date.parse(schedule.start_time) <= Date.parse(time.start_time) && Date.parse(schedule.end_time) >= Date.parse(time.end_time)) {
respond(null, { success: false, message: 'Este funcionário possui uma escala em conflito com o horário selecionado' })
}
schedule.save$(function(err,schedule){
respond(null,schedule)
})
Expand All @@ -49,6 +59,7 @@ seneca()
respond(null, schedule);
});
})
})

.add('role:schedule,cmd:listDay', function (msg, respond) {
var id = msg.id;
Expand Down

0 comments on commit 60f0d82

Please sign in to comment.