forked from science-ation/science-ation
Change JOIN to LEFT JOIN for donation/sponsorship list in the case that they don't specify an appeal.
Add ability to REMOVE a donation Add activitylog for both adding and removing donations
This commit is contained in:
parent
ab60a0f389
commit
0fbf664f67
@ -128,7 +128,14 @@ switch($_GET['action']) {
|
||||
echo "<br />\n";
|
||||
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");
|
||||
$q=mysql_query("SELECT fundraising_donations.*,
|
||||
fundraising_campaigns.name AS campaignname
|
||||
FROM fundraising_donations
|
||||
LEFT 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\">";
|
||||
@ -137,6 +144,7 @@ switch($_GET['action']) {
|
||||
echo " <th>".i18n("Purpose")."</th>\n";
|
||||
echo " <th>".i18n("Appeal")."</th>\n";
|
||||
echo " <th>".i18n("Value")."</th>\n";
|
||||
echo " <th>".i18n("Remove")."</th>\n";
|
||||
echo "</tr>";
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
echo "<tr>\n";
|
||||
@ -145,6 +153,9 @@ switch($_GET['action']) {
|
||||
echo " <td>$goal->name</td>";
|
||||
echo " <td>$r->campaignname</td>";
|
||||
echo " <td>".format_money($r->value,false)."</td>";
|
||||
echo " <td align=\"center\">";
|
||||
echo "<a onclick=\"return removedonation($r->id,$id)\" href=\"#\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
echo " </td>";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
@ -162,9 +173,16 @@ switch($_GET['action']) {
|
||||
echo " <th>".i18n("Purpose")."</th>\n";
|
||||
echo " <th>".i18n("Appeal")."</th>\n";
|
||||
echo " <th>".i18n("Value")."</th>\n";
|
||||
echo " <th>".i18n("Remove")."</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");
|
||||
$q=mysql_query("SELECT fundraising_donations.*,
|
||||
fundraising_campaigns.name AS campaignname
|
||||
FROM fundraising_donations
|
||||
LEFT 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";
|
||||
@ -172,6 +190,9 @@ switch($_GET['action']) {
|
||||
echo " <td>$goal->name</td>";
|
||||
echo " <td>$r->campaignname</td>";
|
||||
echo " <td>".format_money($r->value,false)."</td>";
|
||||
echo " <td align=\"center\">";
|
||||
echo "<a onclick=\"return removedonation($r->id,$id)\" href=\"#\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
echo " </td>";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
@ -398,6 +419,9 @@ switch($_GET['action']) {
|
||||
'".mysql_real_escape_string($datereceived)."',
|
||||
'".mysql_real_escape_string($supporttype)."'
|
||||
)");
|
||||
$id=mysql_insert_id();
|
||||
$logStr=getDonationString($id);
|
||||
save_activityinfo("Added donation/sponsorship: $logStr", $sponsorid, $_SESSION['users_uid'],"System");
|
||||
echo mysql_error();
|
||||
|
||||
happy_("Donation/sponsorship added");
|
||||
@ -407,6 +431,21 @@ switch($_GET['action']) {
|
||||
|
||||
exit;
|
||||
break;
|
||||
case "donation_remove":
|
||||
//function save_activityinfo($comment, $donorId, $userId, $type, $campaign_id=null){
|
||||
$id=intval($_POST['id']);
|
||||
$sponsorid=intval($_POST['sponsors_id']);
|
||||
if($logStr=getDonationString($id)) {
|
||||
save_activityinfo("Removed donation/sponsorship: $logStr", $sponsorid, $_SESSION['users_uid'],"System");
|
||||
happy_("Donation/sponsorship removed");
|
||||
mysql_query("DELETE FROM fundraising_donations WHERE id='$id' AND sponsors_id='$sponsorid'");
|
||||
echo mysql_error();
|
||||
}
|
||||
else {
|
||||
error_("Invalid donation/sponsorship to remove");
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
send_header("Donor/Sponsor Management",
|
||||
@ -810,6 +849,44 @@ function save_activityinfo($comment, $donorId, $userId, $type, $campaign_id=null
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
function getDonationString($id) {
|
||||
global $config;
|
||||
$q=mysql_query("SELECT fundraising_donations.*,
|
||||
fundraising_campaigns.name AS campaignname
|
||||
FROM fundraising_donations
|
||||
LEFT JOIN fundraising_campaigns ON fundraising_donations.fundraising_campaigns_id=fundraising_campaigns.id
|
||||
WHERE fundraising_donations.id='$id'
|
||||
AND fundraising_donations.fiscalyear='{$config['FISCALYEAR']}'
|
||||
");
|
||||
echo mysql_error();
|
||||
$str="";
|
||||
if($r=mysql_fetch_object($q)) {
|
||||
$str.=format_date($r->datereceived)." - ";
|
||||
$goal=getGoal($r->fundraising_goal);
|
||||
if($goal) {
|
||||
$str.=i18n("Goal: %1",array($goal->name));
|
||||
}
|
||||
else {
|
||||
$str.=i18n("Goal: none");
|
||||
}
|
||||
$str.= " - ";
|
||||
if($r->campaignname) {
|
||||
$str.= i18n("Campaign: %1",array($r->campaignname));
|
||||
}
|
||||
else {
|
||||
$str.=i18n("Campaign: none");
|
||||
}
|
||||
$str.= " - ";
|
||||
$str.= " Value: ".format_money($r->value,false);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
/* Setup the popup window */
|
||||
@ -1074,6 +1151,13 @@ function adddonation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function removedonation(donationid,sponsorid) {
|
||||
if(confirmClick('Are you sure you want to remove this donation/sponsorship?')) {
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=donation_remove", {id: donationid, sponsors_id: sponsorid},function() { update_sponsorshipinfo(); });
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
</script>
|
||||
<?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user