I am loading from scheduler.load(“php/events_tree_db.php”) but when I try and create recurring events, it fails to write to the event_rec table. It only writes to the events_tt table with the following:
Note that recurring events expect additional handling on the server side, check out Recurring events page in our documentation.
Or simple past additional handlers from the scheduler\samples\03_extensions\php\events_rec.php file.
thanks for the reply but I’m still having trouble. Can you be more specific where these queries need to be? Seems like it will only update one table. It writes to either events_tt or events_rec. But events_rec depends on events_tt for the related event_id.
[code]<?php
include (’…/…/…/codebase/connector/scheduler_connector.php’);
include (’…/…/common/config.php’);
$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);
function delete_related($action){
global $scheduler;
$status = $action->get_status();
$type =$action->get_value("rec_type");
$pid =$action->get_value("event_pid");
//when serie changed or deleted we need to remove all linked events
if (($status == "deleted" || $status == "updated") && $type!=""){
$scheduler->sql->query("DELETE FROM events_rec WHERE event_pid='".$scheduler->sql->escape($action->get_id())."'");
}
if ($status == "deleted" && $pid !=0){
$scheduler->sql->query("UPDATE events_rec SET rec_type='none' WHERE event_id='".$scheduler->sql->escape($action->get_id())."'");
$action->success();
}
}
function insert_related($action){
$status = $action->get_status();
$type =$action->get_value("rec_type");
if ($status == "inserted" && $type=="none")
$action->set_status("deleted");
}
$scheduler = new schedulerConnector($res);
//$scheduler->enable_log("log.txt",true);
$scheduler->event->attach("beforeProcessing","delete_related");
$scheduler->event->attach("afterProcessing","insert_related");
$scheduler->render_table("events_rec","event_id","start_date,end_date,text,rec_type,event_pid,event_length");
?>[/code]
What you need to do is add event handlers in your events.php file:
function delete_related($action){
global $scheduler;
$status = $action->get_status();
$type =$action->get_value("rec_type");
$pid =$action->get_value("event_pid");
//when serie changed or deleted we need to remove all linked events
if (($status == "deleted" || $status == "updated") && $type!=""){
$scheduler->sql->query("DELETE FROM events_rec WHERE event_pid='".$scheduler->sql->escape($action->get_id())."'");
}
if ($status == "deleted" && $pid !=0){
$scheduler->sql->query("UPDATE events_rec SET rec_type='none' WHERE event_id='".$scheduler->sql->escape($action->get_id())."'");
$action->success();
}
}
function insert_related($action){
$status = $action->get_status();
$type =$action->get_value("rec_type");
if ($status == "inserted" && $type=="none")
$action->set_status("deleted");
}
...
$scheduler->event->attach("beforeProcessing","delete_related");
$scheduler->event->attach("afterProcessing","insert_related");
events_tt is the table for events tree which is a timeline view. Since I was having issues writing to both tables, I tried adding on columns to this table for the recurring events. Following the documentation from http://docs.dhtmlx.com/doku.php?id=dhtmlxscheduler:recurring_events Looks like the needed columns are:
ec_type - varchar[64]
event_length - long int
event_pid - int
function delete_related($action){
global $scheduler;
$status = $action->get_status();
$type =$action->get_value("rec_type");
$pid =$action->get_value("event_pid");
//when serie changed or deleted we need to remove all linked events
if (($status == "deleted" || $status == "updated") && $type!=""){
$scheduler->sql->query("DELETE FROM events_rec WHERE event_pid='".$scheduler->sql->escape($action->get_id())."'");
}
if ($status == "deleted" && $pid !=0){
$scheduler->sql->query("UPDATE events_rec SET rec_type='none' WHERE event_id='".$scheduler->sql->escape($action->get_id())."'");
$action->success();
}
}
function insert_related($action){
$status = $action->get_status();
$type =$action->get_value("rec_type");
if ($status == "inserted" && $type=="none")
$action->set_status("deleted");
}
$scheduler = new schedulerConnector($res);
//$scheduler->enable_log("log.txt",true);
//
$scheduler->event->attach("beforeProcessing","delete_related");
$scheduler->event->attach("afterProcessing","insert_related");
$scheduler->render_table("events_tt","event_id","start_date,end_date,event_name,details,section_id,section2_id,rec_type,event_pid,event_length");
[/code]
It now write to the db fine but every time I try and edit a recurring event I get the error “ev is undefined”
I tried following: opened tree timeline sample, added recurring events functionality support and tried to edit events — everything seemed to work ok.
Can you please describe in detail steps to reproduce this issue?
Thank you and best regards,
Ilya
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan