Recurring Events

Hi,

My goal over the next few months is to provide a scheduling system for Golf Pro’s as part of an app for a CMS. I’m experiencing one or two issues with initial setup, currently the recurring events seems to be having problems.

Recently, someone kindly helped me with options connector, which works well, but only until I introduced recurring events, now the options in my select are no longer being outputted.

Also, the recurring event saves and displays as expected, until you navigate away from the page and then back to the page, the recurring event has disappeared even though the entry has been saved to the database. The entry stored is for example: ‘week_4___2#4’ in the rec_type field.

Can someone please advise or provide a detailed example of recurring events in action both client and server side for PHP? I’ll need t know why this is affecting existing code for Options Selector too.

The code for my connector is:

require_once("../codebase/connector/scheduler_connector.php");
 
$res=mysql_connect("localhost","pass","pass");
mysql_select_db("db_name");

$list = new OptionsConnector($res);
$list->render_sql("SELECT clientId as value, CONCAT(firstName, ' ',lastName) as label from golf_clients","value","value,label");

$conn = new SchedulerConnector($res);
$conn->enable_log("temp.log");

$conn->set_options("student", $list);
 
$conn->render_table("golf_bookings","booking_id","start_date,end_date,text,coach,student,rec_type");

and my client-side code is as:

function init() {
	scheduler.config.xml_date="%Y-%m-%d %H:%i";
	scheduler.config.first_hour = 8;
	scheduler.config.last_hour = 20;

	scheduler.config.details_on_create = true;
	scheduler.config.details_on_dblclick = true;
	scheduler.config.prevent_cache = true;
	scheduler.config.full_day = true;

	scheduler.locale.labels.section_coach = "Coach:";
	scheduler.locale.labels.section_student = "Student:";			

	var sections = [
		{key:'coach1', label:'Coach 1'},
		{key:'coach2', label:'Coach 2'}
	];

	scheduler.attachEvent("onTemplatesReady", function(){
		var lightbox_form = scheduler.getLightbox(); // this will generate lightbox form
		var inputs = lightbox_form.getElementsByTagName('input');
		var date_of_end = null;
		for (var i=0; i<inputs.length; i++) {
			if (inputs[i].name == "date_of_end") {
				date_of_end = inputs[i];
				break;
			}
		}

		var repeat_end_date_format = scheduler.date.date_to_str("%d.%m.%Y");
		var show_minical = function(){
			if (scheduler.isCalendarVisible())
				scheduler.destroyCalendar();
			else {
				scheduler.renderCalendar({
					position:date_of_end,
					date:scheduler._date,
					navigation:true,
					handler:function(date,calendar) {
						date_of_end.value = repeat_end_date_format(date);
						scheduler.destroyCalendar()
					}
				});
			}
		};
		date_of_end.onclick = show_minical;

	});
	
	scheduler.config.lightbox.sections = [
		{ name:"description", height:130, map_to:"text", type:"textarea" , focus:true },
		{ name:"student", height: 21, map_to: "student", type: "select", options:scheduler.serverList("student") },
		{ name:"coach", height:43, type:"select", options:sections, map_to:"coach", filtering: true },
		{ name:"recurring", type:"recurring", map_to:"rec_type", button:"recurring" },
		{ name:"time", height:72, type:"time", map_to:"auto" }
	];

	scheduler.templates.event_class=function(start, end, event){
        if(event.coach) // if event has subject property then special class should be assigned
            return "event_"+event.coach;

        return ""; // default return
    };

	scheduler.init('scheduler_here',null,"week");

	scheduler.load("data/connector.php");

	var dp = new dataProcessor("data/connector.php");
	dp.init(scheduler);

	var calendar = scheduler.renderCalendar({
		container:"cal_here", 
		navigation:true,
		handler:function(date){
			scheduler.setCurrentView(date, scheduler._mode);
		}
	});
	scheduler.linkCalendar(calendar);
	scheduler.setCurrentView(scheduler._date, scheduler._mode);
}

Jon.

You need to have two more fields in DB and in connector command - event_pid and event_length

$conn->render_table("golf_bookings","booking_id","start_date,end_date,text,coach,student,rec_type,event_pid,event_length");

docs.dhtmlx.com/doku.php?id=dhtm … ntegration

That’s great, thanks. Recurring events now works, but my select still does not. This worked before I introduced recurring events.

Any idea why this would have stopped working?

Jon.

Can you open the connector file directly in browser and check does it have the list of options correctly generated ?

Recurring events must not interfere with options in any way, so while you have valid options connector configuration and valid map_to attribute in lightbox config - options must be shown in editor.

Hi,

So, I opened the file in my browser and got the below:

<coll_options for="student">
<item value="1" label="Jon Young"/>
<item value="5" label="Ellis Young"/>
<item value="6" label="Olivia Young"/>
<item value="11" label="Frankie Young"/>
<item value="12" label="Name Name"/>
<item value="13" label="Name Name"/>
<item value="14" label="Name Name"/>
<item value="15" label="fsef sef"/>
<item value="16" label="ggg ggg"/>
</coll_options>

…so, yes, the connector is working. It’s just not outputting to the select in the lightbox.

It’s the below code that is causing the error, taken from one of the samples:

[code]scheduler.attachEvent(“onTemplatesReady”, function(){
var lightbox_form = scheduler.getLightbox(); // this will generate lightbox form
var inputs = lightbox_form.getElementsByTagName(‘input’);
var date_of_end = null;
for (var i=0; i<inputs.length; i++) {
if (inputs[i].name == “date_of_end”) {
date_of_end = inputs[i];
break;
}
}

	var repeat_end_date_format = scheduler.date.date_to_str("%d.%m.%Y");
	var show_minical = function(){
		if (scheduler.isCalendarVisible())
			scheduler.destroyCalendar();
		else {
			scheduler.renderCalendar({
				position:date_of_end,
				date:scheduler._date,
				navigation:true,
				handler:function(date,calendar) {
					date_of_end.value = repeat_end_date_format(date);
					scheduler.destroyCalendar()
				}
			});
		}
	};
	date_of_end.onclick = show_minical;

});[/code]

If I remove it, the select options come back and work correctly, but a pop up calendar no longer appears when I want to change the ‘end by’ date in the recurring events section…

Any idea how to fix this?

Try to change

scheduler.attachEvent(“onTemplatesReady”, function(){

as

scheduler.attachEvent(“onXLE”, function(){

now it inits the lightbox before options loading, which causes issue, after above change lightbox will be initialized only after data loading, which must fix the issue.

Great, that did the trick. Thanks a lot!