diff --git a/admin/donors.php b/admin/donors.php index 3e1bb0b..4818677 100644 --- a/admin/donors.php +++ b/admin/donors.php @@ -126,7 +126,7 @@ switch($_GET['action']) { echo "
\n"; echo "

".i18n("Donations/Sponsorships")."

\n"; echo "
"; - $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 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 ""; @@ -179,21 +179,56 @@ switch($_GET['action']) { echo "

".i18n("Add New Donation/Sponsorship")."

\n"; echo ""; + echo "\n"; echo "
"; echo "\n"; @@ -204,7 +239,7 @@ switch($_GET['action']) { echo " var defaultgoals=Array();\n"; echo $str; echo "\n"; - echo ""; echo "\n"; //FIXME: only show campaigns that they were included as part of //we need a campaigns_users_link or campaigns_sponsors_link or something @@ -229,13 +264,13 @@ switch($_GET['action']) { echo "\n"; } echo "\n"; - echo "\n"; /* echo ""; echo "\n"; */ + echo "\n"; echo "
"; echo i18n("Appeal").":"; echo ""; + + // loop through each contact in the donor + $query = mysql_query("SELECT users.id,users.uid,users.deleted,MAX(year) + FROM users + LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id + WHERE + sponsors_id='$id' + AND types LIKE '%sponsor%' + GROUP BY uid + HAVING deleted='no' + ORDER BY users_sponsor.primary DESC,lastname,firstname + "); + echo mysql_error(); + $uids=array(); + while($r=mysql_fetch_object($query)) { + $uids[]=$r->uid; + } + + $q=mysql_query("SELECT * FROM fundraising_campaigns + WHERE fiscalyear='{$config['FISCALYEAR']}' + ORDER BY name"); + $str=""; echo "\n"; echo "
"; echo "".i18n("Generate Thank You")."
\n"; @@ -340,6 +375,36 @@ switch($_GET['action']) { echo "
"; exit; break; + case "donation_add": + $campaignid=intval($_POST['fundraising_campaigns_id']); + $sponsorid=intval($_POST['sponsors_id']); + $goal=$_POST['fundraising_goal']; + $value=intval($_POST['value']); + $supporttype=$_POST['supporttype']; + $datereceived=$_POST['datereceived']; + + if($goal && $value && $supporttype) { + mysql_query("INSERT INTO fundraising_donations (sponsors_id,fundraising_goal,fundraising_campaigns_id,value,status,probability,fiscalyear,thanked,datereceived,supporttype) VALUES ( + '$sponsorid', + '".mysql_real_escape_string($goal)."', + '$campaignid', + '$value', + 'received', + '100', + '{$config['FISCALYEAR']}', + 'no', + '".mysql_real_escape_string($datereceived)."', + '".mysql_real_escape_string($supporttype)."' + )"); + echo mysql_error(); + + happy_("Donation/sponsorship added"); + } else { + error_("All fields are required"); + } + + exit; + break; } send_header("Donor/Sponsor Management", @@ -657,11 +722,11 @@ function draw_activityinfo_form(){ - - - - - + + + + + @@ -969,6 +1034,9 @@ function togglefulldonationhistory() { } function campaignchange() { + var campaignid=$("#fundraising_campaign_id").val(); + var goal=defaultgoals[campaignid]; + $("#fundraising_goal").val(goal); } function donortypechange() { @@ -991,7 +1059,8 @@ function donortypechange() { function adddonation() { var id=sponsor_id; - $("#debug").load("?action=donation_add", $("#donationaddform").serializeArray(),function() { update_contactsinfo(); }); + $("#debug").load("?action=donation_add", $("#addnewdonationform").serializeArray(),function() { update_sponsorshipinfo(); }); + return false; }
DateCommittee MemberContact TypeAppealNotes/>