2013-08-28 23:08:41 +00:00
|
|
|
<?
|
|
|
|
|
2013-04-30 18:18:07 +00:00
|
|
|
if (!check_perms('admin_donor_log')) {
|
|
|
|
error(403);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
include(SERVER_ROOT.'/sections/donate/config.php');
|
|
|
|
|
|
|
|
define('DONATIONS_PER_PAGE', 50);
|
2013-05-28 08:01:02 +00:00
|
|
|
list($Page, $Limit) = Format::page_limit(DONATIONS_PER_PAGE);
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-08-28 23:08:41 +00:00
|
|
|
$AfterDate = $_GET['after_date'];
|
|
|
|
$BeforeDate = $_GET['before_date'];
|
|
|
|
$DateSearch = false;
|
|
|
|
if (!empty($AfterDate) && !empty($BeforeDate)) {
|
|
|
|
list($Y, $M, $D) = explode('-', $AfterDate);
|
|
|
|
if (!checkdate($M, $D, $Y)) {
|
|
|
|
error('Incorrect "after" date format');
|
|
|
|
}
|
|
|
|
list($Y, $M, $D) = explode('-', $BeforeDate);
|
|
|
|
if (!checkdate($M, $D, $Y)) {
|
|
|
|
error('Incorrect "before" date format');
|
|
|
|
}
|
|
|
|
$AfterDate = db_string($AfterDate);
|
|
|
|
$BeforeDate = db_string($BeforeDate);
|
|
|
|
$DateSearch = true;
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-08-28 23:08:41 +00:00
|
|
|
$Operator = "WHERE";
|
|
|
|
$SQL = "
|
2013-05-27 08:00:58 +00:00
|
|
|
SELECT
|
|
|
|
SQL_CALC_FOUND_ROWS
|
|
|
|
d.UserID,
|
|
|
|
d.Amount,
|
|
|
|
d.Currency,
|
|
|
|
d.Email,
|
2013-08-28 23:08:41 +00:00
|
|
|
d.Time,
|
|
|
|
d.Source,
|
|
|
|
m.Username,
|
|
|
|
d.AddedBy,
|
|
|
|
d.Reason
|
|
|
|
FROM donations AS d
|
|
|
|
LEFT JOIN users_main AS m ON m.ID = d.UserID ";
|
|
|
|
|
|
|
|
if (!empty($_GET['email'])) {
|
|
|
|
$SQL .= "
|
|
|
|
$Operator d.Email LIKE '%".db_string($_GET['email'])."%' ";
|
|
|
|
$Operator = "AND";
|
|
|
|
}
|
|
|
|
if (!empty($_GET['username'])) {
|
|
|
|
$SQL .= "
|
|
|
|
$Operator m.Username LIKE '%".db_string($_GET['username'])."%' ";
|
|
|
|
$Operator = "AND";
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-08-28 23:08:41 +00:00
|
|
|
if ($DateSearch) {
|
|
|
|
$SQL .= "$Operator d.Time BETWEEN '$AfterDate' AND '$BeforeDate' ";
|
|
|
|
$Operator = "AND";
|
|
|
|
}
|
|
|
|
$SQL .= "
|
2013-05-27 08:00:58 +00:00
|
|
|
ORDER BY d.Time DESC
|
|
|
|
LIMIT $Limit";
|
2013-08-28 23:08:41 +00:00
|
|
|
$DB->query($SQL);
|
|
|
|
$Donations = $DB->to_array();
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-07-13 08:00:46 +00:00
|
|
|
$DB->query('SELECT FOUND_ROWS()');
|
2011-03-28 14:21:28 +00:00
|
|
|
list($Results) = $DB->next_record();
|
|
|
|
|
2013-08-28 23:08:41 +00:00
|
|
|
$DB->query("SELECT SUM(Amount) FROM donations");
|
|
|
|
list($Total) = $DB->next_record();
|
|
|
|
|
|
|
|
if (empty($_GET['email']) && empty($_GET['username']) && empty($_GET['source']) && !isset($_GET['page']) && !$DonationTimeline = $Cache->get_value('donation_timeline')) {
|
2013-05-27 08:00:58 +00:00
|
|
|
include(SERVER_ROOT.'/classes/charts.class.php');
|
|
|
|
$DB->query("
|
|
|
|
SELECT DATE_FORMAT(Time,'%b \'%y') AS Month, SUM(Amount)
|
|
|
|
FROM donations
|
|
|
|
GROUP BY Month
|
|
|
|
ORDER BY Time DESC
|
|
|
|
LIMIT 1, 18");
|
2011-03-28 14:21:28 +00:00
|
|
|
$Timeline = array_reverse($DB->to_array());
|
2013-07-13 08:00:46 +00:00
|
|
|
$Area = new AREA_GRAPH(880, 160, array('Break' => 1));
|
2013-04-30 18:18:07 +00:00
|
|
|
foreach ($Timeline as $Entry) {
|
2013-05-27 08:00:58 +00:00
|
|
|
list($Label, $Amount) = $Entry;
|
|
|
|
$Area->add($Label, $Amount);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
$Area->transparent();
|
|
|
|
$Area->grid_lines();
|
|
|
|
$Area->color('3d7930');
|
|
|
|
$Area->lines(2);
|
|
|
|
$Area->generate();
|
|
|
|
$DonationTimeline = $Area->url();
|
2013-07-13 08:00:46 +00:00
|
|
|
$Cache->cache_value('donation_timeline', $DonationTimeline, mktime(0, 0, 0, date('n') + 1, 2));
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
View::show_header('Donation log');
|
2013-08-28 23:08:41 +00:00
|
|
|
if (empty($_GET['email']) && empty($_GET['source']) && empty($_GET['username']) && !isset($_GET['page'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
|
|
|
<div class="box pad">
|
2012-09-23 08:00:25 +00:00
|
|
|
<img src="<?=$DonationTimeline?>" alt="Donation timeline. The "y" axis is donation amount." />
|
2011-03-28 14:21:28 +00:00
|
|
|
</div>
|
2012-09-23 08:00:25 +00:00
|
|
|
<br />
|
2011-03-28 14:21:28 +00:00
|
|
|
<? } ?>
|
|
|
|
<div>
|
2012-09-15 08:00:25 +00:00
|
|
|
<form class="search_form" name="donation_log" action="" method="get">
|
2013-08-28 23:08:41 +00:00
|
|
|
<input type="hidden" name="action" value="donation_log" />
|
2012-09-01 08:00:24 +00:00
|
|
|
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
|
2013-08-28 23:08:41 +00:00
|
|
|
<tr>
|
|
|
|
<td class="label"><strong>Username:</strong></td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="username" size="60" value="<? if (!empty($_GET['username'])) { echo display_str($_GET['username']); } ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
2011-03-28 14:21:28 +00:00
|
|
|
<tr>
|
|
|
|
<td class="label"><strong>Email:</strong></td>
|
|
|
|
<td>
|
2013-08-28 23:08:41 +00:00
|
|
|
<input type="text" name="email" size="60" value="<? if (!empty($_GET['email'])) { echo display_str($_GET['email']); } ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="label"><strong>Source:</strong></td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="source" size="60" value="<? if (!empty($_GET['source'])) { echo display_str($_GET['source']); } ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="label"><strong>Date Range:</strong></td>
|
|
|
|
<td>
|
|
|
|
<input type="date" name="after_date" />
|
|
|
|
<input type="date" name="before_date" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2012-09-23 08:00:25 +00:00
|
|
|
<input type="submit" value="Search donation log" />
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2013-02-22 08:00:24 +00:00
|
|
|
</table>
|
2011-03-28 14:21:28 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
2012-09-23 08:00:25 +00:00
|
|
|
<br />
|
2011-03-28 14:21:28 +00:00
|
|
|
<div class="linkbox">
|
|
|
|
<?
|
2013-04-30 18:18:07 +00:00
|
|
|
$Pages = Format::get_pages($Page, $Results, DONATIONS_PER_PAGE, 11);
|
2011-03-28 14:21:28 +00:00
|
|
|
echo $Pages;
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<table width="100%">
|
|
|
|
<tr class="colhead">
|
|
|
|
<td>User</td>
|
|
|
|
<td>Amount</td>
|
|
|
|
<td>Email</td>
|
2013-08-28 23:08:41 +00:00
|
|
|
<td>Source</td>
|
|
|
|
<td>Reason</td>
|
2011-03-28 14:21:28 +00:00
|
|
|
<td>Time</td>
|
|
|
|
</tr>
|
|
|
|
<?
|
2013-08-28 23:08:41 +00:00
|
|
|
$PageTotal = 0;
|
2013-04-30 18:18:07 +00:00
|
|
|
foreach ($Donations as $Donation) {
|
2013-08-28 23:08:41 +00:00
|
|
|
$PageTotal += $Donation['Amount']; ?>
|
|
|
|
<tr>
|
|
|
|
<td><?=Users::format_username($Donation['UserID'], true)?> (<?=Users::format_username($Donation['AddedBy'])?>)</td>
|
|
|
|
<td><?=display_str($Donation['Amount'])?></td>
|
|
|
|
<td><?=display_str($Donation['Email'])?></td>
|
|
|
|
<td><?=display_str($Donation['Source'])?></td>
|
|
|
|
<td><?=display_str($Donation['Reason'])?></td>
|
|
|
|
<td><?=time_diff($Donation['Time'])?></td>
|
|
|
|
</tr>
|
2011-03-28 14:21:28 +00:00
|
|
|
<? } ?>
|
2013-08-28 23:08:41 +00:00
|
|
|
<tr class="colhead">
|
|
|
|
<td>Page Total</td>
|
|
|
|
<td><?=$PageTotal?></td>
|
|
|
|
<td>Total</td>
|
|
|
|
<td colspan="3"><?=$Total?></td>
|
|
|
|
</tr>
|
2011-03-28 14:21:28 +00:00
|
|
|
</table>
|
|
|
|
<div class="linkbox">
|
|
|
|
<?=$Pages?>
|
|
|
|
</div>
|
2012-10-11 08:00:15 +00:00
|
|
|
<? View::show_footer(); ?>
|