How to save data form lightbox in manual mode???

Hello to you all!!! :slight_smile:
I am very new to DHTMLX and to dhtmlxScheduler!!!

I am coding a test program where I have some user/password on a ‘users’ table and a ‘scheduldata’ table with fields like ‘IEID,IUID,DSTARTDATE,DENDDATE,TTEXT,TDETAILS’. (where IUID is the id of a user).

I want that, when a user is logged in,he can see his data in the scheduler and can add/modify/delete his data.

I have put off the dataProcessor object but I cannot understand HOW to save my new data (insert) in my scheduldata table WITH also the field IUID of the user connected?!?!? :unamused:

Here I put my html code:

[code]

[/code]

and php code :

[code]<?php
include (’…/…/…/codebase/connector/scheduler_connector.php’);
include (’…/…/common/config_scheduler_test.php’);

$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);

$scheduler = new schedulerConnector($res);
//$scheduler->enable_log("log.txt",true);

$iuid = $_GET['iuid'];

$query = "SELECT * FROM scheduldata WHERE IUID = '$iuid'";
$scheduler->render_sql($query,"IEID","DSTARTDATE,DENDDATE,TTEXT,TDETAILS");

/*
//including additional field to request
function my_update($data){
      $data->add_field("IUID",1); //will be included in insert
} 

$res->event->attach("beforeInsert","my_update");
*/

/*
$qinsert = "INSERT INTO scheduldata (DSTARTDATE,DENDDATE,TTEXT,TDETAILS,IUID) VALUES ('{DSTARTDATE}','{DENDDATE}','{TTEXT}','{TDETAILS}','$iuid')";

//$qinsert = "INSERT INTO scheduldata (IUID) VALUES ('$iuid')";

$scheduler->sql->attach("Insert",$qinsert);
$scheduler->render_sql($qinsert,"IEID","DSTARTDATE,DENDDATE,TTEXT,TDETAILS","IUID");
*/

?>[/code]

Could someone help me ,please ?

Thanks a lot!!! :smiley:

1 Like

Commented code in your file already contains the correct strings

[code] include (’…/…/…/codebase/connector/scheduler_connector.php’);
include (’…/…/common/config_scheduler_test.php’);

$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);

$scheduler = new schedulerConnector($res);

$iuid = $_GET[‘iuid’];
function my_update($data){
global $iuid;
$data->add_field(“IUID”,$iuid); //will be included in insert
}
$scheduler->event->attach(“beforeInsert”,“my_update”);

$query = “SELECT * FROM scheduldata WHERE IUID = ‘$iuid’”;
$scheduler->render_sql($query,“IEID”,“DSTARTDATE,DENDDATE,TTEXT,TDETAILS”);

[/code]

Try the above code, if it still doesn’t work - enable log and post its content here.

1 Like

Hi Stanislav!!!

Your code is OK!!!
It now save with also the field IUID.Great! :smiley:

But I see this problem…
When I click on ‘save’ on the lightbox,scheduler write the new event on frontend,but don’t save it in the DB!!!
only when I enter a second event and click save,I see in the DB the first new event…?!?

Why??? How to to this correctly?

And also,how to enable the Log in the scheduler???

Thanks and sorry but I am new…

Grubby69

Stanislav,I correct my code in the javascript and I have use the correct event:

scheduler.attachEvent("onEventAdded", function(event_id,event_object){ dp.sendData(); });

in this way the update of the DB is in time live and all is OK!!! :sunglasses:

Great,I say you Thank you very much for your help!!! :smiley:

regards

It is quite strange behavior, looks like first insert causes error, and after second data sending it is processed correctly.

In your code, before render_sql add

$scheduler->enable_log(“some.txt”);

as result all db actions ( exact sql queries and error info ) will be stored in some.txt ( in same folder where php file resides )

Yep, onEventSave is a moment when save button is clicked, but before real data saving. onEventAdded, onEventChanged - a events after real event adding|changing.

Also, if you are using default dataprocessor settings - scheduler will send data to server side automatically, without need for manual sendData calls.

You are right!!!
i have deleted the code :

/* dp.setUpdateMode("off"); scheduler.attachEvent("onEventAdded", function(event_id,event_object){ dp.sendData(); });*/

and it automatically add new event with the correct IUID field added.

I have only problem adding the event_log…
it doesn’t create a file some.txt,and so I create by myself but it doesn’t fill with any text…?!?

i do this:

$query = "SELECT * FROM scheduldata WHERE IUID = '$iuid'"; $scheduler->enable_log("some.txt"); //as result all db actions ( exact sql queries and error info ) will be stored in some.txt ( in same folder where php file resides ) $scheduler->render_sql($query,"IEID","DSTARTDATE,DENDDATE,TTEXT,TDETAILS");

Check that php script has write access to that dir