. * * Originally authored by Deon George * * @author Deon George * @copyright 2009 Deon George * @link http://osb.leenooks.net * @license http://www.gnu.org/licenses/ * @package AgileBill * @subpackage Modules:Payment */ /** * The main AgileBill Account Fee Class * * @package AgileBill * @subpackage Modules:AccountFee */ class account_fee extends OSB_module { /** * Calculate the account fee for an account * * @param $account_id The account ID to calculate * @param $period Invoice period being calculated * @uses account */ public function sAccountFee($account_id,$period) { static $CACHE = array(); if (! isset($CACHE[$account_id][$period])) { $db = &DB(); include_once(PATH_MODULES.'account/account.inc.php'); $ao = new account; # Load the account fees $rs = $db->Execute(sqlSelect('account_fee','*',array('where'=>array('active=1')))); if ($rs && $rs->RecordCount()) { while (! $rs->EOF) { $gf = unserialize($rs->fields['groups_fee']); if (isset($gf[$period]) && $gf[$period]['show']) foreach ($ao->sAccountGroups($account_id) as $gid) if (isset($gf[$period]['group'][$gid]) && (! isset($CACHE[$account_id][$period]) || $CACHE[$account_id][$period] > $gf[$period]['group'][$gid]['fee'])) $CACHE[$account_id][$period] = $gf[$period]['group'][$gid]['fee']; $rs->MoveNext(); } } } return $CACHE[$account_id][$period]; } } ?>