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

@@ -6,49 +6,24 @@
* 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/
* 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>
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @version 1.4.93
*/
class campaign
{
# Open the constructor for this mod
function campaign()
{
# name of this module:
$this->module = "campaign";
# location of the construct XML file:
$this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml";
# open the construct file for parsing
$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"];
}
class campaign extends OSB_module {
##############################
## CLICK ##
##############################
function click($VAR)
{
{
### Set the forward URL
if(!empty($VAR['caid']))
{
@@ -56,9 +31,9 @@ class campaign
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['caid']);
$result = $db->Execute($sql);
$result = $db->Execute($sql);
if (strlen($result->fields['url']) >= 1) $url = $result->fields['url'];
}
}
if(empty($url)) $url = URL;
echo '<script language="JavaScript"> <!-- START
@@ -136,7 +111,7 @@ class campaign
##############################
## ADD ##
##############################
function add($VAR)
function xadd($VAR)
{
global $_FILES;
@@ -145,14 +120,14 @@ class campaign
for($i=1; $i<=12; $i++) {
if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) {
$VAR['campaign_type'.$i] = $_FILES['upload_file'.$i]['type'];
$VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name'];
}
$VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name'];
}
}
## Attempt to add the record:
## Attempt to add the record:
$type = "add";
$this->method["$type"] = explode(",", $this->method["$type"]);
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$campaign_id = $db->add($VAR, $this, $type);
@@ -165,173 +140,162 @@ class campaign
if(!copy($_FILES['upload_file'.$i]['tmp_name'], PATH_FILES . 'campaign_'.$campaign_id.'_'.$i.'.dat'))
{
### ERROR:
}
}
#unlink any temp files
unlink($_FILES['upload_file'.$i]['tmp_name']);
}
}
}
}
}
}
/**
* View a record
*/
public function view($VAR) {
$smart = parent::view($VAR);
##############################
## VIEW ##
##############################
function view($VAR)
{
$type = "view";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$smart = $db->view($VAR, $this, $type);
# Get the stats for each advertisement:
$budget = $smart['budget'];
#print_r($smart);
for($i=0;$i<count($smart); $i++)
{
# Get the stats for each advertisement:
$budget = $smart[$i]['budget'];
# Total Impressions, Total Clicks, & Accounts referred
$smart['impressions_total'] = 0;
$smart['clicks_total'] = 0;
$smart['accounts_referred'] = $this->referred_accounts($smart['id']);
# Total Impressions, Total Clicks, & Accounts referred
$smart[$i]['impressions_total'] = 0;
$smart[$i]['clicks_total'] = 0;
$smart[$i]['accounts_referred'] = $this->referred_accounts($smart[$i]['id']);
# Invoices referred
$inv = $this->referred_invoices($smart['id']);
$smart['invoices_referred'] = $inv[0];
$smart['invoices_revenue'] = round($inv[1],2);
# Invoices referred
$inv = $this->referred_invoices($smart[$i]['id']);
$smart[$i]['invoices_referred'] = $inv[0];
$smart[$i]['invoices_revenue'] = round( $inv[1], 2);
# Total impressions & clicks:
$impressions_total = 0;
$clicks_total = 0;
# total impressions & clicks:
$impressions_total=0;
$clicks_total=0;
for($ii=1; $ii<=12; $ii++)
{
$impressions_total += $smart[$i]["served".$ii];
$clicks_total += $smart[$i]["clicked".$ii];
for ($ii=1; $ii<=12; $ii++) {
$smart['results'][$ii]['served'] = $smart['served'.$ii];
$smart['results'][$ii]['clicked'] = $smart['clicked'.$ii];
$smart['results'][$ii]['file'] = $smart['file'.$ii];
if(empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]))
$smart[$i]["show".$ii] = false;
else
$smart[$i]["show".$ii] = true;
}
$smart[$i]['impressions_total'] = $impressions_total;
$smart[$i]['clicks_total'] = $clicks_total;
$impressions_total += $smart['results'][$ii]['served'];
$clicks_total += $smart['results'][$ii]['clicked'];
if (empty($smart['results'][$ii]['served']))
$smart['results'][$ii]['show'] = false;
else
$smart['results'][$ii]['show'] = true;
}
# Impr. percentage, Clicks percentage, CTR
$ctr_count = 0;
$ctr_amt = 0;
for($ii=1; $ii<=12; $ii++)
{
# Impr. percentage
if( $smart[$i]["show".$ii] )
{
$impressions_percentage = $smart[$i]["served".$ii] / $impressions_total;
$smart[$i]['impressions_percentage'.$ii] = "(".round($impressions_percentage*100)."%)";
} else {
$smart[$i]['impressions_percentage'.$ii] = '';
}
$smart['impressions_total'] = $impressions_total;
$smart['clicks_total'] = $clicks_total;
# Impr. percentage, Clicks percentage, CTR
$ctr_count = 0;
$ctr_amt = 0;
for ($ii=1; $ii<=12; $ii++) {
if ($smart['results'][$ii]['show']) {
# Impression percentage
$impressions_percentage = $smart['results'][$ii]['served']/$impressions_total;
$smart['results'][$ii]['impressions_percentage'] = sprintf('(%s%%)',round($impressions_percentage*100));
# Clicks percentage
if( $smart[$i]["show".$ii] ) {
@$clicks_percentage = ($smart[$i]["clicked".$ii] / $clicks_total);
$smart[$i]['clicks_percentage'.$ii] = "(".round($clicks_percentage*100)."%)";
} else {
$smart[$i]['clicks_percentage'.$ii] = '';
}
$clicks_percentage = $smart['results'][$ii]['clicked']/$clicks_total;
$smart['results'][$ii]['clicks_percentage'] = sprintf('(%s%%)',round($clicks_percentage*100));
# Cost
if( $smart[$i]["show".$ii] ) {
$impressions_percentage = $smart[$i]["served".$ii] / $impressions_total;
$smart[$i]['cost'.$ii] = round($budget * $impressions_percentage, 2);
} else {
$smart[$i]['cost'.$ii] = "0";
}
$impressions_percentage = $smart['results'][$ii]['served']/$impressions_total;
$smart['results'][$ii]['cost'] = round($budget*$impressions_percentage,2);
# CTR
if( $smart[$i]["show".$ii] ) {
$ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100;
if($ctr < 0)
$smart[$i]['ctr'.$ii] = round($ctr).'%';
else
$smart[$i]['ctr'.$ii] = round($ctr,1).'%';
$ctr_count++;
$ctr_amt += $ctr;
} else {
$smart[$i]['ctr'.$ii] = "0%";
$ctr_count++;
}
$ctr = ($smart['results'][$ii]['clicked']/$smart['results'][$ii]['served'])*100;
if ($ctr < 0)
$smart['results'][$ii]['ctr'] = round($ctr).'%';
else
$smart['results'][$ii]['ctr'] = round($ctr,1).'%';
$ctr_amt += $ctr;
} else {
$smart['results'][$ii]['impressions_percentage'] = '';
$smart['results'][$ii]['clicks_percentage'] = '';
$smart['results'][$ii]['cost'] = 0;
$smart['results'][$ii]['ctr'] = '0%';
}
$ctr_count++;
}
# CTR Avg:
if($ctr_count > 0)
$smart[$i]['ctr_avg'] = round( $ctr_amt / $ctr_count, 2) .'%';
else
$smart[$i]['ctr_avg'] = "0%";
# CTR Avg:
if ($ctr_count > 0)
$smart['ctr_avg'] = round($ctr_amt/$ctr_count,2).'%';
else
$smart['ctr_avg'] = '0%';
# CPC Avg:
if ($clicks_total > 0) {
$cpc_avg = $budget / $clicks_total;
# CPC Avg:
if($clicks_total > 0) {
$cpc_avg = $budget / $clicks_total;
if($cpc_avg < .1)
$smart[$i]['cpc_avg'] = round($cpc_avg,3);
else
$smart[$i]['cpc_avg'] = round($cpc_avg,2);
} else {
$smart[$i]['cpc_avg'] = 0;
}
# CPI Avg:
if($impressions_total > 0) {
$cpi_avg = $budget / $impressions_total;
if($cpi_avg < .1)
$smart[$i]['cpi_avg'] = round($cpi_avg,3);
else
$smart[$i]['cpi_avg'] = round($cpi_avg,2);
} else {
$smart[$i]['cpi_avg'] = 0;
}
# Cost per Conversion:
if($inv[0] > 0)
$smart[$i]['conversion_cost'] = round($budget / $inv[0], 2);
if ($cpc_avg < .1)
$smart['cpc_avg'] = round($cpc_avg,3);
else
$smart[$i]['conversion_cost'] = 0;
$smart['cpc_avg'] = round($cpc_avg,2);
} else {
$smart['cpc_avg'] = 0;
}
# Avg sales amount:
if($inv[0] > 0 && $budget > 0)
$smart[$i]['invoice_avg'] = round($inv[1] / $inv[0], 2);
else
$smart[$i]['invoice_avg'] = 0;
# CPI Avg:
if ($impressions_total > 0) {
$cpi_avg = $budget / $impressions_total;
# ROI
if($inv[0] > 0 && $budget > 0)
$smart[$i]['roi'] = round(($inv[1] / $budget) * 100).'%';
else
$smart[$i]['roi'] = '---';
if ($cpi_avg < .1)
$smart['cpi_avg'] = round($cpi_avg,3);
else
$smart['cpi_avg'] = round($cpi_avg,2);
# Impression to Buy Ratio
if($inv[0] > 0 && $impressions_total > 0) {
$ratio = round($impressions_total / $inv[0]);
$percent = round( ($inv[0] / $impressions_total) * 100, 3);
$smart[$i]['impr_to_buy'] = $ratio . ' / 1 &nbsp;&nbsp; ('.$percent.'%)';
} else {
$smart[$i]['impr_to_buy'] = '---';
}
} else {
$smart['cpi_avg'] = 0;
}
# Click-thru to Buy ratio
if($inv[0] > 0 && $clicks_total > 0) {
$ratio = round($clicks_total / $inv[0]);
$percent = round( ($inv[0] / $clicks_total) * 100, 2);
$smart[$i]['click_to_buy'] = $ratio . ' / 1 &nbsp;&nbsp; ('.$percent.'%)';
} else {
$smart[$i]['click_to_buy'] = '---';
}
# Cost per Conversion:
if ($inv[0] > 0)
$smart['conversion_cost'] = round($budget/$inv[0],2);
else
$smart['conversion_cost'] = 0;
# Avg sales amount:
if($inv[0] > 0 && $budget > 0)
$smart['invoice_avg'] = round($inv[1]/$inv[0],2);
else
$smart['invoice_avg'] = 0;
# ROI
if ($inv[0] > 0 && $budget > 0)
$smart['roi'] = round(($inv[1]/$budget)*100).'%';
else
$smart['roi'] = '---';
# Impression to Buy Ratio
if($inv[0] > 0 && $impressions_total > 0) {
$ratio = round($impressions_total/$inv[0]);
$percent = round(($inv[0]/$impressions_total)*100,3);
$smart['impr_to_buy'] = sprintf('%s / 1 (%s)%%',$ratio,$percent);
} else {
$smart['impr_to_buy'] = '---';
}
# Click-thru to Buy ratio
if ($inv[0] > 0 && $clicks_total > 0) {
$ratio = round($clicks_total/$inv[0]);
$percent = round(($inv[0]/$clicks_total)*100,2);
$smart['click_to_buy'] = sprintf('%s / 1 (%s)%%',$ratio,$percent);
} else {
$smart['click_to_buy'] = '---';
}
global $smarty;
$smarty->assign('campaign', $smart);
}
$smarty->assign('record',$smart);
}
### Get the number of referred accounts:
function referred_accounts ($id) {
@@ -358,18 +322,18 @@ class campaign
}
}
return Array($rs->RecordCount(), $total);
}
}
##############################
## AFFILIATE VIEW ##
##############################
function affiliate($VAR)
{
{
$type = "view";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->view($VAR, $this, $type);
}
}
##############################
## UPDATE ##
@@ -380,8 +344,8 @@ class campaign
for($i=1; $i<=12; $i++) {
if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) {
$VAR['campaign_type'.$i] = $_FILES['upload_file'.$i]['type'];
$VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name'];
}
$VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name'];
}
}
# Store the record
@@ -401,14 +365,14 @@ class campaign
}
}
}
}
}
}
##############################
## DELETE ADDs ##
##############################
function delete_add($VAR)
{
{
$field = 'file'.$VAR['file'];
$db = &DB();
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign
@@ -436,7 +400,7 @@ class campaign
## DELETE ##
##############################
function delete($VAR)
{
{
$db = &DB();
$id = $this->table . '_id';
@@ -458,7 +422,7 @@ class campaign
if($id[$i] != '')
{
if($i == 0)
{
{
$id_list .= " id = " . $db->qstr($id[$i]) . " ";
$ii++;
}
@@ -466,8 +430,8 @@ class campaign
{
$id_list .= " OR id = " . $db->qstr($id[$i]) . " ";
$ii++;
}
}
}
}
}
@@ -488,7 +452,7 @@ class campaign
if ($result === false)
{
global $C_debug;
$C_debug->error('campaign.inc.php','delete', $db->ErrorMsg());
$C_debug->error('campaign.inc.php','delete', $db->ErrorMsg());
}
else
{
@@ -498,100 +462,70 @@ class campaign
{
error_reporting(0);
for($ii=1; $ii<=12; $ii++)
unlink(PATH_FILES . 'campaign_'.$id[$i].'_'.$ii.'.dat');
for($ii=1; $ii<=12; $ii++)
unlink(PATH_FILES . 'campaign_'.$id[$i].'_'.$ii.'.dat');
# Restore the proper error level
$error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');';
eval($error_reporting_eval);
}
}
eval($error_reporting_eval);
}
}
# Alert delete message
global $C_debug, $C_translate;
$C_translate->value["CORE"]["module_name"] = $C_translate->translate('name',$this->module,"");
$message = $C_translate->translate('alert_delete_ids',"CORE","");
$C_debug->alert($message);
$C_debug->alert($message);
}
}
}
##############################
## SEARCH FORM ##
##############################
function search_form($VAR)
{
$type = "search";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->search_form($VAR, $this, $type);
}
##############################
## SEARCH ##
##############################
function search($VAR)
{
$type = "search";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$db->search($VAR, $this, $type);
}
}
}
##############################
## SEARCH SHOW ##
##############################
function search_show($VAR) {
$smart = parent::search_show($VAR);
function search_show($VAR)
{
$type = "search";
$this->method["$type"] = explode(",", $this->method["$type"]);
$db = new CORE_database;
$smart = $db->search_show($VAR, $this, $type);
for($i=0; $i<count($smart); $i++)
{
for($i=0; $i<count($smart); $i++) {
# Get the stats for each advertisement:
$budget = $smart[$i]['budget'];
$budget = $smart[$i]['budget'];
# Invoices referred
$inv = $this->referred_invoices($smart[$i]['id']);
$smart[$i]['invoices_referred'] = $inv[0];
$inv = $this->referred_invoices($smart[$i]['id']);
$smart[$i]['invoices_referred'] = $inv[0];
$smart[$i]['invoices_revenue'] = $inv[1];
@$smart[$i]['invoice_avg'] = $inv[1] / $inv[0];
@$smart[$i]['invoice_avg'] = $inv[1] / $inv[0];
# total impressions & clicks:
$impressions_total=0;
$clicks_total=0;
for($ii=1; $ii<=12; $ii++)
{
$impressions_total += $smart[$i]["served".$ii];
$clicks_total += $smart[$i]["clicked".$ii];
{
$impressions_total += $smart[$i]["served".$ii];
$clicks_total += $smart[$i]["clicked".$ii];
if(empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]))
$smart[$i]["show".$ii] = false;
else
$smart[$i]["show".$ii] = true;
$smart[$i]["show".$ii] = true;
}
$smart[$i]['impressions_total'] = $impressions_total;
$smart[$i]['clicks_total'] = $clicks_total;
# Impr. percentage, Clicks percentage, CTR
$ctr_count = 0;
$ctr_amt = 0;
# Impr. percentage, Clicks percentage, CTR
$ctr_count = 0;
$ctr_amt = 0;
for($ii=1; $ii<=12; $ii++)
{
{
# CTR
if( $smart[$i]["show".$ii] ) {
$ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100;
$ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100;
if($ctr < 0)
$smart[$i]['ctr'.$ii] = round($ctr).'%';
else
else
$smart[$i]['ctr'.$ii] = round($ctr,1).'%';
$ctr_count++;
$ctr_amt += $ctr;
@@ -604,7 +538,7 @@ class campaign
# CTR Avg:
if($ctr_count > 0)
$smart[$i]['ctr_avg'] = round( $ctr_amt / $ctr_count, 2) .'%';
else
else
$smart[$i]['ctr_avg'] = "0%";
@@ -613,7 +547,7 @@ class campaign
$cpc_avg = $budget / $clicks_total;
if($cpc_avg < .1)
$smart[$i]['cpc_avg'] = round($cpc_avg,3);
else
else
$smart[$i]['cpc_avg'] = round($cpc_avg,2);
} else {
$smart[$i]['cpc_avg'] = 0;
@@ -640,20 +574,19 @@ class campaign
if($inv[0] > 0 && $budget > 0)
$smart[$i]['roi'] = round(($inv[1] / $budget) * 100).'%';
else
$smart[$i]['roi'] = '---';
$smart[$i]['roi'] = '---';
}
global $smarty;
$smarty->assign('campaign', $smart);
$smarty->assign('search_show',$smart);
}
}
##############################
## SEARCH EXPORT ##
##############################
##############################
function search_export($VAR)
{
# require the export class
# require the export class
require_once (PATH_CORE . "export.inc.php");
# Call the correct export function for inline browser display, download, email, or web save.
@@ -662,7 +595,7 @@ class campaign
$type = "export_excel";
$this->method["$type"] = explode(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_excel($VAR, $this, $type);
$export->search_excel($VAR, $this, $type);
}
else if ($VAR["format"] == "pdf")
@@ -670,7 +603,7 @@ class campaign
$type = "export_pdf";
$this->method["$type"] = explode(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_pdf($VAR, $this, $type);
$export->search_pdf($VAR, $this, $type);
}
else if ($VAR["format"] == "xml")
@@ -695,7 +628,7 @@ class campaign
$this->method["$type"] = explode(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_tab($VAR, $this, $type);
}
}
}
}
}
?>
?>

