Initial Commit of AgileBill Open Source

This commit is contained in:
unknown
2008-11-26 14:50:40 -08:00
parent ae5a0fc25e
commit 02306ccc47
2954 changed files with 410976 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
<?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
*/
# Account Discount Affiliate Plugin
class plgn_aff_ACCOUNT_DISCOUNT
{
########################################################################
## Add new affiliate:
########################################################################
function add($account_id, $affiliate_id)
{
}
########################################################################
## Add an account credit for this affiliate
########################################################################
function commission($total, $affiliate_id, $affiliate_commission_id)
{
global $plgn_aff_MONEYBOOKERS;
### Get the affiliate details:
$db = &DB();
$sql = 'SELECT account_id, plugin_data FROM ' . AGILE_DB_PREFIX . 'affiliate
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($affiliate_id);
$aff = $db->Execute($sql);
$account_id = $aff->fields['account_id'];
### Check that this account has not already been credited for this commission id:
$AFFCOM = $affiliate_id.'-'.$affiliate_commission_id;
$sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'discount WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
name = ' . $db->qstr($AFFCOM);
$check = $db->Execute($sql);
if($check->RecordCount() > 0) return;
### Add the credit to this affiliates account:
$id = $db->GenID(AGILE_DB_PREFIX . 'invoice_id');
$sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'discount
SET
id = '. $db->qstr($id) . ',
site_id = '. $db->qstr(DEFAULT_SITE) . ',
date_orig = '. $db->qstr(time()) . ',
date_start = '. $db->qstr(time()) . ',
status = '. $db->qstr('1') . ',
name = '. $db->qstr($AFFCOM) . ',
notes = '. $db->qstr("Affiliate Commission ID $affiliate_commission_id, $affiliate_id") . ',
max_usage_account = '. $db->qstr("1") . ',
avail_account_id = '. $db->qstr($account_id) . ',
new_status = '. $db->qstr("1") . ',
new_type = '. $db->qstr("1") . ',
new_rate = '. $db->qstr($total) . ',
new_max_discount = '. $db->qstr($total) . ',
new_min_cost = '. $db->qstr($total) . ',
recurr_status = '. $db->qstr("1") . ',
recurr_type = '. $db->qstr("1") . ',
recurr_rate = '. $db->qstr($total) . ',
recurr_max_discount = '. $db->qstr($total) . ',
recurr_min_cost = '. $db->qstr($total);
$check = $db->Execute($sql);
}
########################################################################
## Create the header for the affiliate export file
########################################################################
function header()
{
echo "<BR><CENTER>The discounts have been added to the affiliates accounts.</CENTER>";
}
}
?>

View File

@@ -0,0 +1,108 @@
<?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
*/
/*
We need the following to export for check writing: (cvs)
----------------------------------------------------------------
payee,address,city,state,zip,e-mail,amount,reference no
----------------------------------------------------------------
*/
class plgn_aff_MAIL_CHECK
{
########################################################################
## Add new affiliate:
########################################################################
function add($account_id, $affiliate_id)
{
$db = &DB();
$sql = 'SELECT email,first_name,middle_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($account_id);
$result = $db->Execute($sql);
if($result->RecordCount() > 0)
{
# $plugin_data["address"]= $result->fields['address'];
# $plugin_data["city"] = $result->fields['city'];
# $plugin_data["state"] = $result->fields['state'];
# $plugin_data["zip"] = $result->fields['zip'];
$plugin_data["payee"] = $result->fields['first_name'] . ' ' . $result->fields['middle_name'] . ' ' . $result->fields['last_name'];
$plugin_data["email"] = $result->fields['email'];
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'affiliate SET
plugin_data = '. $db->qstr(serialize($plugin_data)) . '
WHERE
site_id = '. $db->qstr(DEFAULT_SITE) . ' AND
id = '. $db->qstr($affiliate_id);
$result = $db->Execute($sql);
}
}
########################################################################
## Create the line in the export commission file for this affiliate
########################################################################
function commission($total, $affiliate_id, $affiliate_commission_id)
{
### Get the affiliate details:
$db = &DB();
$sql = 'SELECT plugin_data FROM ' . AGILE_DB_PREFIX . 'affiliate
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($affiliate_id);
$aff = $db->Execute($sql);
$plugin_data = unserialize($aff->fields['plugin_data']);
### Generate this line for the export:
$ret = $plugin_data["payee"] . ',';
$ret .= $plugin_data["address"] . ',';
$ret .= $plugin_data["city"] . ',';
$ret .= $plugin_data["state"] . ',';
$ret .= $plugin_data["zip"] . ',';
$ret .= $plugin_data["email"] . ',';
$ret .= $total . ',';
$ret .= 'Affiliate Commission ' .$affiliate_commission_id .' for '.$affiliate_id;
$ret .= '
';
### Return the generated line:
return $ret;
}
########################################################################
## Create the header for the affiliate export file
########################################################################
function header()
{
$filename = 'Affiliate_Commission_CSV.csv';
header ('Content-type: application/x-csv');
header ("Content-Disposition: inline; filename=$filename" );
}
}
?>

