Removed modules not being used
This commit is contained in:
@@ -1,359 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
* 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>
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Charge
|
||||
*/
|
||||
|
||||
/**
|
||||
* The main AgileBill Charge Class
|
||||
*
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Charge
|
||||
*/
|
||||
class charge extends OSB_module {
|
||||
private $xmlrpc = false;
|
||||
|
||||
public function task_SweepDaily() {
|
||||
$this->sweep(0);
|
||||
}
|
||||
|
||||
public function task_SweepWeekly() {
|
||||
$this->sweep(1);
|
||||
}
|
||||
|
||||
public function task_SweepMonthly() {
|
||||
$this->sweep(2);
|
||||
}
|
||||
|
||||
public function task_SweepQuarterly() {
|
||||
$this->sweep(3);
|
||||
}
|
||||
|
||||
public function task_SweepSemiAnnually() {
|
||||
$this->sweep(4);
|
||||
}
|
||||
|
||||
public function task_SweepAnnually() {
|
||||
$this->sweep(5);
|
||||
}
|
||||
|
||||
private function sweep($type) {
|
||||
global $C_list;
|
||||
|
||||
# Load required elements
|
||||
include_once(PATH_MODULES.'invoice/invoice.inc.php');
|
||||
include_once(PATH_MODULES.'account/account.inc.php');
|
||||
|
||||
$account_billing = false;
|
||||
if ($C_list->is_installed('account_billing')) {
|
||||
include_once(PATH_MODULES.'account_billing/account_billing.inc.php');
|
||||
$abo = new account_billing;
|
||||
}
|
||||
|
||||
$charges = $this->sql_GetRecords(array('where'=>array('status'=>0,'sweep_type'=>$type),'orderby'=>'account_id,date_orig'));
|
||||
|
||||
# No charges
|
||||
if (! count($charges))
|
||||
return true;
|
||||
|
||||
# Start a transaction
|
||||
$db = &DB();
|
||||
if (AGILE_DB_TYPE == 'mysqlt') {
|
||||
$db->StartTrans();
|
||||
|
||||
if (! $db->hasTransactions) {
|
||||
global $C_debug;
|
||||
|
||||
$msg = "Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver";
|
||||
$C_debug->alert($msg);
|
||||
$C_debug->error(__FILE__,__METHOD__,$msg);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$ao = false;
|
||||
$io = false;
|
||||
foreach ($charges as $charge) {
|
||||
# First Run
|
||||
if (! $ao) {
|
||||
$ao = new account($charge['account_id']);
|
||||
}
|
||||
|
||||
# Next run, are we onto a new account?
|
||||
if ($ao->getRecordAttr('id') != $charge['account_id']) {
|
||||
$rs = $io->sql_SaveRecord(true);
|
||||
|
||||
if (! $rs) {
|
||||
global $C_debug;
|
||||
|
||||
$C_debug->error(__FILE__,__METHOD__,$db->ErrorMsg());
|
||||
$db->FailTrans();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AGILE_DB_TYPE == 'mysqlt')
|
||||
$db->CompleteTrans();
|
||||
|
||||
# Start next invoice
|
||||
$io = false;
|
||||
|
||||
# Load our new account object
|
||||
$ao = new account($charge['account_id']);
|
||||
}
|
||||
|
||||
if (! $io) {
|
||||
# Generate an invoice id
|
||||
$io = new invoice();
|
||||
$io->setRecordAttr('id',sqlGenID($db,'invoice'));
|
||||
$io->setRecordAttr('account_id',$charge['account_id']);
|
||||
$io->setRecordAttr('billed_currency_id',$ao->getRecordAttr('currency_id'));
|
||||
$io->setRecordAttr('actual_billed_currency_id',DEFAULT_CURRENCY);
|
||||
$io->setRecordAttr('reseller_id',$ao->getRecordAttr('reseller_id'));
|
||||
$io->setRecordAttr('checkout_plugin_id',$ao->getRecordAttr('checkout_plugin_id'));
|
||||
$io->setRecordAttr('checkout_plugin_data',$ao->getRecordAttr('checkout_plugin_data'));
|
||||
$io->setRecordAttr('grace_period',$ao->getRecordAttr('invoice_grace'));
|
||||
$io->setRecordAttr('affiliate_id',$ao->getRecordAttr('affiliate_id'));
|
||||
$io->setRecordAttr('campaign_id',null);
|
||||
$io->setRecordAttr('notice_next_date',time());
|
||||
$io->setRecordAttr('billing_status',0);
|
||||
$io->setRecordAttr('print_status',0);
|
||||
$io->setRecordAttr('process_status',0);
|
||||
$io->setRecordAttr('status',1);
|
||||
// $io->setRecordAttr('suspend_billing',0);
|
||||
$io->setRecordAttr('billed_amt',0);
|
||||
$io->setRecordAttr('actual_billed_amt',0);
|
||||
$io->setRecordAttr('notice_count',0);
|
||||
$io->setRecordAttr('type',1);
|
||||
$io->setRecordAttr('notice_max',MAX_BILLING_NOTICE);
|
||||
$io->setRecordAttr('account_billing_id',null);
|
||||
|
||||
# @todo this should be a system default
|
||||
$io->setRecordAttr('due_date',time()+7*86400);
|
||||
}
|
||||
|
||||
$io->aaddItem(array(
|
||||
'charge_id'=>$charge['id'],
|
||||
'date_start'=>$charge['date_orig'],
|
||||
'date_stop'=>$charge['date_orig'],
|
||||
'domain_name'=>null,
|
||||
'domain_tld'=>null,
|
||||
'domain_type'=>null,
|
||||
'domain_term'=>null,
|
||||
'item_type'=>5,
|
||||
'price_setup'=>0,
|
||||
'price_base'=>$charge['amount'],
|
||||
'price_type'=>3,
|
||||
'product_id'=>$charge['product_id'],
|
||||
'product_name'=>$charge['description'],
|
||||
'product_attr'=>$charge['attributes'],
|
||||
'product_attr_cart'=>null,
|
||||
'quantity'=>$charge['quantity'],
|
||||
'recurring_schedule'=>null,
|
||||
'service_id'=>$charge['service_id'],
|
||||
'sku'=>null
|
||||
));
|
||||
|
||||
# @todo Move this update, need to incase the charge add fails.
|
||||
$db->Execute(sqlUpdate($db,'charge',array('status'=>1),array('id'=>$charge['id'])));
|
||||
}
|
||||
|
||||
# Save invoice
|
||||
if ($io) {
|
||||
$rs = $io->sql_SaveRecord(true);
|
||||
|
||||
if (! $rs) {
|
||||
global $C_debug;
|
||||
|
||||
$C_debug->error(__FILE__,__METHOD__,$db->ErrorMsg());
|
||||
$db->FailTrans();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AGILE_DB_TYPE == 'mysqlt')
|
||||
$db->CompleteTrans();
|
||||
}
|
||||
}
|
||||
|
||||
function api($VAR) {
|
||||
$db = &DB();
|
||||
|
||||
# amount
|
||||
if(@$VAR['amount'] <= 0) {
|
||||
return $this->api_return(0,'','Invalid value supplied for the \'amount\' parameter, must be greater than 0');
|
||||
} else {
|
||||
$amount = $VAR['amount'];
|
||||
}
|
||||
|
||||
# sweep_type
|
||||
if(@$VAR['sweep_type'] <= 6) {
|
||||
$sweep_type = $VAR['sweep_type'];
|
||||
} else {
|
||||
return $this->api_return(0,'','Invalid value supplied for the \'sweep_type\' parameter, must be 0-6');
|
||||
}
|
||||
|
||||
# account_id OR service_id
|
||||
if(empty($VAR['account_id']) && empty($VAR['service_id'])) {
|
||||
return $this->api_return(0,'','Either the \'account_id\' or \'service_id\' parameter must be provided');
|
||||
} else {
|
||||
|
||||
# check the account id
|
||||
if(!empty($VAR['account_id'])) {
|
||||
$sql = "SELECT * FROM ".AGILE_DB_PREFIX."account WHERE
|
||||
id = " . $db->qstr($VAR['account_id']) . " OR
|
||||
username = " . $db->qstr($VAR['account_id']) . " AND
|
||||
site_id = " . $db->qstr(DEFAULT_SITE);
|
||||
$rs = $db->Execute($sql);
|
||||
if ($rs === false) {
|
||||
global $C_debug;
|
||||
$C_debug->error('charge.inc.php','charge :: api()', $db->ErrorMsg(). "\r\n\r\n". $sql);
|
||||
}
|
||||
if($rs->RecordCount() == 1) {
|
||||
$account_id = $rs->fields['id'];
|
||||
} else {
|
||||
return $this->api_return(0,'','The \'account_id\' value provided does not exist');
|
||||
}
|
||||
|
||||
# check the service id
|
||||
} elseif(!empty($VAR['service_id'])) {
|
||||
$sql = "SELECT id,account_id FROM ".AGILE_DB_PREFIX."service WHERE
|
||||
site_id = " . $db->qstr(DEFAULT_SITE) . " AND
|
||||
id = " . $db->qstr($VAR['service_id']);
|
||||
$rs = $db->Execute($sql);
|
||||
if ($rs === false) {
|
||||
global $C_debug;
|
||||
$C_debug->error('charge.inc.php','charge :: api()', $db->ErrorMsg(). "\r\n\r\n". $sql);
|
||||
}
|
||||
if($rs->RecordCount() == 1) {
|
||||
$service_id = $VAR['service_id'];
|
||||
$account_id = $rs->fields['account_id'];
|
||||
} else {
|
||||
return $this->api_return(0,'','The \'service_id\' value provided does not exist');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# taxable
|
||||
if(empty($VAR['taxable']))
|
||||
$taxable = 0;
|
||||
else
|
||||
$taxable = $VAR['taxable'];
|
||||
|
||||
# attributes
|
||||
if(!empty($VAR['attributes'])) {
|
||||
@$attributes = ereg_replace("@@", "\r\n", $VAR['attributes']);
|
||||
@$attributes = ereg_replace("--", "==", $attributes);
|
||||
} else {
|
||||
$attributes = false;
|
||||
}
|
||||
|
||||
# quantity
|
||||
if(empty($VAR['quantity']))
|
||||
$quantity = 1;
|
||||
else
|
||||
$quantity = $VAR['quantity'];
|
||||
|
||||
# product id
|
||||
if(empty($VAR['product_id'])) {
|
||||
$product_id = false;
|
||||
} else {
|
||||
$product_id = $VAR['product_id'];
|
||||
}
|
||||
|
||||
# description
|
||||
if(empty($VAR['description'])) {
|
||||
$description = false;
|
||||
} else {
|
||||
$description = $VAR['description'];
|
||||
}
|
||||
|
||||
/* Start: SQL Insert Statement */
|
||||
$sql = "SELECT * FROM ".AGILE_DB_PREFIX."charge WHERE id = -1";
|
||||
$rs = $db->Execute($sql);
|
||||
|
||||
$id = $db->GenID(AGILE_DB_PREFIX . 'charge_id');
|
||||
$insert = Array ( 'id' => $id,
|
||||
'site_id' => DEFAULT_SITE,
|
||||
'date_orig' => time(),
|
||||
'status' => 0,
|
||||
'sweep_type' => $sweep_type,
|
||||
'account_id' => @$account_id,
|
||||
'service_id' => @$service_id,
|
||||
'product_id' => @$product_id,
|
||||
'amount' => $amount,
|
||||
'quantity' => $quantity,
|
||||
'taxable' => $taxable,
|
||||
'attributes' => $attributes,
|
||||
'description' => $description );
|
||||
$sql = $db->GetInsertSQL($rs, $insert);
|
||||
$result = $db->Execute($sql);
|
||||
if ($result === false) {
|
||||
global $C_debug;
|
||||
$C_debug->error('charge.inc.php','charge :: api()', $db->ErrorMsg(). "\r\n\r\n". $sql);
|
||||
return $this->api_return(0,'','The SQL insert failed!');
|
||||
} else {
|
||||
return $this->api_return(1,$id,'');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function api_return($status=0,$id='',$error='') {
|
||||
if (! $this->xmlrpc) {
|
||||
echo "status=={$status}++charge_id={$id}++error=={$error}";
|
||||
} else {
|
||||
$arr = array('status'=>$status, 'charge_id'=>$id, 'error'=> $error);
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a record
|
||||
*/
|
||||
public function add($VAR) {
|
||||
if (! empty($VAR['attributes'])) {
|
||||
$attr = '';
|
||||
|
||||
for ($i=0; $i<count($VAR['attributes']); $i++)
|
||||
if (! empty($VAR['attributes'][$i][0]))
|
||||
$attr .= sprintf("%s==%s\r\n",$VAR['attributes'][$i][0],$VAR['attributes'][$i][1]);
|
||||
|
||||
$VAR['charge_attributes'] = $attr;
|
||||
}
|
||||
|
||||
return parent::add($VAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import records
|
||||
*/
|
||||
function import($VAR) {
|
||||
include_once(PATH_CORE.'import.inc.php');
|
||||
$import = new CORE_import;
|
||||
|
||||
if (! empty($VAR['confirm']))
|
||||
$import->do_import($VAR,$this);
|
||||
else
|
||||
$import->prepare_import($VAR,$this);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,143 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<!-- Module name -->
|
||||
<module>charge</module>
|
||||
<!-- Module supporting database table -->
|
||||
<table>charge</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>date_orig</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>
|
||||
<sweep_type>sweep_type,status</sweep_type>
|
||||
<service_id>account_id,service_id</service_id>
|
||||
<sss>site_id,service_id,status</sss>
|
||||
</index>
|
||||
|
||||
<!-- Database fields -->
|
||||
<field>
|
||||
<!-- Record ID -->
|
||||
<id>
|
||||
<index>1</index>
|
||||
<type>I8</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>
|
||||
<!-- Record active (BOOL)-->
|
||||
<status>
|
||||
<display>Processed</display>
|
||||
<index>1</index>
|
||||
<type>L</type>
|
||||
</status>
|
||||
<sweep_type>
|
||||
<display>Charge Schedule</display>
|
||||
<type>I4</type>
|
||||
</sweep_type>
|
||||
<account_id>
|
||||
<asso_table>account</asso_table>
|
||||
<asso_field>username</asso_field>
|
||||
<display>Account</display>
|
||||
<type>I8</type>
|
||||
<validate>any</validate>
|
||||
</account_id>
|
||||
<product_id>
|
||||
<asso_table>product</asso_table>
|
||||
<asso_field>sku</asso_field>
|
||||
<display>Product</display>
|
||||
<type>I4</type>
|
||||
</product_id>
|
||||
<service_id>
|
||||
<display>Service</display>
|
||||
<type>I4</type>
|
||||
<type>I4</type>
|
||||
</service_id>
|
||||
<amount>
|
||||
<display>Amount</display>
|
||||
<type>F</type>
|
||||
<validate>float</validate>
|
||||
</amount>
|
||||
<quantity>
|
||||
<display>Quantity</display>
|
||||
<type>F</type>
|
||||
<validate>float</validate>
|
||||
</quantity>
|
||||
<taxable>
|
||||
<display>Taxable</display>
|
||||
<type>L</type>
|
||||
</taxable>
|
||||
<attributes>
|
||||
<display>Attributes</display>
|
||||
<type>X2</type>
|
||||
</attributes>
|
||||
<description>
|
||||
<display>Description</display>
|
||||
<type>C(32)</type>
|
||||
</description>
|
||||
</field>
|
||||
|
||||
<!-- Methods for this class, and the fields they have access to, if applicable -->
|
||||
<method>
|
||||
<add>status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes,description</add>
|
||||
<delete>id</delete>
|
||||
<update>id,status,sweep_type,amount,quantity,taxable,attributes,description</update>
|
||||
<search_export>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</search_export>
|
||||
<search>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</search>
|
||||
<view>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes,description</view>
|
||||
<export_excel>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</export_excel>
|
||||
<export_xml>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</export_xml>
|
||||
<export_tab>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</export_tab>
|
||||
<export_csv>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</export_csv>
|
||||
<import>id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes</import>
|
||||
</method>
|
||||
|
||||
<!-- Method triggers -->
|
||||
<trigger></trigger>
|
||||
|
||||
<!-- Template page display titles -->
|
||||
<title>
|
||||
</title>
|
||||
|
||||
<!-- Template helpers -->
|
||||
<tpl>
|
||||
<search_show>
|
||||
<checkbox>
|
||||
<field>id</field>
|
||||
<type>checkbox</type>
|
||||
<width>25px</width>
|
||||
</checkbox>
|
||||
<date_orig>
|
||||
<field>date_orig</field>
|
||||
<type>date</type>
|
||||
</date_orig>
|
||||
<account_id>
|
||||
<field>account_id</field>
|
||||
</account_id>
|
||||
<status>
|
||||
<field>status</field>
|
||||
<type>bool</type>
|
||||
</status>
|
||||
<amount>
|
||||
<field>amount</field>
|
||||
<type>currency</type>
|
||||
</amount>
|
||||
</search_show>
|
||||
</tpl>
|
||||
</construct>
|
@@ -1,82 +0,0 @@
|
||||
<?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>invoice</dependancy>
|
||||
<!-- Translated display to use on the tree -->
|
||||
<display>Charges</display>
|
||||
<!-- Display a module in the menu tree -->
|
||||
<menu_display>1</menu_display>
|
||||
<!-- MODULE Name -->
|
||||
<name>charge</name>
|
||||
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
|
||||
<notes><![CDATA[Stores incremental charges to be swept into a new invoice on a specified schedule]]></notes>
|
||||
<!-- MODULE Parent, the parent node in the tree -->
|
||||
<parent>invoice</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>
|
||||
<api>
|
||||
<name>api</name>
|
||||
</api>
|
||||
<export_csv>
|
||||
<name>export_csv</name>
|
||||
</export_csv>
|
||||
<export_excel>
|
||||
<name>export_excel</name>
|
||||
</export_excel>
|
||||
<export_tab>
|
||||
<name>export_tab</name>
|
||||
</export_tab>
|
||||
<export_xml>
|
||||
<name>export_xml</name>
|
||||
</export_xml>
|
||||
<search_export>
|
||||
<name>search_export</name>
|
||||
</search_export>
|
||||
<import>
|
||||
<name>import</name>
|
||||
<page><![CDATA[core:import&module=%%]]></page>
|
||||
<menu_display>1</menu_display>
|
||||
</import>
|
||||
</module_method>
|
||||
</install>
|
@@ -1,84 +0,0 @@
|
||||
<?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/
|
||||
*
|
||||
* @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>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
include_once('../../config.inc.php');
|
||||
require_once(PATH_ADODB . 'adodb.inc.php');
|
||||
require_once(PATH_CORE . 'database.inc.php');
|
||||
require_once(PATH_CORE . 'setup.inc.php');
|
||||
require_once(PATH_CORE . 'vars.inc.php');
|
||||
include_once(PATH_INCLUDES.'xml-rpc/xml-rpc.php');
|
||||
include_once(PATH_MODULES .'charge/charge.inc.php');
|
||||
$C_debug = new CORE_debugger;
|
||||
$C_vars = new CORE_vars;
|
||||
$VAR = $C_vars->f;
|
||||
$C_db = &DB();
|
||||
$C_setup = new CORE_setup;
|
||||
|
||||
class ChargeServer extends IXR_Server {
|
||||
|
||||
var $account_id;
|
||||
var $username;
|
||||
var $password;
|
||||
|
||||
function ChargeServer() {
|
||||
$this->IXR_Server(array(
|
||||
'charge.add' => 'this:add'
|
||||
));
|
||||
}
|
||||
|
||||
function add($args) {
|
||||
$this->username = $args[0];
|
||||
$this->password = $args[1];
|
||||
if(!$this->validate()) return array('status'=>false, 'charge_id'=>false, 'error'=> "Authentication failed");
|
||||
|
||||
@$var['account_id'] = $args[2];
|
||||
@$var['service_id'] = $args[3];
|
||||
@$var['amount'] = $args[4];
|
||||
@$var['sweep_type'] = $args[5];
|
||||
@$var['taxable'] = $args[6];
|
||||
@$var['quantity'] = $args[7];
|
||||
@$var['product_id'] = $args[8];
|
||||
@$var['description'] = $args[9];
|
||||
@$var['attributes'] = $args[10];
|
||||
|
||||
$charge = new charge;
|
||||
$charge->xmlrpc=true;
|
||||
$ret = $charge->api($var, $charge);
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
function validate() {
|
||||
if(empty($this->username) || empty($this->password)) return false;
|
||||
$p=AGILE_DB_PREFIX;
|
||||
$s=DEFAULT_SITE;
|
||||
$db=&DB();
|
||||
$sql = "SELECT DISTINCT A.id,A.username FROM {$p}account as A, {$p}account_group as AG
|
||||
WHERE A.username=".$db->qstr($this->username)." AND A.password=MD5(".$db->qstr($this->password).")
|
||||
AND A.status=1 AND AG.account_id = A.id AND A.site_id={$s} AND AG.site_id={$s}
|
||||
AND AG.group_id in ( SELECT DISTINCT GM.group_id FROM _group_method GM JOIN {$p}module M on (M.name='charge' and M.site_id={$s}) JOIN {$p}module_method MM on (MM.name='api' AND MM.module_id=M.id and MM.site_id={$s}))";
|
||||
$rs=$db->Execute($sql);
|
||||
if(!$rs || !$rs->RecordCount()) return false;
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
$server = new ChargeServer();
|
||||
?>
|
Reference in New Issue
Block a user