Implement current/past donations for donors on the donors/sponsorships tab, and a way to switch between this year, and ALL years history

This commit is contained in:
james 2009-10-11 20:20:52 +00:00
parent 5486317f53
commit 724c627db4

View File

@ -81,7 +81,7 @@ switch($_GET['action']) {
break;
case 'sponsorshipinfo_load':
$id=intval($_GET['id']);
echo "<h3>".i18n("Summary")."</h3>\n";
echo "<h4>".i18n("Summary")."</h4>\n";
echo "<table cellspacing=3 cellpadding=3>\n";
@ -95,6 +95,7 @@ switch($_GET['action']) {
//TOTAL THIS YEAR
$q=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations
WHERE sponsors_id='$id'
AND status='received'
AND fiscalyear={$config['FISCALYEAR']}
");
@ -107,6 +108,7 @@ switch($_GET['action']) {
$lastyear=$config['FISCALYEAR']-1;
$q=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations
WHERE sponsors_id='$id'
AND status='received'
AND fiscalyear=$lastyear
");
@ -115,7 +117,6 @@ switch($_GET['action']) {
else
$totallastyear=format_money(0);
//OUTPUT
echo "<tr><td>".i18n("Last Donation")."</td><td>$lastdonation</td></tr>\n";
echo "<tr><td>".i18n("Total This Year")."</td><td>$totalthisyear</td></tr>\n";
@ -123,29 +124,59 @@ switch($_GET['action']) {
echo "</table>\n";
echo "<br />\n";
echo "<a href=\"#\" onclick=\"return togglefulldonationhistory()\" id=\"fullhistorylink\">".i18n("View full donation history")."</a>";
echo "<div id=\"fulldonationhistory\" style=\"display: none;\">";
$q=mysql_query("SELECT * FROM fundraising_donations WHERE sponsors_id='$id' ORDER BY datereceived DESC");
echo "FIXME: get the goal and campaign";
echo "<h4>".i18n("Donations/Sponsorships")."</h4>\n";
echo "<div id=\"thisyeardonationhistory\">";
$q=mysql_query("SELECT fundraising_donations.*, fundraising_campaigns.name AS campaignname FROM fundraising_donations JOIN fundraising_campaigns ON fundraising_donations.fundraising_campaigns_id=fundraising_campaigns.id WHERE sponsors_id='$id' AND status='received' AND fundraising_donations.fiscalyear='{$config['fiscalyear']}' ORDER BY datereceived DESC");
echo mysql_Error();
if(mysql_num_rows($q)) {
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>".i18n("Date")."</th>\n";
echo " <th>".i18n("Goal")."</th>\n";
echo " <th>".i18n("Campaign")."</th>\n";
echo " <th>".i18n("Appeal")."</th>\n";
echo " <th>".i18n("Value")."</th>\n";
echo "</tr>";
while($r=mysql_fetch_object($q)) {
echo "<tr>\n";
echo " <td>".format_date($r->datereceived)."</td>\n";
echo " <td>$r->fundraising_goal</td>";
echo " <td>$r->fundraising_campaigns_id</td>";
$goal=getGoal($r->fundraising_goal);
echo " <td>$goal->name</td>";
echo " <td>$r->campaignname</td>";
echo " <td>".format_money($r->value,false)."</td>";
echo "</tr>\n";
}
echo "</table>\n";
echo "<br />\n";
}
else
echo i18n("No donations this year")."<br />";
echo "<a href=\"#\" onclick=\"return togglefulldonationhistory()\" id=\"fullhistorylink\">".i18n("View full donation history")."</a>";
echo "</div>";
echo "<div id=\"fulldonationhistory\" style=\"display: none;\">";
echo "<a href=\"#\" onclick=\"return togglefulldonationhistory()\" id=\"fullhistorylink\">".i18n("View this year's donation history")."</a>";
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>".i18n("Date")."</th>\n";
echo " <th>".i18n("Goal")."</th>\n";
echo " <th>".i18n("Appeal")."</th>\n";
echo " <th>".i18n("Value")."</th>\n";
echo "</tr>";
$q=mysql_query("SELECT fundraising_donations.*, fundraising_campaigns.name AS campaignname FROM fundraising_donations JOIN fundraising_campaigns ON fundraising_donations.fundraising_campaigns_id=fundraising_campaigns.id WHERE sponsors_id='$id' AND status='received' ORDER BY datereceived DESC");
while($r=mysql_fetch_object($q)) {
echo "<tr>\n";
echo " <td>".format_date($r->datereceived)."</td>\n";
$goal=getGoal($r->fundraising_goal);
echo " <td>$goal->name</td>";
echo " <td>$r->campaignname</td>";
echo " <td>".format_money($r->value,false)."</td>";
echo "</tr>\n";
}
echo "</table>\n";
echo "</div>\n";
echo "<hr />\n";
echo "<h3>".i18n("Add New Donation/Sponsorship")."</h3>\n";
echo "<br />\n";
echo "<h4>".i18n("Add New Donation/Sponsorship")."</h4>\n";
echo "<form>";
echo "<table cellspacing=3 cellpadding=3>";
@ -629,7 +660,7 @@ function draw_activityinfo_form(){
<th>Date</th>
<th>Committee Member</th>
<th>Contact Type</th>
<th>Campaign</th>
<th>Appeal</th>
<th>Notes</th>
</tr></thead>
<tbody>
@ -641,7 +672,7 @@ function draw_activityinfo_form(){
<?
echo "<select name=\"type\">";
echo "<option value=\"\">".i18n("Choose Type")."</option>\n";
$logtypes=array("Campaign","Phone Call","Email","Personal Visit","Other");
$logtypes=array("Appeal","Phone Call","Email","Personal Visit","Other");
foreach($logtypes AS $lt) {
echo "<option value=\"$lt\">".i18n($lt)."</option>\n";
}
@ -652,7 +683,7 @@ function draw_activityinfo_form(){
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
echo "<select name=\"fundraising_campaigns_id\">";
echo "<option value=\"\">".i18n("Choose Campaign")."</option>\n";
echo "<option value=\"\">".i18n("Choose Appeal")."</option>\n";
while($r=mysql_fetch_object($q)) {
echo "<option value=\"$r->id\">$r->name</option>\n";
}
@ -934,7 +965,7 @@ function useexistingcontact(uid) {
function togglefulldonationhistory() {
$("#fulldonationhistory").toggle('slow');
$("#thisyeardonationhistory").toggle('slow');
}
function campaignchange() {