View File

@@ -0,0 +1,88 @@
<?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
*/
# MoneyBookers Affiliate Plugin
class plgn_aff_MONEYBOOKERS
{
########################################################################
## Add new affiliate:
########################################################################
function add($account_id, $affiliate_id)
{
$db = &DB();
$sql = 'SELECT email FROM ' . AGILE_DB_PREFIX . 'account WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($account_id);
$result = $db->Execute($sql);
if($result->RecordCount() > 0)
{
$plugin_data["email"] = $result->fields['email'];
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'affiliate SET
plugin_data = '. $db->qstr(serialize($plugin_data)) . '
WHERE
site_id = '. $db->qstr(DEFAULT_SITE) . ' AND
id = '. $db->qstr($affiliate_id);
$result = $db->Execute($sql);
}
}
########################################################################
## Create the line in the export commission file for this affiliate
########################################################################
function commission($total, $affiliate_id, $affiliate_commission_id)
{
global $plgn_aff_MONEYBOOKERS;
### Get the affiliate details:
$db = &DB();
$sql = 'SELECT plugin_data FROM ' . AGILE_DB_PREFIX . 'affiliate
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($affiliate_id);
$aff = $db->Execute($sql);
$plugin_data = unserialize($aff->fields['plugin_data']);
### Generate this line for the export:
$ret = $plugin_data["email"] . ' ';
$ret .= 'USD ';
$ret .= $total . ' ';
$ret .= "Affiliate Commission " . $affiliate_commission_id . " for ".$affiliate_id;
$ret .= '
';
### Return the generated line:
return $ret;
}
########################################################################
## Create the header for the affiliate export file
########################################################################
function header()
{
$filename = 'MoneyBookers_Affiliate_Mass_Payment.txt';
header ('Content-type: application/x-txt');
header ("Content-Disposition: inline; filename=$filename" );
}
}
?>

View File

@@ -0,0 +1,89 @@
<?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
*/
# Paypal Affiliate Plugin
class plgn_aff_PAYPAL
{
########################################################################
## Add new affiliate:
########################################################################
function add($account_id, $affiliate_id)
{
$db = &DB();
$sql = 'SELECT email FROM ' . AGILE_DB_PREFIX . 'account WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($account_id);
$result = $db->Execute($sql);
if($result->RecordCount() > 0)
{
$plugin_data["email"] = $result->fields['email'];
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'affiliate SET
plugin_data = '. $db->qstr(serialize($plugin_data)) . '
WHERE
site_id = '. $db->qstr(DEFAULT_SITE) . ' AND
id = '. $db->qstr($affiliate_id);
$result = $db->Execute($sql);
}
}
########################################################################
## Create the line in the export commission file for this affiliate
########################################################################
function commission($total, $affiliate_id, $affiliate_commission_id)
{
### Get the affiliate details:
$db = &DB();
$sql = 'SELECT plugin_data FROM ' . AGILE_DB_PREFIX . 'affiliate
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($affiliate_id);
$aff = $db->Execute($sql);
$plugin_data = unserialize($aff->fields['plugin_data']);
### Generate this line for the export:
$ret = $plugin_data["email"] . ' ';
$ret .= $total . ' ';
$ret .= "Affiliate Commission Id. " . $affiliate_commission_id . ' ';
$ret .= $affiliate_id;
$ret .= '
';
### Return the generated line:
return $ret;
}
########################################################################
## Create the header for the affiliate export file
########################################################################
function header()
{
$filename = 'Paypal_Affiliate_Mass_Payment.txt';
header ('Content-type: application/x-txt');
header ("Content-Disposition: inline; filename=$filename" );
}
}
?>