how to save recurring events as individual events?

Thanks, I meant onEventChanged, but actually event_pid was being populated in that function anyway.

Any idea how to resolve my timeline view issue?

Thanks.

Code, which you are using, looks fine, and must not cause such issues.
Can you provide any kind of sample or demo link where problem can be reconstructed.

Unfortunately our environment is password protected. I could take a screen shot, but that wouldn’t be helpful…if there are other parts of code that you would like to see, let me know. I will also try to think of other things that might be causing this issue…

Thanks.

I have included the source code for the calendar when it loads. Please let me know if this is more helpful.

[code]<?xml version="1.0" encoding="utf-8"?>

Microscopy Core Scheduling @import url("common/css/default.css"); @import url("microscopy_core/css/mcs.css"); @import url("microscopy_core/css/dhtmlxscheduler.css"); @import url("microscopy_core/css/dhtmlxscheduler_recurring.css"); @import url("microscopy_core/css/dhtmlxscheduler_ext.css"); @import url("common/css/default_print.css") print;
PENN

Microscopy Core Scheduling


html, body { margin:0px; padding:0px; height:100%; overflow:hidden; } /*Maintenance event in day or week view*/ .dhx_cal_event.maintenance div { background-color:magenta !important; color:white !important; } /*Maintenance multi-day event in month view*/ .dhx_cal_event_line.maintenance { background-color:magenta !important; color:white !important; } /*Maintenance event with fixed time, in month view*/ .dhx_cal_event_clear.maintenance { color:magenta !important; } /*Billed event in day or week view*/ .dhx_cal_event.billed div { background-color:navy !important; color:white !important; } /*Billed multi-day event in month view*/ .dhx_cal_event_line.billed { background-color:navy !important; color:white !important; } /*Billed event with fixed time, in month view*/ .dhx_cal_event_clear.billed { color:navy !important; } /*User's event in day or week view*/ .dhx_cal_event.own_event div { background-color:green !important; color:white !important; } /*User's multi-day event in month view*/ .dhx_cal_event_line.own_event { background-color:green !important; color:white !important; } /*User's event with fixed time, in month view*/ .dhx_cal_event_clear.own_event { color:green !important; }
 WORKING
 
 
 
[/code]

Hi there,

  Well, basically, I'm trying to do the same and to add recurring events as separate events, but I have a small question concerning this code:
