-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_class.php
59 lines (51 loc) · 1.29 KB
/
_class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
* AnteUp - A Donation Tracking Plugin for e107
*
* Copyright (C) 2012-2017 Patrick Weaver (http://trickmod.com/)
* For additional information refer to the README.mkd file.
*
*/
define("ANTEUP", e_PLUGIN."anteup/");
define("ANTEUP_ABS", SITEURLBASE.e_PLUGIN_ABS."anteup/");
function format_currency($input, $id, $commify = true)
{
$curr = e107::getDb()->retrieve("anteup_currency", "*", "id='".intval($id)."'");
$input = (($commify) ? number_format($input, 2) : $input);
return ($curr['location'] == "back" ? $input.$curr['symbol'] : $curr['symbol'].$input);
}
function get_info($type, $campaign = 1)
{
$sql = e107::getDb();
$campaignInfo = $sql->retrieve("anteup_campaign", "*", "id='".$campaign."'");
$donations = $sql->retrieve("anteup_ipn", "*", "payment_status='Completed' AND campaign='".$campaign."'", true);
$current = 0;
$total = 0;
if($campaignInfo['goal_date'])
{
foreach($donations as $donation)
{
if($donation['payment_date'] < $campaignInfo['goal_date'])
{
$current += $donation['mc_gross'];
}
$total += $donation['mc_gross'];
}
}
else
{
foreach($donations as $donation)
{
$current += $donation['mc_gross'];
$total = $current;
}
}
if($type == "current")
{
return $current;
}
elseif($type == "total")
{
return $total;
}
}