1
votes

I'm using fullcalendar Sean Kenny's fork to add a resource view.

Source web page

the problem is some events are just displayed under the month view, not in week or resource view.

allDay is set to false for all events

$(document).ready(function() {
  var date = new Date();
  var d = date.getDate();
  var m = date.getMonth();
  var y = date.getFullYear();
  $('#calendar').fullCalendar({
    header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,resourceDay'
    },
	monthNames: ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" ], 
	monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'],
	dayNames: [ 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
	dayNamesShort: ['Dom','Lun','Mar','Mie','Jue','Vie','Sab'],
	buttonText: {
		today: 'hoy',
		month: 'mes',
		week: 'semana',
		day: 'dia'
	},
	allDaySlot : false,
	slotDuration: '00:15:00',
	axisFormat: 'HH:mm',
	firstDay : 1,
	minTime: '09:00:00',
	maxTime: '20:00:00',
    defaultView: 'resourceDay',
	allDayDefault: false,
    editable: true,
    droppable: true,
	disableResizing: false,
    resources: [{
		'id': '1',
		'name': 'Sara'
    }, {
		'id': '2',
		'name': 'Angela'
    }],
    selectable: true,
    selectHelper: true,
	events: '\load_events.php',
    select: function(start, end, ev) {
		console.log(ev.resources);
		var horaIni = moment(start).format("YYYY-MM-DD HH:mm:ss");
		var horaFin = moment(end).format("YYYY-MM-DD HH:mm:ss");
		if(isHoraMaxOver(end)){
			alert(mensajeHoraMax);
		}else if(isEventOverlapped(ev,horaIni,horaFin)){
			alert(mensajeOverlap);
		}else if(isDomingo(horaIni)){
			alert("Los Domingos descansamos. Lo siento");
		}else{
			createEvent(horaIni,horaFin,ev);
		}
    },
    eventClick: function(calEvent, jsEvent, view){
		if(isAdmin()){
			modifyEvent(calEvent);
		}
    },
    eventDrop: function (event, delta, revertFunc) {
		var start = moment(event.start).format("YYYY-MM-DD HH:mm:ss");
		var end = moment(event.end).format("YYYY-MM-DD HH:mm:ss");
		if(isHoraMaxOver(end)){
			alert(mensajeHoraMax);
		}else if(isEventOverlapped(event,start,end)){
			alert(mensajeOverlap);
		}else if(isDomingo(start)){
			alert("Los Domingos descansamos. Lo siento");
		}else{
			$.ajax({
				url:  'update_event.php',
				data: 'fechaIni='+ start +'&fechaFin='+ end +'&id='+ event.id +'&profesional='+ event.resources,
				type: "POST"
			});
		}
		$('#calendar').fullCalendar('refresh');
		location.reload(true);
	},
	loading: function(bool){
		if(!bool){
			diableforInvitados();
			updateResources();
		}
	},
	eventRender: function(event, element) { 
            element.find('.fc-event-title').append("<br/>" + event.description);
	},
	eventResize: function(event, delta, revertFunc) {
		var start = moment(event.start).format("YYYY-MM-DD HH:mm:ss");
		var end = moment(event.end).format("YYYY-MM-DD HH:mm:ss");
		if(isHoraMaxOver(end)){
			alert(mensajeHoraMax);
		}else if(isEventOverlapped(event,start,end)){
			alert(mensajeOverlap);
		}else{
			$.ajax({
				url:  'update_event.php',
				data: 'fechaIni='+ start +'&fechaFin='+ end +'&id='+ event.id,
				type: "POST"
			});
		}
		$('#calendar').fullCalendar('refresh');
		 location.reload(true);
	}
  });
  
	$("#calendar").fullCalendar('rerenderEvents');

});

Here is an example of a JSON feed for an event

Object {id: "63", title: "mariana _", start: FCMoment, end: FCMoment, description: "manicura express esmalte normal   12mins   30.00 € <br/>"…}_allDay: false_end: FCMoment_d: Tue Nov 11 2014 21:12:00 GMT-0500 (Eastern Standard Time)_f: "YYYY-MM-DDTHH:mm:ssZ"_i: "2014-11-12T02:12:00-0500"_isAMomentObject: true_isUTC: true_locale: f_offset: 300_pf: Object_tzm: 300__proto__: f_id: "63"_start: FCMoment_d: Tue Nov 11 2014 21:00:00 GMT-0500 (Eastern Standard Time)_f: "YYYY-MM-DDTHH:mm:ssZ"_i: "2014-11-12T02:00:00-0500"_isAMomentObject: true_isUTC: true_locale: f_offset: 300_pf: Object_tzm: 300__proto__: fallDay: falseclassName: Array[0]color: "#00FF1E"description: "manicura express esmalte normal   12mins   30.00 € <br/>"end: FCMomentid: "63"resources: "1"source: Objectstart: FCMomenttitle: "mariana _"__proto__: Object

Here is the link for the current web page: Web page

1
is possible to have a plunker/fiddle of your code? With a .jpg is really difficult.Mario Levrero
@thelamproject I'm also having the same problem but mine, it doesn't show the events in day view only. Do you know how to resolve it?Ricardo

1 Answers

2
votes

I found the solution. The problem was the events were booked on a 24H format and I was capturing them under a 12H format instead. As a results those events that were booked after noon, were not being displayed within the time frame in the Day view. Time frame: 9:00 - 20:00. E.g.: start time: 17:00 -> 5:00PM was transformed into 5AM hence it wasn't displayed.

I had to add

timeFormat: 'H:mm'

and change create_event.php

$fecha_inicio=date("Y-m-d H:i:s",strtotime($fecha_inicio));
$fecha_fin=date("Y-m-d H:i:s",strtotime($fecha_fin));