View File

@@ -1,233 +1,299 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- define the module name -->
<module>campaign</module>
<!-- define the module table name -->
<table>campaign</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>name</order_by>
<!-- define the methods -->
<limit>25</limit>
<!-- 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-now</convert>
</date_orig>
<date_last>
<type>I8</type>
<convert>date-now</convert>
</date_last>
<date_start>
<type>C(16)</type>
<convert>date</convert>
</date_start>
<date_expire>
<type>C(16)</type>
<convert>date</convert>
</date_expire>
<status>
<type>L</type>
<pdf_width>30</pdf_width>
</status>
<name>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
<unique>1</unique>
<pdf_width>30</pdf_width>
</name>
<description>
<type>X2</type>
</description>
<budget>
<type>F</type>
<pdf_width>30</pdf_width>
</budget>
<target_conversion>
<type>F</type>
<pdf_width>30</pdf_width>
</target_conversion>
<file1>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
</file1>
<type1>
<type>C(128)</type>
</type1>
<served1>
<type>I4</type>
</served1>
<clicked1>
<type>I4</type>
</clicked1>
<file2>
<type>C(128)</type>
</file2>
<type2>
<type>C(128)</type>
</type2>
<served2>
<type>I4</type>
</served2>
<clicked2>
<type>I4</type>
</clicked2>
<file3>
<type>C(128)</type>
</file3>
<type3>
<type>C(128)</type>
</type3>
<served3>
<type>I4</type>
</served3>
<clicked3>
<type>I4</type>
</clicked3>
<file4>
<type>C(128)</type>
</file4>
<type4>
<type>C(128)</type>
</type4>
<served4>
<type>I4</type>
</served4>
<clicked4>
<type>I4</type>
</clicked4>
<file5>
<type>C(128)</type>
</file5>
<type5>
<type>C(128)</type>
</type5>
<served5>
<type>I4</type>
</served5>
<clicked5>
<type>I4</type>
</clicked5>
<file6>
<type>C(128)</type>
</file6>
<type6>
<type>C(128)</type>
</type6>
<served6>
<type>I4</type>
</served6>
<clicked6>
<type>I4</type>
</clicked6>
<file7>
<type>C(128)</type>
</file7>
<type7>
<type>C(128)</type>
</type7>
<served7>
<type>I4</type>
</served7>
<clicked7>
<type>I4</type>
</clicked7>
<file8>
<type>C(128)</type>
</file8>
<type8>
<type>C(128)</type>
</type8>
<served8>
<type>I4</type>
</served8>
<clicked8>
<type>I4</type>
</clicked8>
<file9>
<type>C(128)</type>
</file9>
<type9>
<type>C(128)</type>
</type9>
<served9>
<type>I4</type>
</served9>
<clicked9>
<type>I4</type>
</clicked9>
<file10>
<type>C(128)</type>
</file10>
<type10>
<type>C(128)</type>
</type10>
<served10>
<type>I4</type>
</served10>
<clicked10>
<type>I4</type>
</clicked10>
<file11>
<type>C(128)</type>
</file11>
<type11>
<type>C(128)</type>
</type11>
<served11>
<type>I4</type>
</served11>
<clicked11>
<type>I4</type>
</clicked11>
<file12>
<type>C(128)</type>
</file12>
<type12>
<type>C(128)</type>
</type12>
<served12>
<type>I4</type>
</served12>
<clicked12>
<type>I4</type>
</clicked12>
<last_served>
<type>I4</type>
</last_served>
<url>
<type>C(128)</type>
</url>
</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,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</add>
<update>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</update>
<delete>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</delete>
<view>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</view>
<search>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</search>
<export_excel>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_excel>
<export_xml>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_xml>
<export_csv>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_csv>
<export_tab>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_tab>
</method>
<!-- define the method triggers -->
<trigger>0</trigger>
<!-- Module name -->
<module>campaign</module>
<!-- Module supporting database table -->
<table>campaign</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>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>0</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>
<pdf_width>30</pdf_width>
<type>L</type>
</status>
<date_start>
<type>C(16)</type>
<convert>date</convert>
</date_start>
<date_expire>
<type>C(16)</type>
<convert>date</convert>
</date_expire>
<name>
<display>Name</display>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
<unique>1</unique>
<pdf_width>30</pdf_width>
</name>
<description>
<type>X2</type>
</description>
<budget>
<type>F</type>
<pdf_width>30</pdf_width>
</budget>
<target_conversion>
<type>F</type>
<pdf_width>30</pdf_width>
</target_conversion>
<file1>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
</file1>
<type1>
<type>C(128)</type>
</type1>
<served1>
<type>I4</type>
</served1>
<clicked1>
<type>I4</type>
</clicked1>
<file2>
<type>C(128)</type>
</file2>
<type2>
<type>C(128)</type>
</type2>
<served2>
<type>I4</type>
</served2>
<clicked2>
<type>I4</type>
</clicked2>
<file3>
<type>C(128)</type>
</file3>
<type3>
<type>C(128)</type>
</type3>
<served3>
<type>I4</type>
</served3>
<clicked3>
<type>I4</type>
</clicked3>
<file4>
<type>C(128)</type>
</file4>
<type4>
<type>C(128)</type>
</type4>
<served4>
<type>I4</type>
</served4>
<clicked4>
<type>I4</type>
</clicked4>
<file5>
<type>C(128)</type>
</file5>
<type5>
<type>C(128)</type>
</type5>
<served5>
<type>I4</type>
</served5>
<clicked5>
<type>I4</type>
</clicked5>
<file6>
<type>C(128)</type>
</file6>
<type6>
<type>C(128)</type>
</type6>
<served6>
<type>I4</type>
</served6>
<clicked6>
<type>I4</type>
</clicked6>
<file7>
<type>C(128)</type>
</file7>
<type7>
<type>C(128)</type>
</type7>
<served7>
<type>I4</type>
</served7>
<clicked7>
<type>I4</type>
</clicked7>
<file8>
<type>C(128)</type>
</file8>
<type8>
<type>C(128)</type>
</type8>
<served8>
<type>I4</type>
</served8>
<clicked8>
<type>I4</type>
</clicked8>
<file9>
<type>C(128)</type>
</file9>
<type9>
<type>C(128)</type>
</type9>
<served9>
<type>I4</type>
</served9>
<clicked9>
<type>I4</type>
</clicked9>
<file10>
<type>C(128)</type>
</file10>
<type10>
<type>C(128)</type>
</type10>
<served10>
<type>I4</type>
</served10>
<clicked10>
<type>I4</type>
</clicked10>
<file11>
<type>C(128)</type>
</file11>
<type11>
<type>C(128)</type>
</type11>
<served11>
<type>I4</type>
</served11>
<clicked11>
<type>I4</type>
</clicked11>
<file12>
<type>C(128)</type>
</file12>
<type12>
<type>C(128)</type>
</type12>
<served12>
<type>I4</type>
</served12>
<clicked12>
<type>I4</type>
</clicked12>
<last_served>
<type>I4</type>
</last_served>
<url>
<type>C(128)</type>
</url>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>date_start,date_expire,status,name,description,budget,url</add>
<update>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</update>
<delete>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</delete>
<view>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</view>
<search>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</search>
<export_excel>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_excel>
<export_xml>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_xml>
<export_csv>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_csv>
<export_tab>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_tab>
</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>
<name>
<field>name</field>
</name>
<cost>
<field>cost</field>
</cost>
<impressions>
<field>impressions</field>
</impressions>
<clicks>
<field>clicks</field>
</clicks>
<cpc>
<field>cpc</field>
</cpc>
<cpi>
<field>cpi</field>
</cpi>
<conversion>
<field>conversion</field>
</conversion>
<cost_conv>
<field>cost_conv</field>
</cost_conv>
<roi_s>
<field>roi_s</field>
</roi_s>
<avg_sale_s>
<field>avg_sale_s</field>
</avg_sale_s>
<revenue>
<field>revenue</field>
</revenue>
</search_show>
</tpl>
</construct>

