I have 2 tables
telemarketing
id
hourly_rate
telemarketing_hours
id
telemarketing_id
hourly_pay
bonus
total
All I am trying to do is calculate the the hourly_pay based on the selected telemarketing_id in telemarketing_hours by looking up the hourly_rate in the telemarketing table and then setting the total = hourly_pay + bonus. I have a hook in telemarketing_hours_before_update:
function telemarketing_hours_before_update(&$data, $memberInfo, &$args){
/****lookup hourly rate in the telemarketing table*****/
$hourly_rate =sqlValue("select hourly_rate from telemarketing where id='{$data['telemarketing_id']}'");
/*****calculate the hourly pay*****/
$data['hourly_pay'] = $data['hours'] * $hourly_rate;
/*****calculate the total*****/
$data['total'] = $data['hourly_pay'] + $data['bonus'];
return TRUE;
}
Problem is this is not working. Nothing is being updated. Anyone have any ideas here on what to do?
before update hook not working
Re: before update hook not working
the "total" and "hourly_pay" fields must be visible and editable (not read-only) in the "telemarketing_hours" detail view in order for this to work.
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.