Value of a custom field from table events

Hello my problem is that I want to get the id of Invoice (IdFattura) from the table events when I click in a custom button in the scheduler.

I tried with:

scheduler.attachEvent(“onLightboxButton”, function(event_id, button_id, node, event){
location.href=“dettaglio_prest.php?IdFattura=”+event.x_fatture_id;
});

where IdFattura (IdInvoice) has to be get from custom field x_fatture_id of events table

But it doesn’t work :neutral_face:

Hello,

So do you load x_fatture_id field when all events are fetched?
If you do then event.x_fatture_id would store value.

Best regards,
Ilya

It doesnt work, in dettaglio_prest.php file I have:

$IdFattura = @$_REQUEST['IdFattura'];
....

echo $IdFattura;  //(Undefined)

$result=mysql_query("SELECT IdFattura, NumFattura, IdPaziente, DataFattura, Prestazione1, Prestazione2, Prestazione3, Prestazione4, Quant_pre1, Quant_pre2, Quant_pre3, Quant_pre4
FROM x_fatture WHERE IdFattura=$IdFattura");

$row_ed = mysql_fetch_array($result);

The error is:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\calendario\dettaglio_prest.php on line 109

and my events.php is:

<?php
	include ('../dhtmlxScheduler/codebase/connector/scheduler_connector.php');
	include ('../dhtmlxScheduler/common/config.php');
		
	$res=mysql_connect($server, $user, $pass);
	mysql_select_db($db_name);

	$list = new OptionsConnector($res);
	$list->render_table("x_pazienti","IdPaziente","IdPaziente(value),Paziente(label)");		//x_paz
	
	$scheduler = new schedulerConnector($res);
	$scheduler->enable_log("log.txt",true);
	
	$scheduler->set_options("x_pazienti", $list);
	$scheduler->render_table("events","event_id","start_date,end_date, event_name, x_pazienti_id, x_fatture_id");

?>

Help me please !!

Are you pressing button for lightbox, which was opened for already existing event or for the new one.

The code looks correct, but if this is a new event it will not have x_fatture_id value, and undefined will be sent to the server side.

The event already exists, the table “event” has a field named “x_fatture_id” and when I press the button Dettaglio in Detail form of event I want to show another detailed form (dettaglio_prest.php) with the right Invoice data.




start.php

[code]

html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
 
 
[/code]

dettaglio_prest.php

[code]

Dettaglio prestazione <?php include("langsettings.php"); include("php/funzioni_mysql.php"); include("lang/it.php"); include ("dhtmlxScheduler\common\config.php"); // Configurazione accesso database include("js/funzioni.js"); $IdFattura = @$_REQUEST['IdFattura']; $IdPaziente = @$_REQUEST['IdPaziente']; $DataFattura = @$_REQUEST['DataFattura']; $Paziente = @$_REQUEST['Paziente']; // echo $IdFattura; if (@$_REQUEST['action']=="Salva") { $IdFattura = $_POST["IdFattura"]; $NumFattura = $_POST["NumFattura"]; $prestazione1 = $_POST["prestazione1"]; $prestazione2 = $_POST["prestazione2"]; $prestazione3 = $_POST["prestazione3"]; $prestazione4 = $_POST["prestazione4"]; $quant_pre1 = $_POST["quant_pre1"]; $quant_pre2 = $_POST["quant_pre2"]; $quant_pre3 = $_POST["quant_pre3"]; $quant_pre4 = $_POST["quant_pre4"]; $DataFattura = addslashes($_POST['DataFattura']); $sql = "UPDATE x_fatture SET DataFattura='$DataFattura', Prestazione1='$prestazione1', Prestazione2='$prestazione2', Prestazione3='$prestazione3', Prestazione4='$prestazione4', Quant_pre1='$quant_pre1', Quant_pre2='$quant_pre2', Quant_pre3='$quant_pre3', Quant_pre4='$quant_pre4', NumFattura='$NumFattura' WHERE IdFattura = $IdFattura"; //$msg = "Modifica effettuata"; //confirm($msg); if(mysql_query($sql) or die (mysql_error())){ // echo "

Modifica effettuata. Vai Indietro

"; // echo "<\div>"; // header("Location: " . $_SERVER['HTTP_REFERRER']); } ?>
<script language="JavaScript" type="text/javascript">
<!--

	location.replace("fatture.php");

//	location.replace("<?$_SERVER['HTTP_REFERER'];?>");
//	location.replace("http://www.senzaweb.it");
//	Response.Redirect("java-script:history.go(-1)");
//	Response.Redirect(Request.UrlReferrer.AbsolutePath );
//-->
</script>
<? // exit; } else if (@$_REQUEST['action']=="Stampa") { // $datiForm = CaricaDatiForm(); $result=mysql_query("SELECT IdFattura, NumFattura, IdPaziente, DataFattura, Prestazione1, Prestazione2, Prestazione3, Prestazione4, Quant_pre1, Quant_pre2, Quant_pre3, Quant_pre4 FROM x_fatture WHERE IdFattura=$IdFattura"); $row_ed = mysql_fetch_array($result); $IdFattura = mysql_real_escape_string($row_ed["IdFattura"]); $NumFattura = mysql_real_escape_string($row_ed["NumFattura"]); $DataFattura = mysql_real_escape_string($row_ed["DataFattura"]); $prestazione1 = mysql_real_escape_string($row_ed["Prestazione1"]); $prestazione2 = mysql_real_escape_string($row_ed["Prestazione2"]); $prestazione3 = mysql_real_escape_string($row_ed["Prestazione3"]); $prestazione4 = mysql_real_escape_string($row_ed["Prestazione4"]); $quant_pre1 = $row_ed["Quant_pre1"]; $quant_pre2 = $row_ed["Quant_pre2"]; $quant_pre3 = $row_ed["Quant_pre3"]; $quant_pre4 = $row_ed["Quant_pre4"]; // echo $IdFattura; ?>
<script language="JavaScript" type="text/javascript">
	<!--  
	location.href="stampa.php?IdFattura=<?=$IdFattura;?>";
	// prelevato su http://www.web-link.it -->
</script>
<? } else { echo $IdFattura; $result=mysql_query("SELECT IdFattura, NumFattura, IdPaziente, DataFattura, Prestazione1, Prestazione2, Prestazione3, Prestazione4, Quant_pre1, Quant_pre2, Quant_pre3, Quant_pre4 FROM x_fatture WHERE IdFattura=$IdFattura"); $row_ed = mysql_fetch_array($result); $IdFattura = mysql_real_escape_string($row_ed["IdFattura"]); $NumFattura = mysql_real_escape_string($row_ed["NumFattura"]); $DataFattura = mysql_real_escape_string($row_ed["DataFattura"]); $prestazione1 = mysql_real_escape_string($row_ed["Prestazione1"]); $prestazione2 = mysql_real_escape_string($row_ed["Prestazione2"]); $prestazione3 = mysql_real_escape_string($row_ed["Prestazione3"]); $prestazione4 = mysql_real_escape_string($row_ed["Prestazione4"]); $quant_pre1 = $row_ed["Quant_pre1"]; $quant_pre2 = $row_ed["Quant_pre2"]; $quant_pre3 = $row_ed["Quant_pre3"]; $quant_pre4 = $row_ed["Quant_pre4"]; // confirm($msg); } ?>
/> /> /> />

<? echo $Paziente?>


Num. Fattura Data Fattura



Prestazione
Quantità
Prestazione
Quantità
Prestazione
Quantità
Prestazione
Quantità
Note

[/code]

and event.php

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

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

$list = new OptionsConnector($res);
$list->render_table("x_pazienti","IdPaziente","IdPaziente(value),Paziente(label)");		//x_paz

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

$scheduler->set_options("x_pazienti", $list);
$scheduler->render_table("events","event_id","start_date,end_date, event_name, x_pazienti_id, x_fatture_id");

?>[/code]

Sorry for the long post !! I hope I was clear enough !

Any idea ? Sorry to bother you …

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

Your code:

scheduler.attachEvent("onLightboxButton", function(event_id, event_object,node){ location.href="dettaglio_prest.php?IdFattura="+event_object.x_fatture_id; //IdFattura = IdInvoice has to be got from field x_fatture_id of events; });
now that’s not event_object.

var ev = scheduler.getEvent(scheduler.getState().lightbox_id); location.href="dettaglio_prest.php?IdFattura="+ev.x_fatture_id;
Best regards,
Ilya

Now it’s clear… It works !!!

Thanks a lot …

:slight_smile: