before update hook not working

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
elrancho2768
Posts: 1
Joined: 2014-07-07 15:48

before update hook not working

Post by elrancho2768 » 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?

User avatar
a.gneady
Site Admin
Posts: 1287
Joined: 2012-09-27 14:46
Contact:

Re: before update hook not working

Post by a.gneady » 2014-07-08 11:36

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.
:idea: 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.

Post Reply