Call to protected method MySQLDBDataWrapper::get_new_id()

Hi,

I attached a custom data processing on “before update” event, which includes a custom insert query. All is working.

Now following this
docs.dhtmlx.com/doku.php?id=dhtm … om_queries

i inserted

$scheduler->sql->query("INSERT INTO pazienti (cognome,telefono) VALUES (’$nuovo_paz’,’$tel_paz’); ");
$data->success();
$new_id = $scheduler->sql->get_new_id();

The insert query gets executed correctly but
On the line with the $new_id assignment i obtain an alert saying:
Fatal error: Call to protected method MySQLDBDataWrapper::get_new_id() from context ‘’ in …

Don’t know how to handles this, or how alternatively obtain the mysql_insert_id()…or if it could be related to php 5.3. Should a “older” php work? Or is there a way to override this?

Thanks
Gino

i guess I found the answer

docs.dhtmlx.com/doku.php?id=dhtm … ion_object

So I solved by this dirty thing:

$id_new=mysql_insert_id($connessione);

I’m going to use this diry solution at the moment. thanks for reading.

As, we’re talking, is it possibile to show certain fields in the lightbox based on fact if it is going to be a NEW insert, or an update?
If i solve this, i hope i’m finished.

Thank you again
gino

As for original question, it looks as incorrect design, we will fix it in oncoming update ( get_new_id will have public access )

to show certain fields in the lightbox

You can add custom handler to onBeforeLightbox, check is scheduler._new_event flag set or not, based on it alter scheduler.config.lightbox configuration ( add or remove some sections ) , and call scheduler.resetLightbox()

Hi,

yes, got, but how do I alter the lightbox inside the OnBeforeLightbox event?

I tried to move the
scheduler.config.lightbox.sections=[]

but it doesn’t show…

Can you give me some further detail/example on how to do it?

Thank you so much
Gino

lets assume that you have two configs on the page, like

var sectionsA = [ {name:"description", height:200, map_to:"text", type:"textarea" , focus:true}, {name:"time", height:72, type:"time", map_to:"auto"} ]; var sectionsB = [ {name:"time", height:72, type:"time", map_to:"auto"} ]; scheduler.config.lightbox.sections = sectionsA;

now in onBeforeLightBox you can use something like

scheduler.attachEvent("onBeforeLightbox", function(){ scheduler.resetLightbox(); if (some) scheduler.config.lightbox.sections = sectionsA; else scheduler.config.lightbox.sections = sectionsB; return true; });

Thank you, it works! Though I did in a dirtier way.
But now a huge problem…
Lightbox combos are fille base on a query on top of the page.

One of them may vary, based on what the user does on the lightbox, because he can insert directly a new custome (here called “paziente”), so i thought to redo the query on onbeforelightbox to get the list refreshed with the new value inserted, but no luck… where am I wrong?

Sorry if i paste the whole section, but i’d like to be understood correctly

[code] scheduler.attachEvent(“onBeforeLightbox”, function(){
//alert(‘Ciao’);
//scheduler._lightbox = null;
//window.setTimeout(“window.location.reload(true);”, 1000);
//scheduler.resetLightbox();

            if (scheduler._new_event) {

// ################################### FORM NUOVO PAZIENTE
<?
// Pazienti
$qs=“SELECT id,cognome,nome FROM pazienti ORDER BY cognome”;
$rs=mysql_query($qs) or die(mysql_error());
$righe_p= <<<RP
{key:0, label:“Nuovo Paziente (box sottostante)”},
RP;
while ($ds=mysql_fetch_assoc($rs)) {

                    $id=$ds['id'];
                    $nominativo=$ds['cognome']." ".substr($ds['nome'],0,1).".";


                    $righe_p.= <<<RG
                    {key:$id, label:"$nominativo"},

RG;

                }
                $righe_p=substr($righe_p,0,-1);

                ?>
                //alert ('NUOVO');
                  scheduler.templates.lightbox_header = function(start, end, event){
		return "Nuova Terapia";
	}


                 scheduler.config.lightbox.sections=[
                //{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
                //{name:"custom", height:23, type:"select", options:"paziente_id", map_to:"id_paziente"},

                {name:"paziente",  height:25, type:"select", map_to:"id_paz", options:[
                <?=$righe_p?>
                ]},
                /*
                {name:"paziente", height:21, map_to:"id_paz", type:"select",
                                options:scheduler.serverList("id_paz")},
                */
                {name:"cognome", height:15, type:"textarea", map_to:"cognome"},
                {name:"telefono", height:15, type:"textarea", map_to:"telefono"},
                {name:"terapia", height:25, type:"select", map_to:"id_prest", options:[
                <?=$righe_t?>
                ]},
                {name:"medico", height:25, type:"select", map_to:"id_medico", options:[
                <?=$righe_m?>
                ]},
                //{name:"stanza", height:25, type:"select", map_to:"id_stanza", options:[
                //<?=$righe?>
                //]},
                {name:"Note", height:30, type:"textarea", map_to:"Note"},
                {name:"time", height:20, type:"time", map_to:"auto"}
                ]

            } else {

// ################################### FORM MOD PAZIENTE

                                <?
                                    // Pazienti
                $qs="SELECT id,cognome,nome FROM pazienti ORDER BY cognome";
                $rs=mysql_query($qs) or die(mysql_error());
                $righe_p= "";
                
                while ($ds=mysql_fetch_assoc($rs)) {


                    $id=$ds['id'];
                    $nominativo=$ds['cognome']." ".substr($ds['nome'],0,1).".";


                    $righe_p.= <<<RG
                    {key:$id, label:"$nominativo"},

RG;

                }
                $righe_p=substr($righe_p,0,-1);

                ?>


                //alert ('MOD');
                  scheduler.templates.lightbox_header = function(start, end, event){
		return "Modifica Terapia";
	}

                       scheduler.config.lightbox.sections=[
                //{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
                //{name:"custom", height:23, type:"select", options:"paziente_id", map_to:"id_paziente"},

                {name:"paziente",  height:25, type:"select", map_to:"id_paz", options:[
             
                <?=$righe_p?>
                ]},
                /*
                {name:"paziente", height:21, map_to:"id_paz", type:"select",
                                options:scheduler.serverList("id_paz")},

                {name:"cognome", height:15, type:"textarea", map_to:"cognome"},
                {name:"telefono", height:15, type:"textarea", map_to:"telefono"},
                */
                {name:"terapia", height:25, type:"select", map_to:"id_prest", options:[
                <?=$righe_t?>
                ]},
                {name:"medico", height:25, type:"select", map_to:"id_medico", options:[
                <?=$righe_m?>
                ]},
                //{name:"stanza", height:25, type:"select", map_to:"id_stanza", options:[
                //<?=$righe?>
                //]},
                {name:"Note", height:30, type:"textarea", map_to:"Note"},
                {name:"time", height:20, type:"time", map_to:"auto"}
                ]

            }

              


            scheduler.resetLightbox();
            return true;



            });

[/code]

What I need is that the paziente fill when I edit show the right customer on the combo, but it doesn’t because it seems the query is not redone…
Could you please give a precious hint of yours?

I also tried with the option connector but i didn’t get it to work, maybe because I fetch data via php file…

Sorry maybe I was confusing…

What i need is a way to refresh ONE of the combos option every time i open the lightbox, as it might have new values (previously insterted).

If new option inserting occurs on the same page you can just use something like next to add the new option to

scheduler.serverList("id_paz").push({ key:"some", label:"other" }); scheduler.callEvent("onOptionsLoad",[]); scheduler.resetLighbox(); //to repaint form the next time

scheduler has not build in solution for options reloading, so you will be need to use some kind of custom ajax call anyway.

Thak you so much for the hint, I’m going to try it asap.

Meanwhile I went with this (once again) dirty thing, I found on the forum:

[code] scheduler.attachEvent(“onAfterLightbox”, function(){

              window.setTimeout("window.location.reload(true);", 2000);
            });

[/code]

It seems to work, anyway it is a bit annoying for the customer, see the page reload.

So, before I try you solution and see if it solves the problem and the related issues, I’d like to ask if there is a way to da what I did above, but in a smoother way, and above all, keeping the actual view AND actual date?
How would you accomplish this?
Reload the page in the same view and date as the page was before reloading??

Thank you for your patience

scheduler.clearAll(); scheduler.load(url);

will delete all events and reload data from server side, including the options collections.
current view and date will be preserved.

To get even better result you can use just load, without clearAll - in such case loading will update existing events, so user will not see any flickering at all ( it has some disadavnatesd in common case, but must be fine for your scenario )

Hi and thank so much for your reply.

I tried both methods you suggested together and just the load one, but with no luck.
Everything gets refreshed, except the combo.
It depends probably by the weird way I get data (as said I didn’t get the option connector to work).

I tried on the AfterProcessing event and on OnAfterLightbox event.

If there is no other way to reload o reinit the page keeping the view and day, i was thinking of combining a previous solution of your with the present one, that is to say:

you suggested

scheduler.serverList("id_paz").push({ key:"some", label:"other" }); scheduler.callEvent("onOptionsLoad",[]); scheduler.resetLighbox(); //to repaint form the next time

But as said I don’t have a serverlist. So the question would be: is there a way to “simply” add the option “manually”, let us say on the afterprocessign event where I’ve got the event id? If yes, how exactly? And will it stay selected then, as I suppose

After that on the OnAfterLightbox event, I would be keeping this to ensure proper refresh of other data?

What do you say? Might it work as expected?

Alternatively, what would you suggest?

Stan, I really appreciate your help, than you so much.

I was forgetting: besides manually adding the option to the combo, I should also “blank” a couple of field to keep things clean. How do I accomplish this?

Thanks again.

Maybe the catch or at least what you need to know is the i’m using dataprocessor to save data, while loading via php file the outputs xml, due to a too complex query to extract data.

So maybe I don’t optionconnector at all…

Think the manual adding the option stay my only solution…please hel

Probably I have forgot to mention one more line

scheduler.resetLightbox(); scheduler.clearAll(); scheduler.load(url);

Beware that options will not be updated in already opened lightbox, so it has sense to call the above code only when lightbox is closed.

php file the outputs xml, due to a too complex query to extract data.
Are you loading options from the same file or frome some other source?
There is no any “connector” magic here, reloading xml with options list must be enough

Maybe this is the point, thanks for your patience I know I start to seem dumb…

I get the options “manually”, that is to say this way:
I write them manually by querying db on every OnBeforeLightbox

scheduler.attachEvent("onBeforeLightbox", function(){
		<?php
                    // Pazienti
                    $qs="SELECT id,cognome,nome FROM pazienti ORDER BY cognome";
                    $rs=mysql_query($qs) or die(mysql_error());
                    $righe_p= <<<RP
                    {key:0, label:"Nuovo Paziente (box sottostante)"},
RP;
                    while ($ds=mysql_fetch_assoc($rs)) {


                        $id=$ds['id'];
                        $nominativo=$ds['cognome']." ".substr($ds['nome'],0,1).".";


                        $righe_p.= <<<RG
                        {key:$id, label:"$nominativo"},
RG;


                    }
                    $righe_p=substr($righe_p,0,-1);

                    ?>
                    
		}


                     scheduler.config.lightbox.sections=[
               
                    
                    {name:"paziente",  height:25, type:"select", map_to:"id_paz", options:[
                    <?=$righe_p?>
                    ]},

etc...
}

and I fear it is a bad way, though once refreshed the combo options are correctly selected and passing correct values.

Hope you’re about to say there is a more efficient way I can use…to bee in sync, you talked about xml… I’m using it for reading the data of the calendar, but not of its options…is it possible?

To be complete, this doesn’t work either, though I have no errors:

{name:"paziente", height:21, map_to:"id_paz", type:"select",
                                    options:scheduler.serverList("id_paz")},

together with


$scheduler = new schedulerConnector($connessione);
        
        $list = new OptionsConnector($connessione);
	$list->render_table("pazienti","id","id(value),cognome(label)");

        $scheduler->set_options("id_paz", $list);
       
	$scheduler->enable_log("log.txt",true);

this last code is in another file called like this in the main file

 scheduler.load("events.php");
var dp = new dataProcessor("cx.php");

.
.
.
.

dp.init(scheduler);

Hope this clarify a bit and helps understanding where I am wrong.
I feel really confused, and I know I’m not going the right way…
Really thank you for patience in trying to understand.

OK, don’t want to make you waste time.

I’d just like to know THE way load options for the combo when I already load the calendar data via XML… another XML? a syntax I missed?
I didn’t get the point and now I understand it is why I can’t have the option list properly reloaded.

my output is this

 scheduler.load("events.php");

<event id="1763" start_date="2011-01-14 11:20:00" end_date="2011-01-14 12:05:00" text="Aghi personali" details="qaz" id_stanza="0" medico="Generico 1" paziente="qaz" colore="" nome_stanza="" id_medico="6" id_paz="1289" id_prest="37" id_colonna="3" tipo_medico="I" colore_medico="" font_medico="" Note="" event_type="fake"/>

Check the attached sample
1295256699.zip (45 KB)

WOW!!
This time it really works, and things have changed instantly!
What I was mainly missing is the syntax to “embed” options in main xml/php file.

Thought I set it up, I don’t even need to call the function to reload ONLY the combos in a separate xml file…

What can I say? This has opened a better way to use this wonderful tool.
I’mg really grateful for time and patience you spent to understand my issue.
Thank you so much.

Now - back to reality - to get finished two last “details”:

  • In my language, italian, i often have to save text which contains " ’ ", single quotes i mean.
    In the xml, before using CDATA as in your example, I bypassed the problem by using double quotes to define value.
    Escaping it, is creating me some other problem after, so I’d like to know if I can replace the single quotes used in the xmlhttp request by automatic updates with double quotes?

This is how I now see the request:

<?xml version='1.0' ?><data><action type='updated' sid='1829' tid='1829' paziente='ddddddddddddddddddddddddddddddd ' id_paz='1318' terapia='Aghi personali' medico='Generico 1' nome_stanza='' colore='' tipo_medico='I' colore_medico='' font_medico='' id_colonna='3' ></action></data>

I’d like to specifiy values within " and not ’ eg, terapia=“Aghi personali”.
How can i do that?

  • Really last: I did this:
var format_m = scheduler.date.date_to_str("%d");
                scheduler.templates.month_day  = function(date){
                    return "<span onclick='go_day()'>Vai</span> "+format_m(date);
                };

that calls temporarily this

function go_day(){
            alert('CWorking on this!');

        }

My goal is to send the user on THE specified Day in a particular view?
Is it possible? Or rather what I have got to call? And which parameters.

I hope I’m really finished
Really many thanks again.

For the second question:
I think I should use scheduler.setCurrentView

but I don’t know how to get and format the date for the day user has clicked on and want to go to (in the specified view)

So

scheduler.setCurrentView(scheduler._date,"colonna");

I goes to the view, but on the current day. I thought ._date would have assumed the value of the day clicked…

What do I miss?