Szabadság kiadás hozzáadva FullCalendarból
This commit is contained in:
parent
644ea4236e
commit
dff21701fd
|
|
@ -2310,7 +2310,50 @@ router.delete('/holidays_delete/:uid/:hid',utils.ensureAuthenticated,function(re
|
|||
})
|
||||
|
||||
})
|
||||
// Szabadság kiadás full calendar
|
||||
router.post('/holidays_byperson_fc/:id', utils.ensureAuthenticated,function(req,res){
|
||||
console.log(req.params.id);
|
||||
console.log(req.body);
|
||||
moment.locale('HU');
|
||||
let startd = moment(req.body.sField, 'DD.MM.YYYY'); //Pick any format
|
||||
let endd = moment(req.body.eField, 'DD.MM.YYYY');
|
||||
let weekdayCounter = 0;
|
||||
|
||||
while (startd <= endd) {
|
||||
console.log(startd.format('ddd'));
|
||||
// if (startd.format('ddd') !== 'szo' && startd.format('ddd') !== 'vas'){
|
||||
weekdayCounter++; //add 1 to your counter if its not a weekend day
|
||||
//}
|
||||
startd = moment(startd, 'DD.MM.YYYY').add(1, 'days'); //increment by one day
|
||||
}
|
||||
console.log("Hétköznapok",weekdayCounter); //display your total elapsed weekdays in the console!
|
||||
|
||||
let hd ={
|
||||
start_date: req.body.sField,
|
||||
end_date: req.body.eField,
|
||||
|
||||
duration: weekdayCounter,
|
||||
|
||||
};
|
||||
//hd.id=hd._id;
|
||||
Employee.findByIdAndUpdate(req.params.id,{ $inc: {'vacationUsed': weekdayCounter },$push: {holidayData:hd}},function(error,success){
|
||||
if (error) {
|
||||
console.log(error);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send({'response':'Fail','message':'Sikertelen művelet!'});
|
||||
} else {
|
||||
console.log(success);
|
||||
sendEmailHolidayNotify(success.name,success.email,hd);
|
||||
//res.redirect('/employee/holidays_byperson/'+req.params.id);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send({'response':'OK','message':'A szabadság sikeresen kiírva!'});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Szabadság kiadás régi
|
||||
router.post('/holidays_byperson/:id', utils.ensureAuthenticated,function(req,res){
|
||||
console.log(req.params.id);
|
||||
console.log(req.body);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ block content
|
|||
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%')
|
||||
|
|
@ -158,6 +159,7 @@ block content
|
|||
// 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,
|
||||
{
|
||||
|
|
@ -174,8 +176,92 @@ block content
|
|||
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")
|
||||
{
|
||||
|
||||
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',
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ script(type='text/javascript',src='/js/datepicker.js')
|
|||
|
||||
|
||||
|
||||
script(src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js')
|
||||
script(src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js')
|
||||
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
|
||||
script(src='/bower_components/moment/min/moment-with-locales.js')
|
||||
//-script(type='text/javascript', src='/bower_components/bootstrap/dist/js/bootstrap.min.js')
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ block content
|
|||
script(src='https://cdn.jsdelivr.net/gh/gitbrent/bootstrap-switch-button@1.1.0/dist/bootstrap-switch-button.min.js')
|
||||
|
||||
script.
|
||||
// $(document).ready(function () {
|
||||
$(document).ready(function () {
|
||||
// Get current page name
|
||||
const currentUrl = window.location.href;
|
||||
var page = currentUrl.split("/").pop();
|
||||
|
|
@ -196,29 +196,17 @@ block content
|
|||
element.parent().removeClass('has-error');
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
//$(document).ready(function() {
|
||||
function specialValidation(value, validator) {
|
||||
// Determine the numbers which are generated in captchaOperation
|
||||
var items = $('#otherField').txt();
|
||||
return value == sum;
|
||||
};
|
||||
|
||||
})
|
||||
//})
|
||||
$('tr[data-href]').on("click", function() {
|
||||
document.location = $(this).data('href');
|
||||
});
|
||||
/* function renderEventContent(eventInfo) {
|
||||
return (
|
||||
' <div> \
|
||||
<p>{eventInfo.timeText}</p> \
|
||||
<i>{eventInfo.event.title}</i> \
|
||||
<button>123</button> \
|
||||
</div>'
|
||||
);
|
||||
}*/
|
||||
/* function haha(dayRenderInfo){
|
||||
console.log(dayRenderInfo)
|
||||
}*/
|
||||
|
||||
// Szerkesztés modal
|
||||
$(document).on('show.bs.modal','#vehicleEditModal', function () {
|
||||
|
|
@ -228,7 +216,7 @@ block content
|
|||
var getIdFromRow = $(event)[0].currentTarget.activeElement.getAttribute('data-id')//$(event.target).closest('tr').data('id');
|
||||
var getVidFromRow = $(event)[0].currentTarget.activeElement.getAttribute('data-vid');//$(event.target).closest('tr').data('vid');
|
||||
var getVnameFromRow = $(event)[0].currentTarget.activeElement.getAttribute('data-name');//$(event.target).closest('tr').data('name');
|
||||
$('.modal-backdrop').css('background', 'red');
|
||||
//$('.modal-backdrop').css('background', 'red');
|
||||
//$("#fuelingHeader").html(getIdFromRow);
|
||||
$(this).find('#vehicleId').html($('<b> Szerkesztés: '+ getVnameFromRow + '</b> <b style="float:right">'+getVidFromRow+'</b>' ))
|
||||
$.get('/vehicles/api/getVehicle/'+getIdFromRow,function(data)
|
||||
|
|
@ -358,4 +346,5 @@ block content
|
|||
}
|
||||
});
|
||||
});
|
||||
// });
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue