2021-05-30 23:42:30 +02:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
2021-06-02 23:35:07 +02:00
|
|
|
var calendar = $('#calendar').fullCalendar({
|
|
|
|
editable:true,
|
|
|
|
header:{
|
|
|
|
left:'prev,next today',
|
|
|
|
center:'title',
|
|
|
|
right:'month,agendaWeek,agendaDay'
|
|
|
|
},
|
|
|
|
events: 'eventos.php',
|
|
|
|
selectable:true,
|
|
|
|
selectHelper:true,
|
|
|
|
timeFormat: 'H:mm',
|
|
|
|
select: function(start, end, allDay)
|
|
|
|
{
|
|
|
|
var title = prompt("Enter Event Title");
|
|
|
|
if(title)
|
2021-05-30 23:42:30 +02:00
|
|
|
{
|
|
|
|
var e = {
|
2021-06-02 23:35:07 +02:00
|
|
|
"start" : $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss"),
|
|
|
|
"end" : $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss"),
|
|
|
|
"title" : title
|
2021-05-30 23:42:30 +02:00
|
|
|
};
|
|
|
|
$.ajax({
|
2021-06-02 23:35:07 +02:00
|
|
|
url:"eventos.php",
|
|
|
|
type:"POST",
|
2021-05-30 23:42:30 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2021-06-02 23:35:07 +02:00
|
|
|
dataType: "json",
|
2021-05-30 23:42:30 +02:00
|
|
|
data:JSON.stringify(e),
|
2021-06-02 23:35:07 +02:00
|
|
|
success:function()
|
|
|
|
{
|
2021-05-30 23:42:30 +02:00
|
|
|
calendar.fullCalendar('refetchEvents');
|
2021-06-02 23:35:07 +02:00
|
|
|
alert("Added Successfully");
|
2021-05-30 23:42:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-06-02 23:35:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
editable:true,
|
|
|
|
eventResize:function(event)
|
|
|
|
{
|
|
|
|
var e = {
|
|
|
|
"id" : event.id,
|
|
|
|
"userId": event.userId,
|
|
|
|
"start" : $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss"),
|
|
|
|
"end" : $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss"),
|
|
|
|
"title" : event.title
|
|
|
|
};
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url:"eventos.php?idEvento="+event.id,
|
|
|
|
type:"PUT",
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
dataType:"json",
|
|
|
|
data:JSON.stringify(e),
|
|
|
|
success:function(){
|
|
|
|
calendar.fullCalendar('refetchEvents');
|
|
|
|
alert('Event Update');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
eventDrop:function(event)
|
|
|
|
{
|
|
|
|
var e = {
|
|
|
|
"id" : event.id,
|
|
|
|
"userId": event.userId,
|
|
|
|
"start" : $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss"),
|
|
|
|
"end" : $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss"),
|
|
|
|
"title" : event.title
|
|
|
|
};
|
|
|
|
$.ajax({
|
|
|
|
url:"eventos.php?idEvento="+event.id,
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
dataType: "json",
|
|
|
|
type:"PUT",
|
|
|
|
data:JSON.stringify(e),
|
|
|
|
success:function()
|
|
|
|
{
|
|
|
|
calendar.fullCalendar('refetchEvents');
|
|
|
|
alert("Event Updated");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
eventClick:function(event)
|
|
|
|
{
|
|
|
|
if(confirm("Are you sure you want to remove it?"))
|
2021-05-30 23:42:30 +02:00
|
|
|
{
|
2021-06-02 23:35:07 +02:00
|
|
|
var id = event.id;
|
2021-05-30 23:42:30 +02:00
|
|
|
$.ajax({
|
2021-06-02 23:35:07 +02:00
|
|
|
url:"eventos.php?idEvento="+id,
|
2021-05-30 23:42:30 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
dataType: "json",
|
2021-06-02 23:35:07 +02:00
|
|
|
type:"DELETE",
|
2021-05-30 23:42:30 +02:00
|
|
|
success:function()
|
|
|
|
{
|
|
|
|
calendar.fullCalendar('refetchEvents');
|
2021-06-02 23:35:07 +02:00
|
|
|
alert("Event Removed");
|
|
|
|
},
|
|
|
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|
|
|
alert("Status: " + textStatus); alert("Error: " + errorThrown);
|
2021-05-30 23:42:30 +02:00
|
|
|
}
|
2021-06-02 23:35:07 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|