Hi guys,
I have a table populated using a dataprocessor, of which the first column is a coro so I use a OptionsConnector, like this
$GetRatesSQL = “select t1.DefRateID, t1.EntityID, t1.Rate, t1.Hours, t1.TaskID, t2.TaskDesc from calloutrates t1, tasks t2 where EntityID= $_GET[ClientID] and EntityType=‘Client’ and t1.TaskID=t2.TaskID”;
$options = new OptionsConnector($connection);
$options->render_table(“tasks”,“TaskID”,“TaskID(value),TaskDesc(label)”);
$resconn->set_options(“TaskDesc”,$options);
$resconn->render_sql($GetRatesSQL,“DefRateID”,‘TaskDesc,Rate,Hours’);
This all works fine. However I now need to add some new functionality to log changes to this table to an audit table. I am using the events beforeUpdate, beforeInsert and beforeDelete to call another function to log the event, as this
$resconn->event->attach(“beforeUpdate”,“logTaskChange”);
$resconn->event->attach(“beforeDelete”,“logTaskChange”);
$resconn->event->attach(“beforeInsert”,“logTaskChange”);
My problem is, that if the event is an update the label (TaskDesc) from the first column or coro is passed by the dataprocessor which is perfect. But if the event is insert, the value (TaskID) is passed in, which is not what I want. is there any way to resolve this?
heres my log function thats called on the above events
function logTaskChange($action)
{
$Status = $action->get_status();
$TaskDesc = $action->get_value(“TaskDesc”);
$DefRate = $action->get_value(“Rate”);
$Defhours = $action->get_value(“Hours”);
$ClientID = $_GET[ClientID];
$InsertSQL = mysql_query("insert into changelog (action, area, entityid, details, user) VALUES ('$Status', 'client', '$ClientID', '$TaskDesc rate = [$DefRate], Default Hours = [$Defhours]', '$_SESSION[username]')");
return true;
}
thanks