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);
}
}
}
?>
?>