$(document).ready(function() {
var Calendar = FullCalendar.Calendar;
/* initialize the calendar
-----------------------------------------------------------------*/
var calendarEl = document.getElementById('calendar');
var calendar = new Calendar(calendarEl, {
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
plugins: [ 'resourceDayGrid', 'resourceTimeGrid'],
height: 'parent',
//height: 100,
//contentHeight: 100,
now: '2024-11-15 18:00:00',
slotDuration: '00:15',
eventTextColor: "black",
defaultEventMinutes: '01:30:00',
defaultTimedEventDuration: '01:30:00',
editable: false, // enable draggable events
//aspectRatio: 1.8,
scrollTime: '08:30:00', // undo default 6am scrollTime
header: {
left: 'today prev,next',
center: 'title',
right: 'resourceTimeGridDay,resourceTimelineThreeDays'
},
defaultView: 'resourceTimeGridDay',
views: {
resourceTimelineOneDayfif: {
type: 'resourceTimeGrid',
duration: { days: 1 },
slotDuration: '00:15',
buttonText: '15 min'
},
resourceTimelineThreeDays: {
type: 'resourceTimeGrid',
duration: { days: 3 },
buttonText: '3 days'
},
resourceTimelineThreeDaysfif: {
type: 'resourceTimeGrid',
duration: { days: 3 },
slotDuration: '00:15',
buttonText: '3 days 15 min'
}
},
customButtons: {
promptResource: {
text: '+ room',
click: function() {
var title = prompt('Room name');
if (title) {
calendar.addResource({ title: title, id: title });
/* Add Code to save the resource */
}
}
}
},
buttonText: {
today: 'Event Start'
},
resourceLabelText: 'Rooms',
resources: '/schedulerdata.php?eventid=14&action=resourcedata',
events: '/schedulerdata.php?eventid=14&action=eventdata' ,
/* ----- Call Backs ---- */
eventClick: function(info) {
//console.log("Event Click", info);
$('#modalTitle').html(info.event.title);
$('#classdesc').html('Description: '+info.event.extendedProps.description);
$('#classtrack').html('Track: '+info.event.extendedProps.track);
$('#classformat').html('Format: '+info.event.extendedProps.classformat);
$('#pname').html('Name: '+info.event.extendedProps.presenter);
$('#bio').html('Bio: '+info.event.extendedProps.bio);
$('#frmdbid').val(info.event.extendedProps.dbid);
$('#frmevent').val(14);
$('#frmuserid').val();
$('#calendarModal').modal();
$("#attending").val(info.event.extendedProps.attend);
}
});
calendar.render();
$("#calendarModal").on('change', '#attending', function () {
var attending = $('#attending').val();
var action = $('#action').val();
var frmevent = $('#frmevent').val();
var frmuserid = $('#frmuserid').val();
var frmdbid = $('#frmdbid').val();
var event = calendar.getEventById(frmdbid);
var mycolor="";
console.log(event);
if (attending == 1) mycolor="green";
if (attending == 2) mycolor="yellow";
if (attending == 3) mycolor="grey";
if (attending == 0) mycolor="white";
//var alla = $("attendForm").serialize()
/*
*/
console.log(attending+" - "+action+" - "+frmevent+" - "+frmuserid+" - "+frmdbid+ " - " );
$.ajax({
url: '/schedulerdata.php',
type: 'POST', // http method
data: {
action: action,
eventid: frmevent,
userid: frmuserid,
dbid: frmdbid,
attending: attending
}, // data to submit
success: function (data, status, xhr) {
//var obj = JSON.parse(data);
//console.log(obj.dbid);
//console.log(obj.eventend);
//event.setEnd(obj.eventend);
//event.setExtendedProp('dbid' , obj.dbid);
//console.log('eventAdd', data);
},
error: function (jqXhr, textStatus, errorMessage) {
console.log("Error", errorMessage);
}
});
event.setExtendedProp('attend' , attending);
event.setProp('backgroundColor' , mycolor);
});
});