OSB enhancements to date

This commit is contained in:
Deon George
2010-11-30 09:41:08 +11:00
parent 8715a2059b
commit ec6a542bc3
478 changed files with 23423 additions and 9309 deletions

View File

@@ -0,0 +1,71 @@
<?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];
}
}
?>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- Module name -->
<module>account_fee</module>
<!-- Module supporting database table -->
<table>account_fee</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy>account</dependancy>
<!-- DB cache in seconds -->
<cache>0</cache>
<!-- Default order_by field for SQL queries -->
<order_by>name</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>1</version>
<!-- Database indexes -->
<index>
</index>
<!-- Database fields -->
<field>
<!-- Record ID -->
<id>
<index>1</index>
<type>I4</type>
<unique>1</unique>
</id>
<!-- Site ID -->
<site_id>
<index>1</index>
<type>I4</type>
</site_id>
<!-- Date record created -->
<date_orig>
<convert>date-now</convert>
<display>Date Created</display>
<type>I8</type>
</date_orig>
<!-- Date record updated -->
<date_last>
<convert>date-now</convert>
<display>Date Updated</display>
<type>I8</type>
</date_last>
<!-- Record active (BOOL)-->
<status>
<display>Active</display>
<type>L</type>
</status>
<name>
<type>C(32)</type>
<validate>any</validate>
</name>
<groups_fee>
<convert>array</convert>
<type>X2</type>
</groups_fee>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>name,groups_fee</add>
<search>name</search>
<update>name,groups_fee</update>
<view>id,name,groups_fee</view>
</method>
<!-- Method triggers -->
<trigger></trigger>
<!-- Template page display titles -->
<title>
<add>Add Account Fee</add>
</title>
<!-- Template helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<name>
<field>name</field>
</name>
</search_show>
</tpl>
</construct>

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy>account</dependancy>
<!-- Translated display to use on the tree -->
<display>Account Fees</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>account_fee</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[Add account fees to accounts.]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>account</parent>
<!-- SUB Modules to install with this one -->
<sub_modules></sub_modules>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type></type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<display>Add</display>
<menu_display>1</menu_display>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>List</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_form>
<name>search_form</name>
<notes><![CDATA[Search for records]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
</module_method>
</install>