72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* osBilling - Open Billing Software
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
* Originally authored by Deon George
|
||
|
*
|
||
|
* @author Deon George <deonATleenooksDOTnet>
|
||
|
* @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];
|
||
|
}
|
||
|
}
|
||
|
?>
|