I want to create a common auditing routine to embed in all the update,add and delete pages. I have it working O.K., However, I wanted to see if I can add it as a common routine so I don't have to code it over and over again.
The add events looks like the following:
function AfterAdd(&$values,&$keys,$inline)
{
$tablename = 'tblInstructions';
$pkname = 'Instruction_id';
$strSQLid = "select IDENT_CURRENT('".$tablename."') as pk";
global $conn;
$rs = db_exec($strSQLid,$conn);
if ($datacs=db_fetch_array($rs)) {
$pk = $datacs["pk"];}
$strValues1 = "'<".$pkname."=".$pk.">'";
$strSQLInsert = "insert into Audit
(PK,Type,TableName,FieldName,OldValue,NewValue,UpdateDate,UserName)
values (".$strValues1.",'I' ,'".$tablename."','LastUpateUser','','', getdate(),'".$_SESSION["UserID"]."')";
db_exec($strSQLInsert,$conn);
}
Can I make this event part of the template, so I don't need to retype it for every "add", "update" and "Delete" event ?