Thursday, 12 June 2014

How to Save clientEvents from FullCalendar in MySQL /w PHP ?

Edit some things in js:

$( "#datepicker_startdate" ).datepicker({
   dateFormat: 'dd/mm/yy'
  });

$( "#datepicker_enddate" ).datepicker({
   dateFormat: 'dd/mm/yy'
  });

add following lines in addEvent:
// is a date selected in the datepickers, then use those dates
var dp_startdate  = $( "#datepicker_startdate" ).datepicker('getDate');
var dp_enddate   = $( "#datepicker_enddate" ).datepicker('getDate');

if(dp_startdate !== null && dp_enddate !== null) {
 start = dp_startdate;
 end = dp_enddate;
}

before:

if($('#allday_checkbox').is(':checked')) {
 var startdate  = Date.parse(start) / 1000;
 var enddate  = Date.parse(end) / 1000;
} else {
    var startdate  = Date.parse(start.format('mm/dd/yyyy')+ ' ' + $('#timepicker_starttime')[0].value + ':00') / 1000;
    var enddate  = Date.parse(end.format('mm/dd/yyyy')+ ' ' + $('#timepicker_endtime')[0].value + ':00') / 1000;
    }

add following lines in onClickEvent:

$( "#datepicker_startdate" ).datepicker('setDate',  dateFormat(Date.parse(event.date_start),'dd/mm/yy')); 
$( "#datepicker_enddate" ).datepicker('setDate', dateFormat(Date.parse(event.date_end),'dd/mm/yy'));

before:

$('#timepicker_starttime')[0].value = event.time_start.substring(0,5);
$('#timepicker_endtime')[0].value = event.time_end.substring(0,5);

and following lines in updateEvent:

// is a date selected in the datepickers, then use those dates
var dp_startdate  = $( "#datepicker_startdate" ).datepicker('getDate');
var dp_enddate   = $( "#datepicker_enddate" ).datepicker('getDate');

if(dp_startdate !== null && dp_enddate !== null) {
 event.start = dp_startdate;
 event.end = dp_enddate;
}

before:

if($('#allday_checkbox').is(':checked')) {
 var startdate = Date.parse(event.start) / 1000;
 var enddate = event.end !== null ? Date.parse(event.end) / 1000 : startdate;
 event.allDay = 1;
}

No comments:

Post a Comment