scheduler.attachEvent("onEventAdded", function(event_id,event_object){
//alert(event_object.toSource());
                    //return false;
                    if(event_id!='' && scheduler.getEvent(event_id).rec_type){
                        var eventText = event_object.text;                           

                        var repeatArray = new Array();
                        var repeatArray = scheduler.getRecDates(event_id);
                        var repeatCount = repeatArray.length;
                        var new_id = event_id; //added
                        scheduler.deleteEvent(event_id);                       

                        for (var i = 0; i < repeatCount; i++){
                          var start_date = repeatArray[i]['start_date'];
                          var end_date = repeatArray[i]['end_date'];

                          scheduler.addEvent({
                                id:new_id, //added
                                start_date: start_date,
                                end_date: end_date,
                                text:eventText                               
                            });
                          if (new_id!=event_id) //added
                                dp.setUpdated(id, true, "inserted"); //added
                          new_id = scheduler.uid(); //added
                        }
                    }
                    else return true;

Typically, speaking, the addEvent function takes only four parameters. However, my events have some twenty odd fields that needs to be saved. In case of non-recurring event, I already have a “save_form” function that takes care of this issue (called when someone presses the save button on my custom lightbox), but if I have to add events using the “addEvent” method, how can I preserve all of my information?

Wouldn’t it be possible to just copy the event_object, change the start_date, end_date and ID and then save the resulting object into the scheduler? I mean, the event_object already HAS everything I need so…

Anyway, thanks in advance

Osu

Hi, I am completely lost

I’m posting to my server this data from Scheduler:

$rec_type = ‘month_1_1_2_’;
$start_date = ‘19/12/2010 10:00’;
$end_date = ‘25/02/2011 11:00’;
$event_length = ‘3600’;

I can’t seem to find in the SchedulerHelper how to use these values to generate the events individually. In the example I’m looking at a few hundred events that I would like the PHP script/helper to spit out individually.

Am I completely lost or is this something that is possible?

br,

I have included the source code for the calendar when it loads. Please let me know if this is more helpful.

Unfortunately, it still not clear.
One thing which you can try, in onEventChanged hanlder, change code as

scheduler.attachEvent("onEventChanged", function(event_id,event_object) { event_object = scheduler.getEvent(event_id);

While provided ID is correct for sure, the object may reffer to the master events in some complex cases.

Typically, speaking, the addEvent function takes only four parameters.
addEvent has alternative syntax, which allows to use any number of custom fields - last snippet at
docs.dhtmlx.com/doku.php?id=dhtm … addevent&s[]=addEvent

Wouldn’t it be possible to just copy the event_object
This is inner method, so its functionality can change in next version

next is the copy of code, which used in the scheduler to make copy for some instance of recurring event

var nev = this._copy_event(ev); //this == scheduler nev.id = nid; nev.event_pid = id[0]; nev.event_length = id[1]; nev.rec_type = nev.rec_pattern = "none"; this.addEvent(nev);

Am I completely lost or is this something that is possible?
helper class can’t add events to DB, it can be used to calculate dates of instances based on master event info ( rec_type and dates )

Original class works only with DB and need to be modified, to work with custom input.

I’ve stumbled upon a weird mistake and I’m at a loss as to what could possibly be causing it. I’ve taken the function you wrote earlier and adapted it for my needs, here’s the code below:

var firstRec = true;
scheduler.attachEvent("onEventAdded", function(event_id,event_object)
	{
		var test = scheduler.getEvent(event_id).rec_pattern;
		var dp = new dataProcessor("calendrierConnecteur.php");
		
		if(event_id != '' && scheduler.getEvent(event_id).rec_pattern && firstRec)
		{
			var eventCopy = event_object;
			//alert("recurrent");
			//alert(event_object.text);
			var eventText = event_object.text;
			var repeatArray = new Array();
			var repeatArray = scheduler.getRecDates(event_id);
			var repeatCount = repeatArray.length;
			var new_id = event_id;
			 
			scheduler.deleteEvent(event_id);
			firstRec = false;
			
			for (var i = 0; i < repeatCount; i++)
			{
				var start_date = repeatArray[i]['start_date'];
				var end_date = repeatArray[i]['end_date'];

				scheduler.addEvent({
					id:new_id, 
					start_date: start_date,
					end_date: end_date,
					text:eventText,
					CalendrierStrategique: eventCopy.CalendrierStrategique,
					Procedure: eventCopy.Procedure,
					Description: eventCopy.Description,
					Titre: eventCopy.Titre,
					ANoPersonne: eventCopy.ANoPersonne,
					DeNoPersonne: eventCopy.DeNoPersonne,
					NoClient: eventCopy.NoClient,
					NoDivision: eventCopy.NoDivision,
					Priorite: eventCopy.Priorite,
					PrcComplete: eventCopy.PrcComplete,
					StatutId: eventCopy.StatutId,
					CC_length: (typeof(eventCopy.CC_length) != "undefined") ? eventCopy.CC_length : 0,
					ListeCC: eventCopy.ListeCC,
					DateNotificationCC: eventCopy.DateNotificationCC,
					DroitCC: eventCopy.DroitCC,
					FrequenceCC: eventCopy.FrequenceCC,
					UniteFrequenceCC: eventCopy.UniteFrequenceCC,
					NotificationCC: eventCopy.NotificationCC,
					DateRappelGeneral: eventCopy.DateRappelGeneral,
					FrequenceGenerale: eventCopy.FrequenceGenerale,
					FrequenceUniteGeneral: eventCopy.FrequenceUniteGeneral,
					RappelA: eventCopy.RappelA,
					DateRappelA: eventCopy.DateRappelA,
					FrequenceRappelA: eventCopy.FrequenceRappelA,
					UniteRappelA: eventCopy.UniteRappelA,
					DroitsA: eventCopy.DroitsA,
					rec_pattern: eventCopy.rec_pattern,
					event_length: eventCopy.event_length,
					rec_id: event_id
				});
					
				new_id = scheduler.uid();
			}
		}
		
		return true;
			
	});

I made sure to place it before the init function and it works… sort of. The events are indeed all added to the database and appear in the scheduler, but then the scheduler stalls. I can’t add, update or delete any events unless I refresh the page.

Curious, I executed my code in Internet Explorer and got the following error message:

Also, I got rid of:

Because it was also causing my scheduler to crash with a similar message to what I gave you above. Any idea what could have gone wrong? I’m rather perplexed by this unexpected error.

Thanks in advance

Osu

id:new_id,

must
id:scheduler.uid()
to generate unique ids for each new event

rec_pattern: eventCopy.rec_pattern,
event_length: eventCopy.event_length,
those two are not critical, but still can cause problems
rec_pattern is unnecessary
event_length has diffrerent meaning for event copies and need to have different values

Thanks for the answer Stanislav. And yeah, the rec_pattern and event_length aren’t really necessary. As for the new_id, I have

new_id = scheduler.uid();

right below the addEvent call so I do have a unique ID for each event generated. However, after much search, I found that the line that caused everything to crash was:

scheduler.deleteEvent(event_id);

I have no idea why exactly it did that, but once I modified my code so that I no longer needed it, everything started to work perfectly.

A thing I noticed after working with the scheduler_debug.js was that, after trying to delete an event after a fresh reload, there were two places which caused errors when trying to access “this.obj.rowsArr”, a field that didn’t always exist (no idea why). So I applied a small fix and things started working perfectly. Here are the functions I updated (look for the ‘added’ comment):

dataProcessor.wrap("sendData",function(rowId){
	if (rowId){
		this._log("&nbsp;Initiating data sending for <b>"+rowId+"</b>");
		if (this.obj.mytype=="tree"){
        	if (!this.obj._idpull[rowId])
	    		this._log("&nbsp;Error! item with such ID not exists <b>"+rowId+"</b>");
		} else {
			if (typeof(this.obj.rowsAr) != "undefined") //added
				if (!this.obj.rowsAr[rowId])
	        		this._log("&nbsp;Error! row with such ID not exists <b>"+rowId+"</b>");
        }
	}
},function(){
	
});

........

dataProcessor.wrap("afterUpdateCallback",function(sid,tid,action){
	if (this.obj.mytype=="tree"){
		if (!this.obj._idpull[sid]) this._log("Incorrect SID, item with such ID not exists in grid");
	} else {
		if(typeof(this.obj.rowsAr) != "undefined") //added
			if (!this.obj.rowsAr[sid]) this._log("Incorrect SID, row with such ID not exists in grid");
	}
	this._log("&nbsp;Action: "+action+" SID:"+sid+" TID:"+tid);
},function(){
	
});

Anyway, I doubt this has any real bearings on the scheduler itself since these look like debugging functions, but hey, who knows what could be useful to you guys :wink:. Anyway, thanks for the help again and keep up the good work :slight_smile:.

Osu

Thanks for provided info, we will update this part in main codebase, to prevent such problems in future.

No problem, I’m happy I could be of help to you guys :slight_smile:.

Hello,

I’m at a loss with the problem I am having with my timeline view - events that have an event_pid are not visible in that view. Below I have included the .js files I include. The following have been modified (all based on advice through the forum, or files you have sent me):
recurring_20110113.js
expand.js
tooltip.js
debug.js

Again, here is a sample event being loaded:

scheduler.addEvent("09-02-2011 21:00","09-02-2011 22:00","Change entire series",174, {person_id: 8714989, name: "ELIKA MOLAYI", instrument_id:"2", instrument_name:"Zeiss Confocal", discount:"0", is_assisted:"N", status:"maintenance", cost:0, event_pid:172}

Thank you.
Scheduler js files.zip (50.9 KB)

I also noticed that those events are also not visible in the minical in the navbar (the days that those events occur are not yellow as with other days with events).

Thanks.

It is very similar to the case when something is incorrect with end-dates of events. ( both minical and timeline view, will not render event which has end date-time smaller or equal to the start date-time.

Can you check, which start and end date values event have after adding ( scheduler.getEvent(id).end_date ) ?

I added the following after every addEvent statement and got the expected start/end time in the format below:
alert(scheduler.getEvent(<{$event.0}>).start_date + ’ ’ + scheduler.getEvent(<{$event.0}>).end_date + ’ ’ + <{$event.0}>);
Tue Feb 01 2011 13:00:00 GMT-0500 (EST) Tue Feb 01 2011 17:00:00 GMT-0500 (EST) 244

I have checked that dates are being entered correctly into my database and prior to saving an event I check that it is between 30 min and 24hrs, so end date has to be greater than start date…

Thanks.

You can try to use the attached js file instead of the original one ( it is taken from dev. branch, so I’m not sure will it work without side conflicts or not ) - it has some fixes related to the way how list of rendered event builds in the timeline view.
dhtmlxscheduler_timeline.zip (5.54 KB)

Thanks, Stanislav. Recurring events are still missing from the timeline view and the minical. They are visible on day, week, and month view…