546 lines
30 KiB
Plaintext
546 lines
30 KiB
Plaintext
extends layout_side
|
|
|
|
block content
|
|
- function datesDiff(s,e) { var a=moment(e,'DD-MM-YYYY');var b=moment(s,'DD-MM-YYYY'); return a.diff(b,'days'); };
|
|
link(rel='stylesheet', href='https://use.fontawesome.com/releases/v5.6.1/css/all.css', integrity='sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP', crossorigin='anonymous')
|
|
link(rel='stylesheet', type='text/css', href='https://unpkg.com/lightpick@latest/css/lightpick.css')
|
|
link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.css" integrity="sha512-TG239kA30BXeGpy+HpJei+qfJcKo8V9HKpe8UWuVdpk49NGUe86EDhmdXkCxMqD5gSlkLLi6YQ9SbNp+yRa9xQ==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
|
style(type="text/css").
|
|
.mx {
|
|
margin: 0 5px;
|
|
}
|
|
@media print {
|
|
.visible-print { display: inherit !important; }
|
|
.hidden-print { display: none !important; }
|
|
}
|
|
#holidayModal.modal(tabindex='-1', role='dialog', aria-labelledby='holidayModalLabel', aria-hidden='true')
|
|
form(method='POST',id='holidayForm' action='/employee/holidays_byperson/'+employee._id)
|
|
.modal-dialog(role='document', style='width:620px')
|
|
.modal-content
|
|
.modal-header
|
|
h4#holidayModalLabel.modal-title Szabadság kiadása #{employee.name}
|
|
h4.modal-title(id='Holidays', data-remaining=employee.vacationYear-employee.vacationUsed) Kiadható szabadság: #{employee.vacationYear-employee.vacationUsed} nap.
|
|
.modal-body
|
|
h4 Szabadság időtartama:
|
|
input#sField(name='sField',type=text,readonly, style='display:none;')
|
|
input#eField(name='eField',type=text,readonly, style='display:none;')
|
|
input.form-control(id='holidayPicker',name='holidayPicker',type=text, tabindex='2',readonly,style='background-color:#c9ddfc;')
|
|
//input(type="text",id="datepicker")
|
|
br
|
|
.modal-footer
|
|
button.btn.btn-secondary(type='button', data-dismiss='modal') Mégsem
|
|
button.btn.btn-primary(type='submit') Rendben
|
|
br
|
|
label#uid(style='display:none;') #{employee._id}
|
|
label#uname(style='display:none;') #{employee.name}
|
|
.container(style='width:95%')
|
|
|
|
.panel.panel-primary(style='width:95%')
|
|
.panel-heading
|
|
h2 #{title}
|
|
.panel-body
|
|
br
|
|
#form-group(style='margin-left:65px;width:90%;')
|
|
|
|
.row(style='padding-left:10px;')
|
|
.col-sm-2(style='min-width:100px')
|
|
.form-group
|
|
label(style='color:black !important;') Összes szabadság:
|
|
input.form-control(id='vacationYear',name='vacationYear',type=text,readonly, style='color: black;width:140px',value=employee.vacationYear)
|
|
.col-sm-2(style='min-width:100px;')
|
|
.form-group(style='min-width:100px;')
|
|
label(style='color:black !important;') Kiadott szabadság:
|
|
input.form-control(id='vacationUsed',name='vacationUsed',type=text,readonly, style='color: black;width:140px',value=employee.vacationUsed)
|
|
.col-sm-2(style='min-width:100px;')
|
|
.form-group(style='min-width:100px;')
|
|
label(style='color:black !important;') Maradék szabadság:
|
|
input.form-control(id='vacationLeft',name='vacationLeft',type=text,readonly, style='color: black;width:140px',value=employee.vacationYear-employee.vacationUsed)
|
|
.col-sm-5
|
|
.form-group(style='min-width:100px;')
|
|
a.btn.btn-primary.btn-sm(href='#',data-toggle='modal', data-target='#holidayModal',style='margin-top:24px;') Új szabadság kiadása
|
|
|
|
|
button.btn.btn-default.btn-sm(id='print2',name='print2',type='button',style='margin-top:24px;', data-toggle='modal', data-target='#holidayModal')
|
|
span.glyphicon.glyphicon-print
|
|
| Nyomtat
|
|
|
|
|
a.btn.btn-success.btn-sm(href='/employee/detailstemp/'+employee._id,style='margin-top:24px;') Vissza
|
|
br
|
|
#calendar(style="background-color: white;")
|
|
|
|
|
|
|
|
script(type='text/javascript', src='/bower_components/jquery/dist/jquery.min.js')
|
|
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
|
|
script(src='https://cdn.jsdelivr.net/npm/fullcalendar/index.global.min.js')
|
|
script(src='/bower_components/moment/min/moment-with-locales.js')
|
|
script(type='text/javascript', src='/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js')
|
|
script(src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js')
|
|
script(src='https://unpkg.com/lightpick@latest/lightpick.js')
|
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.min.js" integrity="sha512-nD7/PXl2UD6bAYMJVKTLhr7qwnWVvoyqk8/WMzedDKMiQbaNXT3EUPzLYbLUHCLWqAZoXO37aVCtCKmAxZfqGw==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
|
script(src='/js/workingtime.js')
|
|
script.
|
|
//Szabadság törlése
|
|
$(document).on("click",".delete-holiday",function(e)
|
|
{
|
|
var id = $(this).data('id');
|
|
var hid = $(this).data('hid');
|
|
console.log("DataId: "+id+"\nHolidayId: "+hid);
|
|
var r = confirm("Biztosan torli a "+id+" azonosítójú szabadságot?\r\n(A művelet nem visszavonható !)");
|
|
if (r == true)
|
|
{
|
|
$.ajax({
|
|
type: 'DELETE',
|
|
url: '/employee/holidays_delete/'+id+'/'+hid,
|
|
success: function(response)
|
|
{
|
|
//refreshAccessDetails(); // Lista frissítése betöltéskor
|
|
// window.location.href='/';
|
|
console.log('Resp: '+response);
|
|
location.reload();
|
|
alert('Resp: '+response);
|
|
},
|
|
error: function(err)
|
|
{
|
|
alert('A törlés nem sikerült.');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$('#holidayform').on('submit', function(e) {
|
|
e.preventDefault();
|
|
var data = $(this).serialize();
|
|
$.get('/localLogin', data, function(result) {
|
|
if(result.valid == true)
|
|
{
|
|
window.location.href = '/profile';
|
|
}
|
|
else
|
|
{
|
|
$('#loginPopup').html(result);
|
|
}
|
|
});
|
|
});
|
|
$(document).ready(function () {
|
|
//jQuery.noConflict();
|
|
var bodyId = document.getElementById('Holidays');
|
|
var remaining=bodyId.getAttribute('data-remaining');
|
|
|
|
|
|
var picker = new Lightpick({ field: document.getElementById('holidayPicker'),
|
|
singleDate: false,
|
|
inline: true,
|
|
numberOfColumns: 2,
|
|
numberOfMonths: 4,
|
|
disableWeekends: false,
|
|
//minDate: moment(),
|
|
maxDays: remaining,
|
|
//disableDates: [['21.09.2020', '22.09.2020'], ['24.09.2020', '25.09.2020']],
|
|
onSelect: function(start, end){
|
|
var startField = '';
|
|
var endField = '';
|
|
startField = start.format('DD.MM.YYYY');
|
|
endField = end ? end.format('DD.MM.YYYY') : '...';
|
|
document.getElementById('sField').value = startField;
|
|
document.getElementById('eField').value = endField;
|
|
}
|
|
|
|
});
|
|
|
|
console.log(remaining);
|
|
$.get('/employee/get_holidaysById/'+document.getElementById('uid').innerHTML, function(result){
|
|
console.log(result);
|
|
picker.setDisableDates(result);
|
|
|
|
|
|
});
|
|
|
|
// Szabadság kijelzés frissítése módosítás után.
|
|
const refreshCounters=async function(uid){
|
|
const response = await fetch("/employee/holidays_count/"+uid,
|
|
{
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "GET",
|
|
|
|
});
|
|
console.log("DATA: "+response)
|
|
if (response.ok){
|
|
const data = await response.json();
|
|
console.log("DATA: "+JSON.stringify(data))
|
|
if (data.response="OK")
|
|
{
|
|
|
|
document.getElementById('vacationLeft').value=data.vacationLeft;
|
|
document.getElementById('vacationYear').value=data.vacationYear;
|
|
document.getElementById('vacationUsed').value=data.vacationUsed;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$("#mworkers").click();
|
|
$("#listworktime").addClass("active");
|
|
// Calendar
|
|
var calendarEl = document.getElementById('calendar');
|
|
var empId = document.getElementById('uid')
|
|
var empname = document.getElementById('uname').textContent
|
|
const year=+moment().format("YYYY")
|
|
var calendar = new FullCalendar.Calendar(calendarEl,
|
|
{
|
|
initialView: 'multiMonthFourMonth',
|
|
locale: 'hu',
|
|
firstDay: 1,
|
|
initialDate: '2024-01-01',
|
|
height: 'auto',
|
|
//eventLimit: true,
|
|
eventOrder: '-order',
|
|
showNonCurrentDates:false,
|
|
//dayMaxEvents: 10,
|
|
//dayMaxEventRows: 10,
|
|
nextDayThreshold: "01:00:00",
|
|
displayEventTime: false,
|
|
editable: true,
|
|
selectable: true,
|
|
eventStartEditable:true,
|
|
eventDurationEditable:true,
|
|
select: async function (start, end, allDay) {
|
|
var vacationLeft = document.getElementById('vacationLeft').value
|
|
|
|
var a = moment(start.start);
|
|
var b = moment(start.end);
|
|
b= b.subtract(1,'days')
|
|
var duration = b.diff(a, 'days')+1
|
|
if (duration>vacationLeft)
|
|
{
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "warning",
|
|
title: 'Nincs ennyi szabid!\n'+duration+' nap',
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
calendar.unselect();
|
|
}
|
|
else {
|
|
|
|
|
|
const result= await Swal.fire(
|
|
{
|
|
title: "Biztosan kiadja a szabadságot? "+moment(a).format('YYYY.MM.DD')+" - "+moment(b).format('YYYY.MM.DD'),
|
|
text: "A szabadság kiadásáról "+empname+" e-mail értesítést fog kapni.",
|
|
icon: "question",
|
|
showDenyButton: true,
|
|
confirmButtonText: 'Igen',
|
|
denyButtonText: 'Nem',
|
|
customClass: {
|
|
actions: 'my-actions',
|
|
confirmButton: 'order-2',
|
|
denyButton: 'order-3',
|
|
},
|
|
}
|
|
);
|
|
if (result.isConfirmed)
|
|
{
|
|
//console.log("Event ID: "+eventDropInfo.event.id)
|
|
//console.log("Event Before Drop\n"+eventDropInfo.oldEvent.start+'-'+eventDropInfo.oldEvent.end)
|
|
//console.log("Event After Drop\n"+eventDropInfo.event.start+'-'+eventDropInfo.event.end)
|
|
const response = await fetch("/employee/holidays_byperson_fc/"+empId.textContent,
|
|
{
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify({ sField: moment(a).format('DD.MM.YYYY'),eField: moment(b).format('DD.MM.YYYY')}),
|
|
});
|
|
const data = await response.json();
|
|
if (!response.ok)
|
|
{
|
|
Swal.fire('Error', '', 'error')
|
|
}
|
|
if (data.response="OK")
|
|
{
|
|
//var empId = document.getElementById('uid')
|
|
const year=moment(start.view.activeStart).format("YYYY")
|
|
calendar.removeAllEventSources();
|
|
calendar.addEventSource('/employee/holidays_byperson_calendar/'+empId.textContent+'/'+year)
|
|
refreshCounters(uid.textContent);
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "success",
|
|
title: data.message,
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
|
|
//Swal.fire('Saved!', '', 'success')
|
|
}
|
|
|
|
}
|
|
else
|
|
if (result.isDenied)
|
|
{
|
|
//Swal.fire('Changes are not saved', '', 'info')
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "info",
|
|
title: 'Nem történt változtatás',
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
calendar.unselect();
|
|
}
|
|
}
|
|
},
|
|
views: {
|
|
multiMonthFourMonth: {
|
|
type: 'multiMonth',
|
|
duration: { months: 12 },
|
|
multiMonthMaxColumns: 2,
|
|
eventLimit: 10,
|
|
}
|
|
},
|
|
//initialEvents: res,
|
|
//events: '/employee/holidays_byperson_calendar/'+empId.textContent+'/'+year,
|
|
weekNumbers: true,
|
|
themeSystem: 'default',
|
|
eventClick: async function(info)
|
|
{
|
|
//alert('Event: ' + info.event.title+'\n'+info.event.id+'\n'+info.event.extendedProps.employeeId);
|
|
console.log('Event: ' + info.event.title+'\n'+info.event.id+'\n'+info.event.extendedProps.employeeId)
|
|
if (info.event.extendedProps.active)
|
|
{
|
|
var bgColor=info.el.style.backgroundColor;
|
|
// change the border color just for fun
|
|
info.el.style.backgroundColor = 'red';
|
|
const result= await Swal.fire(
|
|
{
|
|
title: "Biztosan törli a szabadságot?\n"+moment(info.event.start).format('YYYY.MM.DD')+' - '+moment(info.event.stop).format('YYYY.MM.DD'),
|
|
text: "A törlésről "+info.event.title+" e-mail értesítést fog kapni.",
|
|
icon: "question",
|
|
showDenyButton: true,
|
|
confirmButtonText: 'Igen',
|
|
denyButtonText: 'Nem',
|
|
customClass: {
|
|
actions: 'my-actions',
|
|
confirmButton: 'order-2',
|
|
denyButton: 'order-3',
|
|
},
|
|
}
|
|
);
|
|
if (result.isConfirmed)
|
|
{
|
|
console.log("Event ID: "+info.event.id)
|
|
|
|
console.log("Event After Drop\n"+info.event.start+'-'+info.event.end)
|
|
const response = await fetch("/employee/holiday_destroy/"+info.event.extendedProps.employeeId+"/"+info.event.id,
|
|
{
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "DELETE",
|
|
body: JSON.stringify({ event: info.event }),
|
|
});
|
|
const data = await response.json();
|
|
if (!response.ok)
|
|
{
|
|
Swal.fire('Error', '', 'error')
|
|
}
|
|
if (data.response=="OK")
|
|
{
|
|
info.el.style.backgroundColor=bgColor;
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "success",
|
|
title: data.message,
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
})
|
|
var empId = document.getElementById('uid')
|
|
const year=moment(info.view.activeStart).format("YYYY")
|
|
calendar.removeAllEventSources();
|
|
calendar.addEventSource('/employee/holidays_byperson_calendar/'+empId.textContent+'/'+year)
|
|
refreshCounters(empId.textContent);
|
|
}
|
|
else
|
|
{
|
|
info.el.style.backgroundColor=bgColor;
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "error",
|
|
title: data.message,
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
}
|
|
);
|
|
|
|
|
|
//Swal.fire('Saved!', '', 'success')
|
|
}
|
|
|
|
}
|
|
else
|
|
if (result.isDenied)
|
|
{
|
|
//Swal.fire('Changes are not saved', '', 'info')
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "info",
|
|
title: 'Nem történt változtatás',
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
info.el.style.backgroundColor=bgColor;
|
|
info.revert();
|
|
}
|
|
}
|
|
},
|
|
eventDrop: async function( eventDropInfo )
|
|
{
|
|
const result= await Swal.fire(
|
|
{
|
|
title: "Biztosan végrehajtja a módosítást?",
|
|
text: "A változásról "+eventDropInfo.event.title+" e-mail értesítést fog kapni.",
|
|
icon: "question",
|
|
showDenyButton: true,
|
|
confirmButtonText: 'Igen',
|
|
denyButtonText: 'Nem',
|
|
customClass: {
|
|
actions: 'my-actions',
|
|
confirmButton: 'order-2',
|
|
denyButton: 'order-3',
|
|
},
|
|
}
|
|
);
|
|
if (result.isConfirmed)
|
|
{
|
|
console.log("Event ID: "+eventDropInfo.event.id)
|
|
console.log("Event Before Drop\n"+eventDropInfo.oldEvent.start+'-'+eventDropInfo.oldEvent.end)
|
|
console.log("Event After Drop\n"+eventDropInfo.event.start+'-'+eventDropInfo.event.end)
|
|
const response = await fetch("/employee/holiday_drop_update",
|
|
{
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify({ event: eventDropInfo.event,oldEvent: eventDropInfo.oldEvent }),
|
|
});
|
|
const data = await response.json();
|
|
if (!response.ok)
|
|
{
|
|
Swal.fire('Error', '', 'error')
|
|
}
|
|
if (data.response="OK")
|
|
{
|
|
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "success",
|
|
title: data.message,
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
//Swal.fire('Saved!', '', 'success')
|
|
}
|
|
|
|
}
|
|
else
|
|
if (result.isDenied)
|
|
{
|
|
//Swal.fire('Changes are not saved', '', 'info')
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "info",
|
|
title: 'Nem történt változtatás',
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
eventDropInfo.revert();
|
|
}
|
|
|
|
|
|
},
|
|
eventResize: async function( eventResizeInfo ) {
|
|
const result= await Swal.fire(
|
|
{
|
|
title: "Biztosan végrehajtja a módosítást?",
|
|
text: "A változásról "+eventResizeInfo.event.title+" e-mail értesítést fog kapni.",
|
|
icon: "question",
|
|
showDenyButton: true,
|
|
confirmButtonText: 'Igen',
|
|
denyButtonText: 'Nem',
|
|
customClass: {
|
|
actions: 'my-actions',
|
|
confirmButton: 'order-2',
|
|
denyButton: 'order-3',
|
|
},
|
|
}
|
|
);
|
|
if (result.isConfirmed)
|
|
{
|
|
console.log("Event ID: "+eventResizeInfo.event.id)
|
|
console.log("Event Before Drop\n"+eventResizeInfo.oldEvent.start+'-'+eventResizeInfo.oldEvent.end)
|
|
console.log("Event After Drop\n"+eventResizeInfo.event.start+'-'+eventResizeInfo.event.end)
|
|
const response = await fetch("/employee/holiday_resize_update",
|
|
{
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify({ event: eventResizeInfo.event,oldEvent: eventResizeInfo.oldEvent }),
|
|
});
|
|
const data = await response.json();
|
|
if (!response.ok)
|
|
{
|
|
Swal.fire('Error', '', 'error')
|
|
}
|
|
if (data.response="OK")
|
|
{
|
|
var vacationUsed = document.querySelector('input[name="vacationUsed"]');
|
|
var vacationLeft = document.querySelector('input[name="vacationLeft"]');
|
|
vacationUsed.value=data.vacationUsed;
|
|
vacationLeft.value=data.vacationLeft;
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "success",
|
|
title: data.message,
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
//Swal.fire('Saved!', '', 'success')
|
|
}
|
|
|
|
}
|
|
else
|
|
if (result.isDenied)
|
|
{
|
|
//Swal.fire('Changes are not saved', '', 'info')
|
|
Swal.fire({
|
|
position: "top-end",
|
|
icon: "info",
|
|
title: 'Nem történt változtatás',
|
|
showConfirmButton: false,
|
|
timer: 1500
|
|
});
|
|
eventDropInfo.revert();
|
|
}
|
|
},
|
|
// ÉV választás
|
|
datesSet: async function (info) {
|
|
var empId = document.getElementById('uid')
|
|
const year=moment(info.view.activeStart).format("YYYY")
|
|
calendar.removeAllEventSources();
|
|
calendar.addEventSource('/employee/holidays_byperson_calendar/'+empId.textContent+'/'+year)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
calendar.render();
|
|
});
|
|
|
|
|