start of calculating bonuses - need mysql functions