View File

@@ -1,60 +1,78 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<name>campaign</name>
<parent>affiliate</parent>
<notes><![CDATA[The campaign module enables you to setup campaings to serve up your advertisements.]]></notes>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Campaigns</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>campaign</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[The campaign module enables you to setup campaings to serve up your advertisements.]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>affiliate</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>
<add>
<name>add</name>
<page><![CDATA[%%:add]]></page>
<menu_display>1</menu_display>
</add>
<update>
<name>update</name>
</update>
<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>
<search>
<name>search</name>
<page><![CDATA[%%:search_form]]></page>
<menu_display>1</menu_display>
</search>
<search_form>
<name>search_form</name>
<notes><![CDATA[Allow users to view the search form]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Allow users to view the search results]]></notes>
</search_show>
<delete_add>
<name>delete_add</name>
<notes><![CDATA[Delete a specific add in a campaign from rotation]]></notes>
</delete_add>
<search_export>
<name>search_export</name>
</search_export>
<export_excel>
<name>export_excel</name>
</export_excel>
<export_pdf>
<name>export_pdf</name>
</export_pdf>
<export_csv>
<name>export_csv</name>
</export_csv>
<export_tab>
<name>export_tab</name>
</export_tab>
</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>
<delete_add>
<name>delete_add</name>
<notes><![CDATA[Delete a specific add in a campaign from rotation]]></notes>
</delete_add>
<search_export>
<name>search_export</name>
</search_export>
<export_excel>
<name>export_excel</name>
</export_excel>
<export_pdf>
<name>export_pdf</name>
</export_pdf>
<export_csv>
<name>export_csv</name>
</export_csv>
<export_tab>
<name>export_tab</name>
</export_tab>
</module_method>
</install>

