Creato evento con data e ora (start-end) per google-calendar

This commit is contained in:
2023-10-24 15:23:49 +02:00
parent 908d8f9328
commit a819ef01ff
7 changed files with 114 additions and 133 deletions

View File

@@ -6,29 +6,32 @@ document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'UTC',
//timeZone: 'UTC',
timeZone: 'Europe/Rome',
initialView: 'timeGridWeek',
// plugins: [ googleCalendarPlugin ],
googleCalendarApiKey: 'AIzaSyClqRqDMqD4grSx5HeLq1lXMxan1-UjK_E',
events: {
googleCalendarId: 'brebar.family@gmail.com'
},
// events: 'admin/test/calendar/google',
editable: true,
selectable: true,
// plugins: [dayGridPlugin],
// initialView: 'dayGridWeek',
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay' // user can switch between the two
},
dateClick: function(info) {
// alert('Clicked on: ' + info.dateStr);
$('#start').val(info.dateStr);
var starttime =moment(info.dateStr);
var endtime = moment(info.dateStr).add(30,'m');
$('#startDay').val(moment(starttime).format("Y-M-D")) ;
$('#startHour').val(moment(starttime).format("HH:mm")) ;
$('#endDay').val(moment(endtime).format("Y-M-D")) ;
$('#endHour').val(moment(endtime).format("HH:mm")) ;
$('#event').modal('show');
console.log(info.dateStr);
//inserire qui richiamo a pagina modale di inserimento appuntamento.
console.log(info.dateStr);
console.log(endtime.dateStr);
}
});
calendar.setOption('locale', 'it');
@@ -44,101 +47,6 @@ $(document).ready(function () {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
});
});
/*
var calendar = $('#calendar').fullCalendar({
editable: true,
events: SITEURL + "/fullcalendar",
displayEventTime: true,
editable: true,
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Titolo evento:');
if (title) {
var start = $.fullCalendar.formatDate(start, "Y-MM-DD");
var end = $.fullCalendar.formatDate(end, "Y-MM-DD");
$.ajax({
url: SITEURL + "/fullcalendar",
data: {
title: title,
start: start,
end: end,
type: 'add'
},
type: "POST",
success: function (data) {
displayMessage("Evento creato con successo");
calendar.fullCalendar('renderEvent',
{
id: data.id,
title: title,
start: start,
end: end,
allDay: allDay
},true);
calendar.fullCalendar('unselect');
}
});
}
},
eventDrop: function (event, delta) {
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD");
var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD");
$.ajax({
url: SITEURL + '/fullcalendar',
data: {
title: event.title,
start: start,
end: end,
id: event.id,
type: 'update'
},
type: "POST",
success: function (response) {
displayMessage("Event Updated Successfully");
}
});
},
eventClick: function (event) {
var deleteMsg = confirm("vuoi veramente cancellare?");
if (deleteMsg) {
$.ajax({
type: "POST",
url: SITEURL + '/fullcalendar',
data: {
id: event.id,
type: 'delete'
},
success: function (response) {
calendar.fullCalendar('removeEvents', event.id);
displayMessage("Event Deleted Successfully");
}
});
}
}
});
});
function displayMessage(message) {
toastr.success(message, 'Event');
}
/**/