Problem Deleting an Event scheduler 3.5

When I delete and event from the scheduler, I receive and error and the event stays on the scheduler with a strikethrough on the event name.

The event [b]is[/b] removed from the mysql table, so after a refresh of the screen, it is removed from view.

The log has this entry;

DELETE FROM events_rec WHERE event_id=‘12’ AND (( companyid=‘1’))

Incorrect field name used: dhx_auto_id

data
event_id => 12
start_date => 2012-07-19 08:00
end_date => 2012-07-19 08:30
text => ted
rec_type =>
event_pid => 0
event_length => 0
color => #3b77bc
section_id => 1
companyid => 1
details =>
location =>
!nativeeditor_status => deleted

exception ‘Exception’ with message ‘Source of data can’t be empty’ in dhtmlx3.5/connector-php/codebase/db_common.php:197
Stack trace:
#0 dhtmlx3.5/connector-php/codebase/base_connector.php(762): DataRequestConfig->set_source(NULL)
#1 dhtmlx3.5/connector-php/codebase/crosslink_connector.php(114): Connector->delete(’’)
#2 [internal function]: CrossOptionsConnector->afterProcessing(Object(DataAction))
#3 dhtmlx3.5/connector-php/codebase/tools.php(106): call_user_func_array(Array, Array)
#4 dhtmlx3.5/connector-php/codebase/dataprocessor.php(174): EventMaster->trigger(‘afterProcessing’, Object(DataAction))
#5 dhtmlx3.5/connector-php/codebase/dataprocessor.php(102): DataProcessor->inner_process(Object(DataAction))
#6 dhtmlx3.5/connector-php/codebase/base_connector.php(475): DataProcessor->process(Object(DataConfig), Object(DataRequestConfig))
#7 dhtmlx3.5/connector-php/codebase/base_connector.php(432): Connector->render()
#8 data/events_rec.php(79): Connector->render_sql(‘select * from e…’, ‘event_id’, ‘start_date,end_…’)
#9 {main}

Edit operation finished
0 => action:error; sid:12; tid:12;

Any insight you can provide would be appreciated

Hello,

Can you please also include your events.php file?

Kind regards,
Ilya

include (’…/dhtmlx3.5/connector-php/codebase/scheduler_connector.php’);
include (’…/dhtmlx3.5/connector-php/codebase/crosslink_connector.php’);
include (’…/dhtmlx3.5/samples/common/config.php’);
session_start(“cal”);
$res = mysql_connect ( $server, $user, $pass );
mysql_select_db ( $db_name );

$user_sql = ‘’;
if (isset ( $_GET [‘userid’] )) {
$user_id = $_GET [‘userid’];
$user_sql = " and section_id in(" . $user_id . “)”;
}
$companyid = $_SESSION [‘companyid’];
$sql = “select * from company where md5(companyid)=’” . $companyid . “’”;
$result = mysql_query ( $sql );
while ( $row = mysql_fetch_assoc ( $result ) ) {
$companyid2 = $row [‘companyid’];
}
if (! isset ( $_SESSION [‘compid’] )) {
session_register ( “compid” );
}
$_SESSION [‘compid’] = $companyid2;

$sql2 = “select * from events_rec where companyid=’” . $companyid2 . “’” . $user_sql;

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" );

}
function doprocessing($action) {
$action->set_value ( “companyid”, $_SESSION [‘compid’] );
}

$cross = new CrossOptionsConnector ( $res );
$cross->dynamic_loading ( true );
$cross->options->render_sql ( “select concat(u.firstname,’ ',u.lastname) as label, u.section_id as value from employment e, user u where e.section_id=u.section_id and e.companyid=” . $_SESSION [‘compid’] . “”, “section_id”, “section_id(value),firstname(label)” );

$colorCross = new CrossOptionsConnector ( $res );
$colorCross->dynamic_loading ( true );
$colorCross->options->render_table ( “colors”, “color”, “color(value),color(label)” );

$scheduler = new schedulerConnector ( $res );
$scheduler->enable_log ( “log.txt”, true );
$scheduler->set_options ( “section_id”, $cross->options );
$scheduler->set_options ( “color”, $colorCross->options );
$scheduler->event->attach ( “beforeProcessing”, “delete_related” );
$scheduler->event->attach ( “beforeProcessing”, “doprocessing” );
$scheduler->event->attach ( “afterProcessing”, “insert_related” );

$scheduler->render_sql ( $sql2, “event_id”, “start_date,end_date,text,rec_type,event_pid,event_length,color,section_id,companyid,details,location” );

Any update on this issue? I attached the code in the previous post as requested.

Hello,

Thank you very much for providing events.php file. Though it’s actually harder to reconstruct same issue locally. Can I ask you for to provide you html and database dumps so we can immediately run your sample?

Also try commenting out before/after processing handlers, issue persists?

Kind regards,
Ilya

exception ‘Exception’ with message ‘Source of data can’t be empty’ in dhtmlx3.5/connector-php/codebase/db_common.php:197

Such kind of error occurs if you are using render_table or render_sql with empty first parameter.
From your code, it seems that first parameter is correctly set, so it may be a log record from some different (old) code

Also, if you are using latest connector ( highly recommended ) you may try to user render_complex_sql instead of render_sql. It will not autogenerate saving command ( you are using custom sql for saving anyway ) but will preserve incoming sql as is, without any alterations, which may resolve issue

I have tried commenting out the before/after processing, but still have the same issue.

However, when I commented out the CrossOptionsConnector functions, the problem went away.

Any ideas what might be causing the problem with the CrossOptionsConnector? I can send you the html and a data dump if you still need it.

problem resolved.

the problem was that I had removed/commented out the line

$cross->link->render_table("event_user","event_id", "section_id,event_id");

apparently this link is required?

thanks for your help.

Yep, in case of cross table connector you need to define all components ( the table with linked data, and table which stores references )