Bug in recurring.js

There is a bug in the dhtmlxscheduler_recurring.js
(based at source version) in line 546
if(ev.rec_type){

should be
if(ev && ev.rec_type){

otherwise deleted event is not redrawn until switch views (checked in FF and Chrome) throws error ev is not defined

Next thing: is it correct that recurring event with this settings:
Time period: 2013-08-19 10:30 - 2013-08-19 12:20
Repeat event: daily
Every 1 day
Finish after 5 occurrences

Sends data:
rec_pattern: day_1___
rec_type: day_1___#5
start date: 2013-08-19 10:30
end date: 2013-08-24 10:30
why end date is not set to 2013-08-23 12:20 that seems to be correct according to where the events ends - Is it bug or a feature used for sth?

Taking into consideration server side collision checking it might be a little problem as the schedulerHelper returns event from 2013-08-24 that doesn’t really exists.

Regards,
Grzesiek

Hello,

  1. problem is confirmed and fixes and dev version, sorry for the inconvenience
    Check the latest build in the attachment, the bug should be fixed there.

  2. yes, it’s correct. The ‘end_date’ of the series means that occurences can start only until that date, defaultly it is date of occurence that could go after the last one.
    The value ‘2013-08-23 12:20’ would also work, as well as any date between 2013-08-23 10:31 - 2013-08-24 10:30, there is no difference.
    dhtmlxScheduler_130821.zip (192 KB)

Aliaksandr,

Thanks for your replay,

I’ve tested attached code and use file for recurring ext from there, but it is the same as in the older version and bug is not fixed in it - (or should I use all files from this zip and bug is fixed in main js?) As for now I’m using the code I’ve sent in previous message.

Thanks,
Grzesiek

Aliaksandr,

One more thing about schedulerHelper - it returns event from 2013-08-24 as it is part of the recurring event range - for mentioned event data as in db end date is 2013-08-24 10:30 and it seems that number of occurrences are not used anywhere in the code - any idea how to deal with it?

Thanks
Grzesiek

The bug is fixed in dhtmlxscheduler.js, try using it.

We’ll check the issue with schedulerHelper, please stay in touch

Aliaksandr,

After switching to newest dhtmlxscheduler.js error doesn’t appear - thanks for quick fix. I just thought that if error is thrown by recurring.js it would be fixed by changes made to this file.

As far as schedulerHelper is concerned - nice to hear(I’ve posted more detailed info here: viewtopic.php?f=6&t=32473). Next thing come out - when deleting or modifying occurrence js timestamp is different from the one generated by php for the same date (it prevents from finding those occurances in sH) - do you thing that setting scheduler.config.occurrence_timestamp_in_utc = true; would fix that?
Does this problem can be solved in the same manner at the mobile version?

Thanks,
Grzesiek

Hi,
could you provide test database dump for schedulerHelper.php problem ?

Redano,

Thanks for your time.

Here is the sql for rows that causes problem:

CREATE TABLE IF NOT EXISTS `events` (
  `event_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `start_date` datetime NOT NULL,
  `end_date` datetime NOT NULL,
  `text` varchar(255) NOT NULL,
  `rec_type` varchar(64) NOT NULL,
  `event_pid` int(11) NOT NULL,
  `event_length` int(11) unsigned NOT NULL,
  `user_id` int(11) unsigned NOT NULL,
  `res_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`event_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=142 ;


INSERT INTO `events` (`event_id`, `start_date`, `end_date`, `text`, `rec_type`, `event_pid`, `event_length`, `user_id`, `res_id`) VALUES
(70, '2013-08-19 06:00:00', '2013-08-24 06:00:00', 'New event', 'day_1___#5', 0, 6000, 15, 2),
(124, '2013-08-19 10:30:00', '2013-08-24 10:30:00', 'aaaaaaaaaaaaaaa41', 'day_1___#5', 0, 6600, 15, 2),
(138, '2013-08-21 10:30:00', '2013-08-21 12:20:00', 'aaaaaaaaaaaaaaa41', 'none', 124, 1377073800, 15, 2),
(141, '2013-08-24 05:30:00', '2013-08-24 08:05:00', 'New event', '', 0, 0, 4, 1);

In my code I blocked no end date option, so the recurring event has its end date always set by number of occurrences or end date. I assume that problem can occur as the js end date for recurring event is not always the end date of last event in series. In this case the real end date should be 2013-08-23 12:20:00.

new regular event that is used for get_dates() checking is:
start date: 2013-08-24 10:10
end date: 2013-08-24 12:45

As you have some knowledge about SH I wanted to ask you about one more thing - namely generating all recurring events from recurring event data during creation - I have this custom function added to help finding collision when adding new recurring event:

[code] function get_dates_from_pattern($event) {
$this->date_start = $event[‘start_date’];
$this->date_end = $event[‘end_date’];
$date_start = date_parse($event[‘start_date’]);
$this->date_start_ts = mktime($date_start[‘hour’], $date_start[‘minute’], $date_start[‘second’], $date_start[‘month’], $date_start[‘day’], $date_start[‘year’]);
$date_end = date_parse($event[‘end_date’]);
$this->date_end_ts = mktime($date_end[‘hour’], $date_end[‘minute’], $date_end[‘second’], $date_end[‘month’], $date_end[‘day’], $date_end[‘year’]);

	$final = array();
	$updates = Array();
	
	$event_cur = new SchedulerDate($event, $updates, $this->date_start);
	$event_cur->transpositor($this->date_start_ts);
	$final_temp = $event_cur->date_generator($this->date_start_ts, $this->date_end_ts);
	foreach ($final_temp as $v) {
		$final[] = $v;
	}
	
	return $final;
}[/code]

The $event var is array from $action->get_data() in my beforeProcessing I check array of new events against all events from new event timerange in a loop also with checking some additional fields as user_id and res_id to prevent the same user from creating event at the same time, and/or the same resource.

Regards,
Grzesiek

Hi,
please, try to update schedulerHelper.php from attachment.
SchedulerHelper.zip (2.47 KB)

Radyno,

Thanks for your time - as far as I checked it works like a charm.

btw: in attached code, function get_event($id) what does it do?

One thing I want to clarify - from what I see do not need to check regular events separately as get_dates() would take all events from specified time range including regular ones - am I right?

Second question in get_correct_date() if regular event is passed it overwrites the the orginal end_date, becouse the $this->event_lenght is empty maybe there should be:

if($this->event_length) $ev['end_date'] = date("Y-m-d H:i:s", $cur_date + $this->event_length);
so the original regular event end date wasn’t changed (obviously currently it is the same as the start_date) - when adding regular event it is not a problem.

But in case of checking collisions when adding recurring event, first we need to generate array of all occurrences - I used for it get_dates_from_pattern() then in loop I’m checking if event overlaps with (StartA <= EndB) and (EndA >= StartB) if yes I’m checking the user_id and res_id conditions.

If you have any clues how to deal with it in a better way please let me know.

Thanks,
Grzesiek