View File

@@ -1,97 +1,102 @@
<?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 Module:Campaign
*/
ob_start();
# Required includes:
/**
* The main AgileBill Campaign Class
*
* @package AgileBill
* @subpackage Module:Campaign
*/
ob_start();
# Required includes:
require_once('../../config.inc.php');
require_once(PATH_ADODB . 'adodb.inc.php');
require_once(PATH_CORE . 'database.inc.php');
require_once(PATH_CORE . 'vars.inc.php');
require_once(PATH_ADODB.'adodb.inc.php');
require_once(PATH_CORE.'database.inc.php');
require_once(PATH_CORE.'vars.inc.php');
$C_debug = new CORE_debugger;
$C_vars = new CORE_vars;
$VAR = $C_vars->f;
$C_debug = new CORE_debugger;
$C_vars = new CORE_vars;
$VAR = $C_vars->f;
if (! isset($VAR['id']))
exit;
$db = &DB();
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['id']);
$result = $db->Execute($sql);
$db = &DB();
$result = $db->Execute(sqlSelect($db,'campaign','*',array('id'=>$VAR['id'])));
if( !empty($VAR['file']) ) {
if (! $result || ! $result->RecordCount())
exit;
if ($VAR['file']) {
$file_no = $VAR['file'];
}
else
{
# random file:
$last = $result->fields['last_served'];
if(empty($last)) $last = 1;
$next = false;
for($i=1; $i<=12; $i++) {
if(!empty($result->fields["file".$i]) && !$next) {
if($i == $last)
} else {
# Random file:
$last = $result->fields['last_served'];
if (empty($last))
$last = 1;
$next = false;
for ($i=1; $i<=12; $i++) {
if (! empty($result->fields['file'.$i]) && ! $next) {
if ($i == $last)
$next = true;
} else if(!empty($result->fields["file".$i]) && $next) {
} elseif (! empty($result->fields['file'.$i]) && $next) {
$file_no = $i;
$i = 20;
}
}
}
if(empty($file_no))
$file_no = '1';
$file = PATH_FILES . 'campaign_' . $VAR['id'] . '_' . $file_no .'.dat';
$type = 'type'.$file_no;
$name = 'file'.$file_no;
$count_field= 'served'.$file_no;
$count = $result->fields[$count_field] + 1;
if($result->RecordCount() > 0)
{
### Open the file
if (@$file=fopen($file, 'r'))
{
### Display the correct headers:
header ("Content-type: " . $result->fields[$type]);
header ("Content-Disposition: inline; filename=" . $result->fields[$name]);
header ("Content-Description: PHP/INTERBASE Generated Data" );
fpassthru($file);
### Increment the file
if(!isset($VAR['_log']))
{
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET
'.$count_field.' = ' . $db->qstr($count) . ',
last_served = ' . $db->qstr($file_no) . '
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['id']);
$result = $db->Execute($sql);
}
exit;
}
}
echo 'Sorry, the campaign or required file does not exist!';
if (empty($file_no))
$file_no = '1';
$file = sprintf(PATH_FILES.'campaign_%s_%s.dat',$VAR['id'],$file_no);
$type = 'type'.$file_no;
$name = 'file'.$file_no;
$count_field= 'served'.$file_no;
$count = $result->fields[$count_field]+1;
# Open the file
if ($fh=fopen($file,'r')) {
# Display the correct headers:
header('Content-type: '.$result->fields[$type]);
header('Content-Disposition: inline; filename='.$result->fields[$name]);
header('Content-Description: PHP/INTERBASE Generated Data');
fpassthru($fh);
# Increment the file
if (! isset($VAR['_log']))
$result = $db->Execute(sqlUpdate($db,'campaign',array('last_served'=>$file_no,$count_field=>$count),array('id'=>$VAR['id'])));
exit;
}
echo _('Sorry, the campaign or required file does not exist!');
ob_end_flush();
?>
?>