Szabadság áthelyezés és átméretezés hozzáadva naptárban.
This commit is contained in:
parent
1591fc9b5d
commit
644ea4236e
|
|
@ -57,7 +57,6 @@
|
|||
"pizzip": "^3.1.3",
|
||||
"pug": "^3.0.2",
|
||||
"semantic-ui-table": "^2.3.1",
|
||||
"sweetalert2": "^11.14.2",
|
||||
"util": "^0.10.4",
|
||||
"uuid": "^3.4.0",
|
||||
"uuid-apikey": "^1.5.1",
|
||||
|
|
|
|||
|
|
@ -1037,6 +1037,63 @@ function sendEmailHolidayNotify(employeeName,employeeMail,holiday)
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Szabadság módosítás email kiküldése
|
||||
function sendEmailHolidayResizeNotify(employeeName,employeeMail,holidayNew,holidayOld)
|
||||
{
|
||||
|
||||
var mailOptions = {
|
||||
from: emailFelado,// 'munkanyilvantarto@klelectro.hu',
|
||||
to: employeeMail,
|
||||
subject: 'Szabadság módosítás.',
|
||||
text: 'That was easy!'
|
||||
};
|
||||
|
||||
mailOptions.text='Tisztelt '+employeeName+'!\n Az Ön szabadsága módosításra került az alábbiak szerint.\n\n'+
|
||||
'Eredeti állapot:\n'+
|
||||
'Szabadság kezdete: '+moment(holidayOld.start_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Szabadság vége: '+moment(holidayOld.end_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Napok: '+holidayOld.duration+
|
||||
'Új állapot:\n'+
|
||||
'Szabadság kezdete: '+moment(holidayNew.start_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Szabadság vége: '+moment(holidayNew.end_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Napok: '+holidayNew.duration;
|
||||
|
||||
transporter.sendMail(mailOptions, function(error, info){
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
console.log('Email sent: ' + info.response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Szabadság áthelyezés email kiküldése
|
||||
function sendEmailHolidayDropNotify(employeeName,employeeMail,holidayNew,holidayOld)
|
||||
{
|
||||
|
||||
var mailOptions = {
|
||||
from: emailFelado,// 'munkanyilvantarto@klelectro.hu',
|
||||
to: employeeMail,
|
||||
subject: 'Szabadság áthelyezés.',
|
||||
text: 'That was easy!'
|
||||
};
|
||||
|
||||
mailOptions.text='Tisztelt '+employeeName+'!\n Az Ön szabadsága áthelyezésre került az alábbiak szerint.\n\n'+
|
||||
'Eredeti állapot:\n'+
|
||||
'Szabadság kezdete: '+moment(holidayOld.start_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Szabadság vége: '+moment(holidayOld.end_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Új állapot:\n'+
|
||||
'Szabadság kezdete: '+moment(holidayNew.start_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n'+
|
||||
'Szabadság vége: '+moment(holidayNew.end_date,'DD-MM-YYYY').format('YYYY.MM.DD')+'\n';
|
||||
transporter.sendMail(mailOptions, function(error, info){
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
console.log('Email sent: ' + info.response);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Regisztrációs email kiküldése
|
||||
function sendEmailRegisterNotify(employee,visiblePassword)
|
||||
{
|
||||
|
|
@ -2002,6 +2059,8 @@ router.get("/holidays_byperson_calendar/:id/:year", async function(req, res){
|
|||
display:'all',
|
||||
extendedProps: {
|
||||
employeeId:element._id,
|
||||
employeeName:element.name,
|
||||
employeeEmail:element.email,
|
||||
order:1,
|
||||
},
|
||||
}
|
||||
|
|
@ -2021,6 +2080,8 @@ router.get("/holidays_byperson_calendar/:id/:year", async function(req, res){
|
|||
editable:false,
|
||||
extendedProps: {
|
||||
employeeId:element._id,
|
||||
employeeName:element.name,
|
||||
employeeEmail:element.email,
|
||||
order:0,
|
||||
},
|
||||
}
|
||||
|
|
@ -2139,20 +2200,75 @@ router.get('/holidays_byperson/:id', utils.ensureAuthenticated,function(req,res)
|
|||
});
|
||||
|
||||
// Szabadság módosítása
|
||||
router.post('/holiday_update', async function(req,res){
|
||||
router.post('/holiday_resize_update', async function(req,res){
|
||||
|
||||
const hd_event=req.body.event;
|
||||
var a = moment(hd_event.start,'YYYY-MM-DD');
|
||||
var b = moment(hd_event.end,'YYYY-MM-DD');
|
||||
//a.diff(b, 'days') // 1
|
||||
const hdOld_event=req.body.oldEvent;
|
||||
var c = moment(hdOld_event.start,'YYYY-MM-DD');
|
||||
var d = moment(hdOld_event.end,'YYYY-MM-DD');
|
||||
|
||||
const empId=hd_event.extendedProps.employeeId;
|
||||
let hd ={
|
||||
duration: b.diff(a, 'days'), // 1
|
||||
start_date: a.format('DD.MM.YYYY'),
|
||||
end_date: b.subtract(1,'days').format('DD.MM.YYYY'),
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
const hdOld ={
|
||||
duration: d.diff(c, 'days'), // 1
|
||||
start_date: c.format('DD.MM.YYYY'),
|
||||
end_date: d.subtract(1,'days').format('DD.MM.YYYY'),
|
||||
};
|
||||
|
||||
const kulombseg=hd.duration-hdOld.duration
|
||||
|
||||
const result1=await Employee.findByIdAndUpdate(empId,{ $inc: {'vacationUsed': kulombseg }}, {new: true})
|
||||
const result=await Employee.updateOne(
|
||||
{'_id':mongo.ObjectId(hd_event.extendedProps.employeeId),"holidayData._id":hd_event.id},
|
||||
{$set:{'holidayData.$.start_date':hd.start_date,'holidayData.$.end_date':hd.end_date}},
|
||||
)
|
||||
if (result.ok)
|
||||
{
|
||||
console.log('Holiday Updated! '+hd_event.id);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
sendEmailHolidayResizeNotify(hd_event.extendedProps.employeeName,hd_event.extendedProps.employeeEmail,hd,hdOld)
|
||||
res.status(200).send({'response':'OK','message':'Sikeres módosítás!','vacationUsed':result1.vacationUsed,'vacationLeft':result1.vacationYear-result1.vacationUsed});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('Holiday Failed to Update! '+hd_event.id);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send({'response':'Fail','message':'Sikertelen Módosítás!'});
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// Szabadság áthelyezése
|
||||
router.post('/holiday_drop_update', async function(req,res){
|
||||
|
||||
const hd_event=req.body.event;
|
||||
var a = moment(hd_event.start,'YYYY-MM-DD');
|
||||
var b = moment(hd_event.end,'YYYY-MM-DD');
|
||||
const hdOld_event=req.body.oldEvent;
|
||||
var c = moment(hdOld_event.start,'YYYY-MM-DD');
|
||||
var d = moment(hdOld_event.end,'YYYY-MM-DD');
|
||||
|
||||
|
||||
let hd ={
|
||||
duration: b.diff(a, 'days'), // 1
|
||||
start_date: a.format('DD.MM.YYYY'),
|
||||
end_date: b.subtract(1,'days').format('DD.MM.YYYY'),
|
||||
};
|
||||
|
||||
const hdOld ={
|
||||
duration: d.diff(c, 'days'), // 1
|
||||
start_date: c.format('DD.MM.YYYY'),
|
||||
end_date: d.subtract(1,'days').format('DD.MM.YYYY'),
|
||||
};
|
||||
|
||||
const result=await Employee.updateOne(
|
||||
{'_id':mongo.ObjectId(hd_event.extendedProps.employeeId),"holidayData._id":hd_event.id},
|
||||
{$set:{'holidayData.$.start_date':hd.start_date,'holidayData.$.end_date':hd.end_date}},
|
||||
|
|
@ -2161,7 +2277,8 @@ router.post('/holiday_update', async function(req,res){
|
|||
{
|
||||
console.log('Holiday Updated! '+hd_event.id);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send({'response':'OK','message':'Sikeres módosítás!'});
|
||||
sendEmailHolidayDropNotify(hd_event.extendedProps.employeeName,hd_event.extendedProps.employeeEmail,hd,hdOld)
|
||||
res.status(200).send({'response':'OK','message':'Sikeres módosítás!'});
|
||||
|
||||
}
|
||||
else
|
||||
|
|
@ -2171,7 +2288,7 @@ router.post('/holiday_update', async function(req,res){
|
|||
res.send({'response':'Fail','message':'Sikertelen Módosítás!'});
|
||||
|
||||
}
|
||||
//console.log('Old event: '+old_event.start+' '+old_event.stop)
|
||||
|
||||
})
|
||||
|
||||
// Szabadság törlése
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ block content
|
|||
.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')
|
||||
|
|
@ -200,39 +204,44 @@ block content
|
|||
text: "A változásról "+eventDropInfo.event.title+" e-mail értesítést fog kapni.",
|
||||
icon: "question",
|
||||
showDenyButton: true,
|
||||
//showCancelButton: true,
|
||||
confirmButtonText: 'Igen',
|
||||
denyButtonText: 'Nem',
|
||||
customClass: {
|
||||
actions: 'my-actions',
|
||||
//cancelButton: 'order-1 right-gap',
|
||||
confirmButton: 'order-2',
|
||||
denyButton: 'order-3',
|
||||
},
|
||||
}
|
||||
);//.then((result) => {
|
||||
);
|
||||
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_update",
|
||||
const response = await fetch("/employee/holiday_drop_update",
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
body: JSON.stringify({ event: eventDropInfo.event }),
|
||||
body: JSON.stringify({ event: eventDropInfo.event,oldEvent: eventDropInfo.oldEvent }),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!response.ok)
|
||||
{
|
||||
//throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
//alert(`HTTP error! Status: ${response.status}`)
|
||||
Swal.fire('Error', '', 'error')
|
||||
}
|
||||
if (response.response="OK")
|
||||
if (data.response="OK")
|
||||
{
|
||||
Swal.fire('Saved!', '', 'success')
|
||||
|
||||
Swal.fire({
|
||||
position: "top-end",
|
||||
icon: "success",
|
||||
title: data.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
//Swal.fire('Saved!', '', 'success')
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -240,45 +249,82 @@ block content
|
|||
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();
|
||||
}
|
||||
|
||||
/* if (!confirm("Biztosan végrehajtja a módosítást?\n\nA változásról "+eventDropInfo.event.title+" e-mail értesítést fog kapni."))
|
||||
{
|
||||
eventDropInfo.revert();
|
||||
}
|
||||
else
|
||||
{
|
||||
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_update", {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
body: JSON.stringify({ event: eventDropInfo.event }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
//throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
alert(`HTTP error! Status: ${response.status}`)
|
||||
}
|
||||
if (response.response="OK")
|
||||
{
|
||||
alert("Sikeres Módosítás!")
|
||||
}
|
||||
}*/
|
||||
|
||||
},
|
||||
eventResize:function( eventResizeInfo ) {
|
||||
if (!confirm("Biztosan végrehajtja a módosítást?\n\nA változásról "+eventResizeInfo.event.title+" e-mail értesítést fog kapni."))
|
||||
{
|
||||
eventResizeInfo.revert();
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Event Before Drop\n"+eventResizeInfo.oldEvent.start+'-'+eventResizeInfo.oldEvent.end)
|
||||
console.log("Event After Drop\n"+eventResizeInfo.event.start+'-'+eventResizeInfo.event.end)
|
||||
}
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue