This topic is locked
[SOLVED]

  DAL works on After Record Updated?

3/13/2012 11:07:23 PM
PHPRunner General questions
S
sickacid author

Hi, i'm using DAL in Before record updated and it works correctly but if i copy the same code in After Record Updated i get undefined as message.

C
cgphp 3/14/2012

We need more details to help you with the issue. Please, post the code.

S
sickacid author 3/14/2012

this is the code Before record updated
global $dal, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$tblOrders = $dal->Table("anagraficaautomezzi");

$rs = $tblOrders->Query("ID=".$_SESSION[$strTableName."_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

echo "Informazioni di sessione Targa: ".$data["Targa"]. " ", "Id_Targa: ".$data["ID"]."
";

}

}
//Gestione interimento record per tagliandi futuri

global $conn;

$Gest0 = $oldvalues["ScadenzaGestita"];

$Gest1 = $values["ScadenzaGestita"];

$Tipo = $values["TipoScadenza"];

$kmr = $values["Km_alla_data_della_manutenzione"];

$IdTarga = $data["ID"];

$note = $values["Note"];

$id = $values["ID"];

$datast = date("Y-m-d",strtotime($values["Data_effetuazione"])+(606024365)); //data + un anno

$str = "select SogliaTagliando from anagraficaautomezzi where Id='".$IdTarga."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$sol = $data["SogliaTagliando"];

$write = $kmr + $sol;
//controlla che tipo di modifiche vengono fatte al record e sceglie cosa fare

if ($Gest0 == 0 and $Gest1 == 0 and $Tipo == 'TAGLIANDO')

return true;
if ($Gest0 == 0 and $Gest1 == 1 and $Tipo == 'TAGLIANDO' and $note == 'PRIMO TAGLIANDO DI CONTROLLO')

{

$strSQLInsert = "insert into tabella_manutenzioni (IdTarga, TipoScadenza, DataInserimento, ScadenzaGestita, TagliandoKm) values ($IdTarga,'TAGLIANDO', now(), 0, $sol)";

db_exec($strSQLInsert,$conn);

$message = "<font color='red'><div class=message> INSERITO NUOVO RECORD!$Gest0, $Gest1</div></font>";

return true;

}
if ($Gest0 == 0 and $Gest1 == 1 and $Tipo == 'TAGLIANDO') //tagliando gestito correttamente

{

$strSQLInsert = "insert into tabella_manutenzioni (IdTarga, TipoScadenza, DataInserimento, ScadenzaGestita, TagliandoKm) values ($IdTarga,'TAGLIANDO', now(), 0, $write)";

db_exec($strSQLInsert,$conn);

//$strSQLInsert2 = "insert into tabella_scadenze (Id_targa, data_scadenza, scadenza_gestita, Note, Destinatario_informazione, AuReference) values ('".$IdTarga."', '".$datast."', '0', 'SCADENZA ANNUALE TAGLIANDO', 'AUTOMEZZI', '".$id."' )";

//db_exec($strSQLInsert2,$conn);

$message = "<font color='red'><div class=message> INSERITO NUOVO RECORD!$Gest0, $Gest1</div></font>";

return true;

}

else

If ($Tipo != 'TAGLIANDO')

return true;

{

$message = "<font color='red'><div class=message>LA SCADENZA E' GIA' STATA GESTITA, NON PUOI MODIFICARLA!!</div></font> $Gest0, $Gest1";

return false;

}
//echo "Id_Targa_selezionato: ", $idTarga;
This is the code in After record updated
global $dal, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$tblOrders = $dal->Table("anagraficaautomezzi");

$rs = $tblOrders->Query("ID=".$_SESSION[$strTableName."_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

echo "Informazioni di sessione Targa: ".$data["Targa"]. " ", "Id_Targa: ".$data["ID"]."
";

}

}
global $conn;

$IdT = $data["ID"];

$Gest0 = $oldvalues["ScadenzaGestita"];

$Gest1 = $values["ScadenzaGestita"];

$Tipo = $values["TipoScadenza"];

$id = $values["ID"]; //informazioni dalla pagina della sessione

$datast = date("Y-m-d",strtotime($values["Data_effetuazione"])+(60
6024365)); //data + un anno
if ($Gest0 == 0 and $Gest1 == 1 and $Tipo == 'TAGLIANDO') //tagliando gestito correttamente

{

$strSQLInsert = "insert into tabella_scadenze (Id_targa, data_scadenza, scadenza_gestita, Note, Destinatario_informazione, AuReference) values ('".$IdT."', '".$datast."', '0', 'SCADENZA ANNUALE TAGLIANDO', 'AUTOMEZZI', '".$id."' )";

db_exec($strSQLInsert,$conn);

}

J
Jane 3/14/2012

Simone,
Could you post screenshot with actual error message?

Also you can publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

S
sickacid author 3/14/2012



Simone,
Could you post screenshot with actual error message?

Also you can publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.


Hi, I've understand the prolbem, if I delete Before record updated event,the code in After record updated WORKS!

can't I use DAL two times? or my code in Before record updated exit unusally?, but if i delete After record event it works.

S
sickacid author 3/14/2012

I've fix changing the code with this:
global $dal, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$tblOrders = $dal->Table("anagraficaautomezzi");

$rs = $tblOrders->Query("ID=".$_SESSION[$strTableName."_masterkey1"],"");

$data = db_fetch_array($rs);

}

Sergey Kornilov admin 3/14/2012

You can use DAL two or more times.