Changes to AgileBill

This commit is contained in:
Deon George
2009-08-03 14:10:16 +10:00
parent 0a22cfe22c
commit 27aee719b0
1051 changed files with 219109 additions and 117219 deletions

View File

@@ -1,128 +1,193 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @version 1.4.93
* @subpackage Modules:Product
*/
/**
* Basic Product Plugin Class for AgileBill
*
* The main AgileBill Base Product Plugin Class
*
* @package AgileBill
* @subpackage Modules:Product
*/
class base_product_plugin
{
var $name = '';
var $tax_based = false;
var $remote_based = true;
var $account;
var $product;
var $product_attr;
abstract class base_product_plugin {
# Plugin Name
protected $name = '';
# If this plugin provisions remote services
public $remote_based = false;
# Account Using this Plugin
protected $account;
# Product this Plugin is Refering
protected $product;
# Product Actributes
protected $product_attr;
/**
* Provision new service
*
* Some available variables:
* * All the fields on the account table, eg: id,username,email,first_name,last_name
* $this->account['username'];
* * All the fields in the service table, eg: id,host_username,host_password
* $this->service['id'];
* * All the fields captured by the custom product plugin configuration template
* $this->plugin_data['my_field'];
*/
function p_new()
{
return true;
protected function p_new() {
# Do some background logging of what is going on
global $C_debug;
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
return true;
}
/**
* Modify service
*/
function p_edit()
{
protected function p_edit() {
# Do some background logging of what is going on
global $C_debug;
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
return true;
}
/**
* Suspend service
*/
function p_inactive()
{
protected function p_inactive() {
# Do some background logging of what is going on
global $C_debug;
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
return true;
}
/**
* Activate service
*/
function p_active()
{
protected function p_active() {
# Do some background logging of what is going on
global $C_debug;
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
return true;
}
/**
* Delete service
* Delete service
*/
function p_delete()
{
protected function p_delete() {
# Do some background logging of what is going on
global $C_debug;
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
return true;
}
function p_one($id)
{
/**
* Delete items from a cart
* Return is not used
*/
public function delete_cart($VAR,$cart) {
return;
}
/**
* Validate items added to cart
*/
public function validate_cart($VAR,$cart) {
return true;
}
/**
* Process a Service
*/
public function p_one($id) {
global $C_debug;
/* Get the service details */
$db = &DB();
$rs = $db->Execute(sqlSelect($db,"service","*","id=::$id::"));
if(!$rs || !$rs->RecordCount()) return false;
/* Get the service details */
$rs = $db->Execute(sqlSelect($db,'service','*',sprintf('id=::%s::',$id)));
if (! $rs || ! $rs->RecordCount())
return false;
$this->service = $rs->fields;
@$this->plugin_data = unserialize($this->service['prod_plugin_data']);
@$this->prod_attr_cart = unserialize($this->service['prod_attr_cart']);
/* Get the account details */
$acct = $db->Execute(sqlSelect($db,"account","*","id=::{$this->service['account_id']}::"));
if($acct && $acct->RecordCount()) $this->account = $acct->fields;
/* Get the product details */
if(!empty($this->service['product_id'])) {
$product = $db->Execute(sqlSelect($db,"product","*","id = ::{$this->service['product_id']}::"));
$this->product = $product->fields;
@$this->product_attr = unserialize($product->fields['prod_plugin_data']);
}
/* determine the correct action */
switch ($this->service['queue'])
{
# Get the account details
$acct = $db->Execute(sqlSelect($db,'account','*',sprintf('id=::%s::',$this->service['account_id'])));
if ($acct && $acct->RecordCount())
$this->account = $acct->fields;
# Get the product details
if (! empty($this->service['product_id'])) {
$product = $db->Execute(sqlSelect($db,'product','*',sprintf('id = ::%s::',$this->service['product_id'])));
$this->product = $product->fields;
@$this->product_attr = unserialize($product->fields['prod_plugin_data']);
}
# Determine the correct action
switch ($this->service['queue']) {
case 'new':
$result = $this->p_new();
break;
$result = $this->p_new();
break;
case 'active':
$result = $this->p_active();
break;
$result = $this->p_active();
break;
case 'inactive':
$result = $this->p_inactive();
break;
case 'edit':
break;
case 'edit':
if ($this->service['active'] == 1)
$this->p_active();
else
$this->p_inactive();
$result = $this->p_edit();
break;
break;
case 'delete':
$result = $this->p_delete();
break;
default:
$result = false;
}
if(@$result !== false) {
$sql = 'UPDATE '.AGILE_DB_PREFIX.'service SET queue='.$db->qstr('none') . ', date_last='.$db->qstr(time()) . ' WHERE id ='.$db->qstr($rs->fields['id']).' AND site_id='.$db->qstr(DEFAULT_SITE);
$upd = $db->Execute($sql);
} else {
if ($result) {
$sql = sprintf("UPDATE %sservice SET queue='none', date_last=%s WHERE id =%s AND site_id=%s",
AGILE_DB_PREFIX,$db->qstr(time()),$db->qstr($rs->fields['id']),$db->qstr(DEFAULT_SITE));
$db->Execute($sql);
} else {
$C_debug->error($this->name.'php', $this->service['queue'], @$result);
}
}
}
?>
?>

View File

@@ -1,161 +1,211 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @version 1.4.93
* @subpackage Modules:Product
*/
class product
{
/**
* The main AgileBill Product Class
*
* @package AgileBill
* @subpackage Modules:Product
*/
class product extends OSB_module {
# Holds the array of available attributes for the current product
private $attr = array();
/**
* Holds the array of available attributes for the current product
* @var array
* Show the product details, used when an admin adds a product to a customers account
*/
var $attr;
/** Admin: View details */
function admin_details($VAR) {
public function admin_details($VAR) {
$this->session_id = SESS;
if(!empty($VAR['account_id'])) {
$this->account_id = $VAR['account_id'];
$db=&DB();
$rs = $db->Execute(sqlSelect($db,"session","id","account_id={$this->account_id}"));
if($rs && $rs->RecordCount()) $this->session_id = $rs->fields['id'];
}
$this->details($VAR, $this);
if (! empty($VAR['account_id'])) {
$this->account_id = $VAR['account_id'];
$db = &DB();
$rs = $db->Execute(sqlSelect($db,'session','id',sprintf('account_id=%s',$this->account_id)));
if ($rs && $rs->RecordCount())
$this->session_id = $rs->fields['id'];
}
$this->details($VAR);
}
/** User: View details */
function details($VAR, &$product_obj) {
global $smarty;
if(empty($VAR['id'])) return false;
/**
* Show the product details to the user - used on the order form
*/
public function details($VAR) {
global $smarty, $C_auth;
if (empty($VAR['id']))
return false;
# able to view inactive items?
$db = &DB();
global $C_auth;
if($C_auth->auth_method_by_name('invoice','add')) $active = ''; else $active = " AND active=1";
$result = $db->Execute(sqlSelect($db,"product","*","id=::{$VAR['id']}:: $active"));
if($result->RecordCount() == 0) return false;
# check for group settings:
# Able to view inactive items?
if (! $C_auth->auth_method_by_name('invoice','add'))
$active = '';
else
$active = ' AND active=1';
$result = $db->Execute($sql = sqlSelect($db,'product','*',sprintf('id=::%s::%s',$VAR['id'],$active)));
if (! count($result->RecordCount()))
return false;
# Check for group settings
$groups = unserialize($result->fields['group_avail']);
$auth = false;
for($ii=0; $ii<count($groups); $ii++) {
if($C_auth->auth_group_by_id($groups[$ii])) {
for ($ii=0; $ii<count($groups); $ii++) {
if ($C_auth->auth_group_by_id($groups[$ii])) {
$auth = true;
break;
}
}
if(!$auth) return false;
# define the DB vars as a Smarty accessible block
$smarty->assign('product', $result->fields);
if (!$auth)
return false;
# Define the DB vars as a Smarty accessible block
$smarty->assign('product',$result->fields);
# If trial, get the sku of the trial product:
if($result->fields["price_type"] == '2') {
$trial = $db->Execute(sqlSelect($db,"*","product","id=::{$result->fields["price_trial_prod"]}::"));
$smarty->assign('trial', $trial->fields);
if($result->fields['price_type'] == '2') {
$trial = $db->Execute(sqlSelect($db,'*','product',sprintf('id=::%s::',$result->fields['price_trial_prod'])));
$smarty->assign('trial',$trial->fields);
}
# Get the best price for base, setup, & any attributes:
$this->price_arr($result->fields);
$smarty->assign('price', $this->price);
$smarty->assign('price',$this->price);
# Get any attributes & attribute pricing:
$this->attr_arr($VAR['id']);
$smarty->assign('attr', $this->attr);
$smarty->assign('attr',$this->attr);
return true;
}
/**
* Get Atribute values for product details page, sets $this->attr
* Return the best price for a product, based on group details
* Determine the best price based on the base rate, not based on the best setup price.
*
* @param array Price Group Array
* @return array Best Price and Setup Price
*/
private function best_price($fields,$account,$recurr_schedule,$show=false) {
global $C_auth;
$ret = array();
@$g_ar = unserialize($fields['price_group']);
if (is_array($g_ar)) {
$g_ar = $g_ar[$recurr_schedule];
if (count($g_ar) > 0) {
while (list($group,$vals) = each($g_ar)) {
if (! $show || (isset($g_ar['show']) && $g_ar['show']))
if ($C_auth->auth_group_by_account_id($account,$group)) {
if ($vals['price_base'] != '' && (! isset($ret['base']) || $vals['price_base'] < $ret['base'])) {
$ret['base'] = $vals['price_base'];
$ret['setup'] = $vals['price_setup'];
}
}
}
}
}
return $ret;
}
/**
* Get Attribute values for product details page, sets $this->attr
*
* @param int $product_id The product id
* @return unknown
*/
function attr_arr($product_id)
{
global $C_auth;
# set the current account
if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT;
$db = &DB();
$result = $db->Execute(sqlSelect($db,"product_attr","*","product_id=::$product_id::","sort_order"));
if(!$result || $result->RecordCount() == 0) {
$this->attr = false;
private function attr_arr($product_id) {
# Set the current account
if (empty($this->account_id))
$this->account_id = SESS_ACCOUNT;
$db = &DB();
$result = $db->Execute(sqlSelect($db,'product_attr','*',sprintf('product_id=::%s::',$product_id),'sort_order'));
if (! $result || $result->RecordCount() == 0) {
$this->attr = array();
return false;
}
# loop through each attribute to get the values:
$i=0;
while( !$result->EOF ) {
$this->attr[$i]["id"] = $result->fields["id"];
$this->attr[$i]["type"] = $result->fields["collect_type"];
$this->attr[$i]["default"] = $result->fields["collect_default"];
$this->attr[$i]["name"] = $result->fields["name"];
$this->attr[$i]["description"] = $result->fields["description"];
$this->attr[$i]["required"] = $result->fields["required"];
#get the best base & setup price
$g_ar = unserialize($result->fields["price_group"]);
$ret['base'] = $result->fields["price_base"];
$ret['setup'] = $result->fields["price_setup"];
if($ret['base'] != 0 && $ret['setup']!= 0) {
if(count($g_ar) > 0) {
while (list ($group, $vals) = each ($g_ar)) {
if ($C_auth->auth_group_by_account_id($this->account_id, $group)) {
if($vals["price_base"] != "" && $vals["price_base"] < $ret['base'])
$ret['base'] = $vals["price_base"];
if($vals["price_setup"] != "" && $vals["price_setup"] < $ret['setup'])
$ret['setup'] = $vals["price_setup"];
}
}
}
}
# if menu, get the menu values as an array:
if($result->fields["collect_type"] == '2') {
$pat="\r\n";
}
# Loop through each attribute to get the values
$i = 0;
while (! $result->EOF) {
$this->attr[$i]['id'] = $result->fields['id'];
$this->attr[$i]['type'] = $result->fields['collect_type'];
$this->attr[$i]['default'] = $result->fields['collect_default'];
$this->attr[$i]['name'] = $result->fields['name'];
$this->attr[$i]['description'] = $result->fields['description'];
$this->attr[$i]['required'] = $result->fields['required'];
# Get the best base & setup price
$ret = $this->best_price(unserialize($result->fields['price_group']));
$this->attr[$i]['price_base'] = $ret['base'];
$this->attr[$i]['price_setup'] = $ret['setup'];
# If menu, get the menu values as an array
if ($result->fields['collect_type'] == '2') {
$pat = "\r\n";
$tarr = false;
$marr = explode($pat,$result->fields["collect_default"]);
for($ii=0;$ii<count($marr); $ii++) {
if(empty($marr[$ii]) || $marr[$ii] == '*') {
# blank line
$tarr[] = Array ('name' => '', 'base' => 0, 'setup' => 0);
$marr = explode($pat,$result->fields['collect_default']);
for ($ii=0; $ii<count($marr); $ii++) {
if (empty($marr[$ii]) || $marr[$ii] == '*') {
# Blank line
$tarr[] = array('name'=>'','base'=>0,'setup'=>0);
} else {
# populated line, determine base/setup price:
if(ereg('==', $marr[$ii])) {
# Populated line, determine base/setup price:
if (preg_match('/==/',$marr[$ii])) {
# Use custom prices
$marrp = explode("==", $marr[$ii]);
$tarr[] = Array ('name' => @$marrp[0], 'base' => @$marrp[1], 'setup' => @$marrp[2]);
$marrp = explode('==',$marr[$ii]);
$tarr[] = array('name'=>@$marrp[0],'base'=>@$marrp[1],'setup'=>@$marrp[2]);
} else {
# Use default prices
$tarr[] = Array ('name' => $marr[$ii], 'base' => $ret['base'], 'setup' => $ret['setup']);
$tarr[] = array('name'=>$marr[$ii],'base'=>$ret['base'],'setup'=>$ret['setup']);
}
}
}
$this->attr[$i]["default"] = $tarr;
$this->attr[$i]['default'] = $tarr;
}
$this->attr[$i]["price_base"] = $ret["base"];
$this->attr[$i]["price_setup"] = $ret["setup"];
$result->MoveNext();
$i++;
}
return true;
}
/** HERE **/
/**
* Calculate the cost for the attributes in the cart
*
@@ -164,44 +214,50 @@ class product
* @param int $recurr_schedule The recurring schedule, 0-5
* @param int $account The account id
* @param bool $prorate Apply prorating or not
* @return unknown
* @return array
*/
function price_attr($fields, $cart_attr, $recurr_schedule, $account=SESS_ACCOUNT, $prorate=true)
{
function price_attr($fields,$cart_attr,$recurr_schedule,$account=SESS_ACCOUNT,$prorate=true) {
global $C_auth;
$ret['base'] = 0;
$ret['setup'] = 0;
$product_id = $fields['id'];
# Get the vars:
if(!empty($cart_attr) && !is_array($cart_attr)) $cart_attr = unserialize($cart_attr);
if(!is_array($cart_attr)) return false;
# get the attributes for this product
$db = &DB();
$result = $db->Execute(sqlSelect($db, "product_attr", "*","product_id=::$product_id::","sort_order"));
if(!$result || $result->RecordCount() == 0) {
$this->attr = false;
if (! empty($cart_attr) && ! is_array($cart_attr))
$cart_attr = unserialize($cart_attr);
if (! is_array($cart_attr))
return false;
# Get the attributes for this product
$db = &DB();
$result = $db->Execute(sqlSelect($db,'product_attr','*',sprintf('product_id=::%s::',$product_id),'sort_order'));
if (!$result || $result->RecordCount() == 0) {
$this->attr = false;
return false;
}
# loop through each attribute to get the values & validate the input:
$i=0;
while( !$result->EOF ) {
# Loop through each attribute to get the values & validate the input
$i = 0;
while (! $result->EOF) {
$calc = false;
reset($cart_attr);
# loop through each attribute defined in the cart
foreach($cart_attr as $id=>$val) {
$menu_def = true;
# if defined in the cart:
if(!empty($val) && is_numeric($id) && $id == $result->fields["id"]) {
# get the best base & setup price
$g_ar = unserialize($result->fields["price_group"]);
$curr['base'] = $result->fields["price_base"];
$curr['setup'] = $result->fields["price_setup"];
### if menu, get the base & setup amount from the selected item:
if($result->fields["collect_type"] == '2') {
$marr = explode("\r\n",$result->fields["collect_default"]);
reset($cart_attr);
# Loop through each attribute defined in the cart
foreach ($cart_attr as $id=>$val) {
$menu_def = true;
# If defined in the cart:
if (! empty($val) && is_numeric($id) && $id == $result->fields['id']) {
# Get the best base & setup price
$g_ar = unserialize($result->fields['price_group']);
$curr['base'] = $result->fields['price_base'];
$curr['setup'] = $result->fields['price_setup'];
# If menu, get the base & setup amount from the selected item:
if ($result->fields['collect_type'] == '2') {
$marr = explode("\r\n",$result->fields['collect_default']);
# Loop through each menu option
for($ii=0;$ii<count($marr); $ii++) {
# Check if current menu item matches the one selected
@@ -209,17 +265,17 @@ class product
# populated line, determine base/setup price:
if(ereg('==', $marr[$ii])) {
# Use custom prices
$marrp = explode("==", $marr[$ii]);
$marrp = explode('==', $marr[$ii]);
@$ret['base'] += @$marrp[1];
@$ret['setup'] += @$marrp[2];
$menu_def = false;
}
}
}
$this->attr[$i]["default"] = $tarr;
}
$this->attr[$i]['default'] = $tarr;
}
### determine best group pricing
# Determine best group pricing
if($menu_def) {
if($curr['base'] > 0 || $curr['setup'] > 0) {
if(count($g_ar) > 0) {
@@ -228,11 +284,11 @@ class product
// check if better pricing exist for current group
if (is_numeric($group) && $C_auth->auth_group_by_account_id($account, $group)) {
// calculate the base price
if($vals["price_base"] != "" && $vals["price_base"] < $curr['base']) @$ret['base'] += $vals["price_base"];
else @$ret['base'] += $curr["base"];
if($vals['price_base'] != '' && $vals['price_base'] < $curr['base']) @$ret['base'] += $vals['price_base'];
else @$ret['base'] += $curr['base'];
// calculate the setup price
if($vals["price_setup"] != "" && $vals["price_setup"] < $curr['setup']) @$ret['setup'] += $vals["price_setup"];
else @$ret['setup'] += $curr["setup"];
if($vals['price_setup'] != '' && $vals['price_setup'] < $curr['setup']) @$ret['setup'] += $vals['price_setup'];
else @$ret['setup'] += $curr['setup'];
$idx++;
}
}
@@ -244,86 +300,130 @@ class product
$result->MoveNext();
$i++;
}
# check the subscription schedule and calculate actual rate for this schedule:
$arr = Array(.23, 1, 3, 6, 12, 24, 36);
if($fields["price_recurr_type"] == 1)
$ret['base'] *= $arr[$recurr_schedule];
# check for any prorating for the selected schedule:
if($fields["price_recurr_type"] == 1 && $prorate==true)
$prorate = $this->prorate($recurr_schedule, $fields["price_recurr_weekday"], $fields["price_recurr_week"]);
# calculate the prorated recurring amount:
if (@$prorate > 0 && $ret["base"] > 0) $ret["base"] *= $prorate;
return Array('base' => @round($ret["base"], 2), 'setup' => @$ret["setup"]);
# check the subscription schedule and calculate actual rate for this schedule:
$arr = array(.23, 1, 3, 6, 12, 24, 36);
if($fields['price_recurr_type'] == 1)
$ret['base'] *= $arr[$recurr_schedule];
# check for any prorating for the selected schedule:
if($fields['price_recurr_type'] == 1 && $prorate==true)
$prorate = $this->prorate($recurr_schedule, $fields['price_recurr_weekday'], $fields['price_recurr_week']);
# calculate the prorated recurring amount:
if (@$prorate > 0 && $ret['base'] > 0) $ret['base'] *= $prorate;
return array('base' => @round($ret['base'],2), 'setup' => @$ret['setup']);
}
/**
* Get the start & end of set billing schedules
* Get the start & end of set billing schedules
*
* @param int $type
* @param int $weekday
* @param int $week
* @return float
* @param int $type Type of Recur
* @param int $weekday Day of Month for fixed billing
* @param int $week Unused
* @return array
*/
function recurrDates($type, $weekday, $week) {
if ($type == 0) {
$period_start = time();
$period_end = $period_start + (86400*7);
return Array('start' => $period_start, 'end' => $period_end);
} elseif ($type == 1) {
$inc_months = 1;
} elseif ($type == 2) {
$inc_months = 3;
} elseif ($type == 3) {
$inc_months = 6;
} elseif ($type == 4) {
$inc_months = 12;
} elseif ($type == 5) {
$inc_months = 24;
} else {
return false;
}
$d = mktime(0, 0 ,0 ,date('m', time()), $weekday, date('y', time()));
if($d < time())
$period_start = $d;
public function recurrDates($type,$weekday,$week,$period_date=false) {
# Make the period consistent, eg: Quarterly = Jan-Mar,Apr-Jun; HalfYearly = Jan-Jun,Jul-Dec
$strict = false;
$used_months = 0;
if (! $period_date)
$period_date = strtotime('today');
switch ($type) {
# Weekly
case 0:
$period_end = $period_date+(86400*7);
return array('start'=>$period_date,'date'=>$period_date,'end'=>$period_end);
# Monthly
case 1:
$inc_months = 1;
break;
# Quarterly
case 2:
# @todo Make this configurable.
$strict = true;
$inc_months = 3;
break;
# Half Yearly
case 3:
# @todo Make this configurable.
$strict = true;
$inc_months = 6;
break;
# Yearly
case 4:
$inc_months = 12;
break;
# Biennial
case 5:
$inc_months = 24;
break;
# Triennial
case 6:
$inc_months = 36;
break;
default:
return false;
}
if ($strict && $type > 0 && $type < 5)
$used_months = $inc_months-(($inc_months-(date('n',$period_date)%$inc_months))%$inc_months+1);
$d = mktime(0,0,0,date('m',$period_date)-$used_months,$weekday,date('y',$period_date));
if ($d <= $period_date)
$period_start = $d;
else
$period_start = mktime(0,0,0,date('m', $d)-1, $weekday, date('y', $d));
$period_end = mktime(0,0,0,date('m', $period_start)+$inc_months, $weekday, date('y', $period_start));
return Array('start' => $period_start, 'end' => $period_end);
$period_start = mktime(0,0,0,date('m',$d)-1-$used_months,$weekday,date('y',$d));
$period_end = mktime(0,0,0,date('m',$period_start)+$inc_months,$weekday,date('y',$period_start));
return array('start'=>$period_start,'date'=>$period_date,'end' => $period_end);
}
/**
* Determine Prorate Amount
* Determine Prorate Amount
*
* @param int $type
* @param int $weekday
* @param int $week
* @return float
*/
function prorate($type, $weekday, $week)
{
$arr = $this->recurrDates($type, $weekday, $week);
if(!$arr) return 0;
$total_time = $arr['end'] - $arr['start'];
$remain_time = $arr['end'] - time();
private function prorate($type,$weekday,$week,$period_start=false) {
$arr = $this->recurrDates($type,$weekday,$week,$period_start);
if (!$arr)
return 0;
$total_time = $arr['end']-$arr['start'];
$remain_time = $arr['end']-$arr['date'];
$percent_remain = ($remain_time/$total_time) ;
return round($percent_remain,2);
return round($percent_remain,4);
}
/**
* Get the lowest price for one-time or recurring product fees
*
* @param array $fields Array containing all product fields
* @param array $fields array containing all product fields
*/
function price_arr($fields) {
global $C_auth;
if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT;
if (empty($this->account_id)) $this->account_id = SESS_ACCOUNT;
$type = $fields['price_type'];
$g_ar = unserialize($fields["price_group"]);
//echo '<pre>'.__METHOD__;print_r($fields);die();
if($type != "1")
{
# get the best base price (trial or one-time charges):
@@ -378,6 +478,7 @@ class product
}
}
}
$this->price = $ret;
}
@@ -387,12 +488,14 @@ class product
* @param int $group Group ID
* @return bool
*/
function group_pricing($group) {
private function group_pricing($group) {
$db = &DB();
$rs = $db->Execute(sqlSelect($db,"group","pricing","id=$group"));
if($rs && $rs->fields['pricing']==1) return true;
$rs = $db->Execute(sqlSelect($db,'group','pricing',sprintf('id=%s',$group)));
if ($rs && $rs->fields['pricing']==1)
return true;
}
/**
* Best Price for Product
*
@@ -402,60 +505,59 @@ class product
* @param bool $prorate
* @return array
*/
function price_prod($fields, $recurr_schedule, $account=SESS_ACCOUNT, $prorate=true) {
global $C_auth;
$type = $fields['price_type'];
@$g_ar = unserialize($fields["price_group"]);
if($type != "1") {
# get the best base price (trial or one-time charges)
$ret['base'] = $fields["price_base"];
$ret['setup'] = $fields["price_setup"];
if(is_array($g_ar) && count($g_ar) > 0 ) {
while (list ($group, $vals) = each ($g_ar)) {
function price_prod($fields,$recurr_schedule,$account=SESS_ACCOUNT,$prorate=true) {
switch ($fields['price_type']) {
# Recurring charge, return best base/setup rates for all available payment schedules
case 1:
# Check for any prorating for the selected schedule:
if ($fields['price_recurr_type'] == 1 && $prorate==true)
$prorate = $this->prorate($recurr_schedule,$fields['price_recurr_weekday'],$fields['price_recurr_week']);
$ret = $this->best_price($fields,$account,$recurr_schedule,true);
if (! count($ret))
return false;
# Calculate the prorated recurring amount:
if ($prorate > 0 && $ret['base'] > 0)
$ret['base'] *= $prorate;
break;
# Get the best base price (trial or one-time charges)
# @todo - need to optimise (call best_price())
default:
global $C_auth;
@$g_ar = unserialize($fields['price_group']);
if (! is_array($g_ar) || ! count($g_ar))
return false;
$ret['base'] = $fields['price_base'];
$ret['setup'] = $fields['price_setup'];
while (list($group,$vals) = each($g_ar)) {
if (is_numeric($group) && $C_auth->auth_group_by_account_id($account,$group)) {
if($this->group_pricing($group)) {
if($vals["price_base"] != "" && $vals["price_base"] < $ret['base']) $ret['base']= $vals["price_base"];
if($vals["price_setup"] != "" && $vals["price_setup"] < $ret['setup']) $ret['setup'] = $vals["price_setup"];
if ($this->group_pricing($group)) {
if ($vals['price_base'] != '' && $vals['price_base'] < $ret['base'])
$ret['base']= $vals['price_base'];
if ($vals['price_setup'] != '' && $vals['price_setup'] < $ret['setup'])
$ret['setup'] = $vals['price_setup'];
}
}
}
}
return Array('base' => $ret["base"], 'setup' => $ret["setup"]);
} else {
## Recurring charge, return best base/setup rates for all available payment schedules
if(is_array($g_ar) && count($g_ar) > 0) {
$i = $recurr_schedule;
# check for any prorating for the selected schedule:
if($fields["price_recurr_type"] == 1 && $prorate==true)
$prorate = $this->prorate($recurr_schedule, $fields["price_recurr_weekday"], $fields["price_recurr_week"]);
while (list ($group, $vals) = each ($g_ar[$i])) {
if($g_ar[$i]["show"] == "1") {
if (is_numeric($group) && $C_auth->auth_group_by_account_id($account, $group)) {
if($this->group_pricing($group)) {
if($vals["price_base"] != "")
if(empty($ret['base']) || $vals["price_base"] < $ret['base']) $ret['base'] = $vals["price_base"];
if($vals["price_setup"] != "")
if(empty($ret['setup']) || $vals["price_setup"] < $ret['setup'])
$ret['setup'] = $vals["price_setup"];
}
}
}
}
}
if(empty($ret)) return false;
# calculate the prorated recurring amount:
if (@$prorate > 0 && $ret["base"] > 0) $ret["base"] *= $prorate;
}
return Array('base' => @round($ret["base"], 2), 'setup' => @$ret["setup"]);
return array('base'=>round($ret['base'],2),'setup'=>$ret['setup']);
}
/**
* Get the lowest (recurring) price
*
* @param array $fields
* @param int $account
* @return array Recurring Price
* @return array Recurring Price
*/
function price_recurr_arr($fields, $account) {
global $C_auth;
@@ -464,7 +566,7 @@ class product
for($i=0; $i<count($g_ar); $i++) {
while (list ($group, $vals) = each ($g_ar[$i])) {
if($g_ar[$i]["show"] == "1") {
if (is_numeric($group) && $C_auth->auth_group_by_account_id($account,$group)) {
if (is_numeric($group) && $C_auth->auth_group_by_account_id($account,$group)) {
if($vals["price_base"] != "")
if(empty($ret[$i]['base']) || $vals["price_base"] < $ret[$i]['base']) $ret[$i]['base'] = $vals["price_base"];
@@ -477,9 +579,9 @@ class product
}
return $ret;
}
/**
* Clone Existing Product
/**
* Clone Existing Product
*/
function cloner($VAR)
{
@@ -504,8 +606,8 @@ class product
# Clone product
$new_prod_id = $db->GenID(AGILE_DB_PREFIX.'product_id');
$sql = "INSERT INTO {$p}product SET
id = $new_prod_id,
sku = " . $db->qstr($sku);
id = $new_prod_id,
sku = " . $db->qstr($sku);
while(list($field,$value) = each($result->fields)) {
if($field != 'sku' && $field != 'id' && !is_numeric($field) )
$sql .= ",$field = ".$db->qstr($value);
@@ -521,8 +623,8 @@ class product
{
$id = $db->GenID(AGILE_DB_PREFIX.'product_translate_id');
$sql = "INSERT INTO {$p}product_translate SET
id = $id,
product_id = $new_prod_id";
id = $id,
product_id = $new_prod_id";
while(list($field,$value) = each($result->fields)) {
if($field != 'product_id' && $field != 'id' && !is_numeric($field) )
$sql .= ",$field = ".$db->qstr($value);
@@ -540,8 +642,8 @@ class product
{
$id = $db->GenID(AGILE_DB_PREFIX.'product_attr_id');
$sql = "INSERT INTO {$p}product_attr SET
id = $id,
product_id = $new_prod_id";
id = $id,
product_id = $new_prod_id";
while(list($field,$value) = each($result->fields)) {
if($field != 'product_id' && $field != 'id' && !is_numeric($field) )
$sql .= ",$field = ".$db->qstr($value);
@@ -596,9 +698,9 @@ class product
}
# Defaults for product groups:
$VAR['product_group_avail'] = Array('0');
$VAR['product_group_avail'] = array('0');
$this->product_construct();
# $this->product_construct();
$type = "add";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
@@ -620,17 +722,9 @@ class product
}
}
function view($VAR) {
$this->product_construct();
$type = "view";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->view($VAR, $this, $type);
}
function update($VAR) {
global $_FILES;
$imgarr = Array('jpeg','jpg','gif','bmp','tif','tiff','png');
$imgarr = array('jpeg','jpg','gif','bmp','tif','tiff','png');
if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0)
{
for($i=0; $i<count($imgarr); $i++)
@@ -651,7 +745,7 @@ class product
if(isset($filename))
$VAR['product_thumbnail'] = $filename;
$this->product_construct();
# $this->product_construct();
$type = "update";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
@@ -667,54 +761,14 @@ class product
function delete($VAR) {
$this->associated_DELETE =
Array (
Array ( 'table' => 'product_translate', 'field' => 'product_id'),
Array ( 'table' => 'product_attr', 'field' => 'product_id'),
Array ( 'table' => 'product_img', 'field' => 'product_id')
array(
array( 'table' => 'product_translate', 'field' => 'product_id'),
array( 'table' => 'product_attr', 'field' => 'product_id'),
array( 'table' => 'product_img', 'field' => 'product_id')
);
$this->product_construct();
# $this->product_construct();
$db = new CORE_database;
$db->mass_delete($VAR, $this, "");
}
function search_form($VAR) {
$this->product_construct();
$type = "search";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->search_form($VAR, $this, $type);
}
function search($VAR)
{
$this->product_construct();
$type = "search";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->search($VAR, $this, $type);
}
function search_show($VAR) {
$this->product_construct();
$type = "search";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->search_show($VAR, $this, $type);
}
function product_construct() {
$this->module = "product";
$this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml";
$C_xml = new CORE_xml;
$construct = $C_xml->xml_to_array($this->xml_construct);
$this->method = $construct["construct"]["method"];
$this->trigger = $construct["construct"]["trigger"];
$this->field = $construct["construct"]["field"];
$this->table = $construct["construct"]["table"];
$this->module = $construct["construct"]["module"];
$this->cache = $construct["construct"]["cache"];
$this->order_by = $construct["construct"]["order_by"];
$this->limit = $construct["construct"]["limit"];
}
}
?>
?>

View File

@@ -1,204 +1,258 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- define the module name -->
<module>product</module>
<!-- define the module table name -->
<table>product</table>
<!-- define the module dependancy(s) -->
<dependancy/>
<!-- define the DB cache in seconds -->
<cache>0</cache>
<!-- define the default order_by field for SQL queries -->
<order_by>sku</order_by>
<!-- define the methods -->
<limit>25</limit>
<!-- define database indexes -->
<index>
<sku>sku</sku>
<active>active</active>
</index>
<!-- define the fields -->
<field>
<id>
<type>I4</type>
<unique>1</unique>
<index>1</index>
</id>
<site_id>
<type>I4</type>
<index>1</index>
</site_id>
<date_orig>
<type>I8</type>
<convert>date-time</convert>
</date_orig>
<date_last>
<type>I8</type>
<convert>date-now</convert>
</date_last>
<sku>
<type>C(32)</type>
<unique>1</unique>
<min_len>1</min_len>
<max_len>32</max_len>
<validate>alphanumeric</validate>
</sku>
<taxable>
<type>L</type>
</taxable>
<active>
<type>L</type>
</active>
<position>
<type>I4</type>
</position>
<cart_multiple>
<type>L</type>
</cart_multiple>
<group_avail>
<type>X2</type>
<validate>any</validate>
<convert>array</convert>
<arr_force>1</arr_force>
</group_avail>
<avail_category_id>
<type>C(255)</type>
<validate>any</validate>
<convert>array</convert>
<arr_force>1</arr_force>
</avail_category_id>
<host>
<type>L</type>
</host>
<host_server_id>
<type>I4</type>
</host_server_id>
<host_provision_plugin_data>
<type>X2</type>
<convert>array</convert>
</host_provision_plugin_data>
<host_allow_domain>
<type>L</type>
</host_allow_domain>
<host_allow_host_only>
<type>L</type>
</host_allow_host_only>
<host_discount_tld>
<type>X2</type>
<convert>array</convert>
</host_discount_tld>
<host_discount_tld_amt>
<type>F</type>
</host_discount_tld_amt>
<discount>
<type>L</type>
</discount>
<discount_amount>
<type>F</type>
</discount_amount>
<price_type>
<type>I4</type>
</price_type>
<price_base>
<type>F</type>
<min_len>1</min_len>
<max_len>32</max_len>
<validate>float</validate>
</price_base>
<price_setup>
<type>F</type>
</price_setup>
<price_group>
<type>X2</type>
<convert>array</convert>
</price_group>
<price_recurr_default>
<type>I4</type>
</price_recurr_default>
<price_recurr_type>
<type>L</type>
</price_recurr_type>
<price_recurr_weekday>
<type>I4</type>
</price_recurr_weekday>
<price_recurr_week>
<type>I4</type>
</price_recurr_week>
<price_recurr_schedule>
<type>L</type>
</price_recurr_schedule>
<price_recurr_cancel>
<type>L</type>
</price_recurr_cancel>
<price_trial_length_type>
<type>I4</type>
</price_trial_length_type>
<price_trial_length>
<type>I4</type>
</price_trial_length>
<price_trial_prod>
<type>I4</type>
<asso_table>product</asso_table>
<asso_field>sku</asso_field>
</price_trial_prod>
<assoc_req_prod>
<type>X2</type>
<asso_table>product</asso_table>
<asso_field>sku</asso_field>
<convert>array</convert>
</assoc_req_prod>
<assoc_req_prod_type>
<type>I4</type>
</assoc_req_prod_type>
<assoc_grant_prod>
<type>X2</type>
<asso_table>product</asso_table>
<asso_field>sku</asso_field>
<convert>array</convert>
<arr_force>1</arr_force>
</assoc_grant_prod>
<assoc_grant_group>
<type>X2</type>
<convert>array</convert>
</assoc_grant_group>
<assoc_grant_group_type>
<type>I4</type>
</assoc_grant_group_type>
<assoc_grant_group_days>
<type>I4</type>
</assoc_grant_group_days>
<thumbnail>
<type>C(128)</type>
</thumbnail>
<prod_plugin>
<type>L</type>
</prod_plugin>
<prod_plugin_file>
<type>C(128)</type>
</prod_plugin_file>
<prod_plugin_data>
<type>X2</type>
<convert>array</convert>
</prod_plugin_data>
<price_recurr_modify>
<type>L</type>
</price_recurr_modify>
<modify_waive_setup>
<type>L</type>
</modify_waive_setup>
<modify_product_arr>
<type>X2</type>
<convert>array</convert>
</modify_product_arr>
</field>
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
<method>
<add>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,price_recurr_modify,modify_waive_setup,modify_product_arr</add>
<update>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,host,host_server_id,host_provision_plugin_data,host_allow_domain,host_allow_host_only,host_discount_tld,host_discount_tld_amt,prod_plugin,prod_plugin_file,prod_plugin_data,price_recurr_modify,modify_waive_setup,modify_product_arr</update>
<delete>id,site_id</delete>
<view>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,host,host_server_id,host_provision_plugin_data,host_allow_domain,host_allow_host_only,host_discount_tld,host_discount_tld_amt,prod_plugin,prod_plugin_file,prod_plugin_data,price_recurr_modify,modify_waive_setup,modify_product_arr</view>
<search>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,price_type,price_recurr_schedule,price_recurr_cancel,price_base,price_setup</search>
</method>
<!-- define the method triggers -->
<trigger>0</trigger>
<!-- Module name -->
<module>product</module>
<!-- Module supporting database table -->
<table>product</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy></dependancy>
<!-- DB cache in seconds -->
<cache>0</cache>
<!-- Default order_by field for SQL queries -->
<order_by>sku</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>0</version>
<!-- Database indexes -->
<index>
<sku>sku</sku>
<active>active</active>
</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>
<sku>
<type>C(32)</type>
<unique>1</unique>
<min_len>1</min_len>
<max_len>32</max_len>
<validate>alphanumeric</validate>
<display>SKU</display>
</sku>
<taxable>
<type>L</type>
</taxable>
<!-- Record active (BOOL)-->
<active>
<display>Status</display>
<type>L</type>
</active>
<position>
<type>I4</type>
</position>
<cart_multiple>
<type>L</type>
</cart_multiple>
<group_avail>
<type>X2</type>
<validate>any</validate>
<convert>array</convert>
<arr_force>1</arr_force>
</group_avail>
<avail_category_id>
<type>C(255)</type>
<validate>any</validate>
<convert>array</convert>
<arr_force>1</arr_force>
</avail_category_id>
<host>
<type>L</type>
</host>
<host_server_id>
<type>I4</type>
</host_server_id>
<host_provision_plugin_data>
<type>X2</type>
<convert>array</convert>
</host_provision_plugin_data>
<host_allow_domain>
<type>L</type>
</host_allow_domain>
<host_allow_host_only>
<type>L</type>
</host_allow_host_only>
<host_discount_tld>
<type>X2</type>
<convert>array</convert>
</host_discount_tld>
<host_discount_tld_amt>
<type>F</type>
</host_discount_tld_amt>
<discount>
<type>L</type>
</discount>
<discount_amount>
<type>F</type>
</discount_amount>
<price_type>
<type>I4</type>
</price_type>
<price_base>
<display>Base Price</display>
<type>F</type>
<min_len>1</min_len>
<max_len>32</max_len>
<validate>float</validate>
</price_base>
<price_setup>
<type>F</type>
</price_setup>
<price_group>
<type>X2</type>
<convert>array</convert>
</price_group>
<price_recurr_default>
<display>Default Billing Schedule</display>
<type>I4</type>
</price_recurr_default>
<!-- Recurring Type: 0=BILL ON ANNIVERSARY, 1: BILL ON FIXED PERIOD -->
<price_recurr_type>
<display>Recurring Billing Schedule</display>
<type>L</type>
</price_recurr_type>
<price_recurr_weekday>
<display>Day of Month to Bill</display>
<type>I4</type>
</price_recurr_weekday>
<price_recurr_week>
<type>I4</type>
</price_recurr_week>
<price_recurr_schedule>
<type>L</type>
</price_recurr_schedule>
<price_recurr_cancel>
<type>L</type>
</price_recurr_cancel>
<price_trial_length_type>
<type>I4</type>
</price_trial_length_type>
<price_trial_length>
<type>I4</type>
</price_trial_length>
<price_trial_prod>
<type>I4</type>
<asso_table>product</asso_table>
<asso_field>sku</asso_field>
</price_trial_prod>
<assoc_req_prod>
<type>X2</type>
<asso_table>product</asso_table>
<asso_field>sku</asso_field>
<convert>array</convert>
</assoc_req_prod>
<assoc_req_prod_type>
<type>I4</type>
</assoc_req_prod_type>
<assoc_grant_prod>
<type>X2</type>
<asso_table>product</asso_table>
<asso_field>sku</asso_field>
<convert>array</convert>
<arr_force>1</arr_force>
</assoc_grant_prod>
<assoc_grant_group>
<type>X2</type>
<convert>array</convert>
</assoc_grant_group>
<assoc_grant_group_type>
<type>I4</type>
</assoc_grant_group_type>
<assoc_grant_group_days>
<type>I4</type>
</assoc_grant_group_days>
<thumbnail>
<display>Product Thumbnail</display>
<type>C(128)</type>
</thumbnail>
<prod_plugin>
<type>L</type>
</prod_plugin>
<prod_plugin_file>
<type>C(128)</type>
</prod_plugin_file>
<prod_plugin_data>
<type>X2</type>
<convert>array</convert>
</prod_plugin_data>
<price_recurr_modify>
<type>L</type>
</price_recurr_modify>
<modify_waive_setup>
<type>L</type>
</modify_waive_setup>
<modify_product_arr>
<type>X2</type>
<convert>array</convert>
</modify_product_arr>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,price_recurr_modify,modify_waive_setup,modify_product_arr</add>
<update>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,host,host_server_id,host_provision_plugin_data,host_allow_domain,host_allow_host_only,host_discount_tld,host_discount_tld_amt,prod_plugin,prod_plugin_file,prod_plugin_data,price_recurr_modify,modify_waive_setup,modify_product_arr</update>
<delete>id,site_id</delete>
<view>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,host,host_server_id,host_provision_plugin_data,host_allow_domain,host_allow_host_only,host_discount_tld,host_discount_tld_amt,prod_plugin,prod_plugin_file,prod_plugin_data,price_recurr_modify,modify_waive_setup,modify_product_arr</view>
<search>id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,price_type,price_recurr_schedule,price_recurr_cancel,price_base,price_setup</search>
</method>
<!-- Method triggers -->
<trigger></trigger>
<!-- Template page display titles -->
<title>
<view>Products</view>
</title>
<!-- Template helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<sku>
<field>sku</field>
</sku>
<price_base>
<field>price_base</field>
</price_base>
<active>
<field>active</field>
<width>20px</width>
</active>
<description>
<field>description</field>
<width>48%</width>
</description>
<icon>
<width>20px</width>
</icon>
</search_show>
</tpl>
</construct>

View File

@@ -1,45 +1,65 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<name>product</name>
<parent>product</parent>
<notes><![CDATA[This module controls the various products and pricing, descriptions, etc.]]></notes>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Products</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>product</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This module controls the various products and pricing, descriptions, etc.]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>product</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>base</type>
</module_properties>
<sql_inserts>
<module_method>
<search_show>
<name>search_show</name>
</search_show>
<search_form>
<name>search_form</name>
</search_form>
<search>
<name>search</name>
<page><![CDATA[%%:search_form]]></page>
<menu_display>1</menu_display>
</search>
<delete>
<name>delete</name>
</delete>
<view>
<name>view</name>
<page><![CDATA[core:search&module=%%&_escape=1&_next_page_one=view]]></page>
<menu_display>1</menu_display>
</view>
<update>
<name>update</name>
</update>
<add>
<name>add</name>
<page><![CDATA[%%:add]]></page>
<menu_display>1</menu_display>
</add>
<admin_details>
<name>admin_details</name>
</admin_details>
<cloner>
<name>cloner</name>
</cloner>
</module_method>
</sql_inserts>
</install>
<!-- 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>
<admin_details>
<name>admin_details</name>
</admin_details>
<cloner>
<name>cloner</name>
</cloner>
</module_method>
</install>