before update hook not working
Posted: 2014-07-07 15:57
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?
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?