diff --git a/public_html/classes/campaign.php b/public_html/classes/campaign.php
index 3068d6e..a235fb7 100644
--- a/public_html/classes/campaign.php
+++ b/public_html/classes/campaign.php
@@ -32,6 +32,8 @@ class Campaign extends CPHPDatabaseRecordClass
'MonthlyProjection' => "ProjectedMonthlyDonations",
'PastMonthDonations' => "PastMonthDonations",
'PastMonthNonDonations' => "PastMonthNonDonations",
+ 'PastMonthAmount' => "PastMonthAmount",
+ 'PastMonthNonAmount' => "PastMonthNonAmount",
'PastMonthSubscriptions' => "PastMonthSubscriptions",
'PastMonthUnsubscriptions' => "PastMonthUnsubscriptions"
),
@@ -114,6 +116,26 @@ class Campaign extends CPHPDatabaseRecordClass
return $sPaymentMethod;
}
+ public function CreateStatisticsEntry()
+ {
+ $sStatisticsEntry = new StatisticsEntry(0);
+ $sStatisticsEntry->uDonationRate = $this->sDonationRate;
+ $sStatisticsEntry->uSubscriberCount = $this->sSubscriberCount;
+ $sStatisticsEntry->uTotalMonthlyDonations = $this->sMonthlyTotal;
+ $sStatisticsEntry->uProjectedMonthlyDonations = $this->sMonthlyProjection;
+ $sStatisticsEntry->uPastMonthDonations = $this->sPastMonthDonations;
+ $sStatisticsEntry->uPastMonthNonDonations = $this->sPastMonthNonDonations;
+ $sStatisticsEntry->uPastMonthAmount = $this->sPastMonthAmount;
+ $sStatisticsEntry->uPastMonthNonAmount = $this->sPastMonthNonAmount;
+ $sStatisticsEntry->uPastMonthSubscriptions = $this->sPastMonthSubscriptions;
+ $sStatisticsEntry->uPastMonthUnsubscriptions = $this->sPastMonthUnsubscriptions;
+ $sStatisticsEntry->uHaveData = $this->sHaveData;
+ $sStatisticsEntry->uAllowOneTime = $this->sAllowOneTime;
+ $sStatisticsEntry->uDate = time();
+ $sStatisticsEntry->uCampaignId = $this->sId;
+ return $sStatisticsEntry;
+ }
+
public function UpdateStatistics()
{
global $database, $cphp_config;
diff --git a/public_html/classes/statisticsentry.php b/public_html/classes/statisticsentry.php
new file mode 100644
index 0000000..58418dc
--- /dev/null
+++ b/public_html/classes/statisticsentry.php
@@ -0,0 +1,47 @@
+ array(
+ 'CampaignId' => "CampaignId",
+ 'SubscriberCount' => "SubscriberCount",
+ 'TotalMonthlyDonations' => "TotalMonthlyDonations",
+ 'ProjectedMonthlyDonations' => "ProjectedMonthlyDonations",
+ 'PastMonthDonations' => "PastMonthDonations",
+ 'PastMonthAmount' => "PastMonthAmount",
+ 'PastMonthNonDonations' => "PastMonthNonDonations",
+ 'PastMonthNonAmount' => "PastMonthNonAmount",
+ 'PastMonthSubscriptions' => "PastMonthSubscriptions",
+ 'PastMonthUnsubscriptions' => "PastMonthUnsubscriptions",
+ 'DonationRate' => "DonationRate"
+ ),
+ 'timestamp' => array(
+ 'Date' => "Date"
+ ),
+ 'boolean' => array(
+ 'HaveData' => "HaveData",
+ 'AllowOneTime' => "AllowOneTime"
+ ),
+ 'campaign' => array(
+ 'Campaign' => "Campaign"
+ )
+ );
+}
diff --git a/public_html/cron.daily.php b/public_html/cron.daily.php
index 6aacd23..ae67cd7 100644
--- a/public_html/cron.daily.php
+++ b/public_html/cron.daily.php
@@ -68,3 +68,12 @@ foreach($sSubscriptions as $sSubscription)
$sSubscription->uLastEmailDate = time();
$sSubscription->InsertIntoDatabase();
}
+
+/* Now, we'll log a historical statistics snapshot for every campaign. */
+
+foreach(Campaign::CreateFromQuery("SELECT * FROM campaigns") as $sCampaign)
+{
+ $sCampaign->UpdateStatistics();
+ $sStatisticsEntry = $sCampaign->CreateStatisticsEntry();
+ $sStatisticsEntry->InsertIntoDatabase();
+}