144 lines
5.7 KiB
JavaScript
Vendored
144 lines
5.7 KiB
JavaScript
Vendored
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// import { Calendar } from '@fullcalendar/core';
|
|
// import googleCalendarPlugin from '@fullcalendar/google-calendar';
|
|
var calendarEl = document.getElementById('calendar');
|
|
|
|
var calendar = new FullCalendar.Calendar(calendarEl, {
|
|
timeZone: 'UTC',
|
|
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);
|
|
$('#event').modal('show');
|
|
console.log(info.dateStr);
|
|
//inserire qui richiamo a pagina modale di inserimento appuntamento.
|
|
}
|
|
});
|
|
calendar.setOption('locale', 'it');
|
|
calendar.render();
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
var SITEURL = "{{ url('/admin/') }}";
|
|
// $(".draggable").draggable();
|
|
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'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');
|
|
}
|
|
/**/ |