Switch fundraising dashboard to be ajax'ed and add the ability to mark thankyou's as done.

This commit is contained in:
james 2009-12-03 21:53:01 +00:00
parent 617723cdbe
commit 3da935eaff

View File

@ -25,46 +25,9 @@
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Fundraising",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
"fundraising"
);
function getUserForSponsor($sponsor_id) {
// loop through each contact and draw a form with their data in it.
$q = mysql_query("SELECT *,MAX(year) FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
WHERE
sponsors_id='" . $sponsor_id . "'
AND types LIKE '%sponsor%'
GROUP BY uid
HAVING deleted='no'
ORDER BY users_sponsor.primary DESC,lastname,firstname
LIMIT 1
");
$r=mysql_fetch_object($q);
return user_load_by_uid($r->uid);
}
if($_GET['action']=="refresh") {
?>
<script type="text/javascript">
$(document).ready(function() {
});
//key is initial or followup
//start is either 'new' to start with a blank, or 'existing' to load an existing email to start from
function opencommunicationsender(uid,template) {
$("#content").empty();
$("#content").load("communication.php?action=dialog_sender&uid="+uid+"&template=fundraising_thankyou_template",null,function() {
});
return false;
}
</script>
<h3><?=i18n("Fundraising Purposes and Progress Year to Date")?></h3>
<?
@ -148,10 +111,11 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
</table>
<br />
<form id="thankyouform" method="post" action="fundraising.php">
<h3><?=i18n("To Do List")?></h3>
<h4><?=i18n("Thank You's")?></h4>
<?
$q=mysql_query("SELECT value, thanked, status, sponsors_id, datereceived,
$q=mysql_query("SELECT id,value, thanked, status, sponsors_id, datereceived,
DATE_ADD(datereceived, INTERVAL 1 MONTH) < NOW() AS onemonth,
DATE_ADD(datereceived, INTERVAL 2 MONTH) < NOW() AS twomonth
FROM fundraising_donations
@ -167,6 +131,7 @@ if(mysql_num_rows($q)) {
echo "<th>".i18n("Date Received")."</th>\n";
echo "<th>".i18n("Amount")."</th>\n";
echo "<th>".i18n("Generate Thank You")."</th>\n";
echo "<th>".i18n("Thanked")."</th>\n";
echo "</tr>\n";
while($r=mysql_fetch_object($q)) {
@ -188,6 +153,7 @@ if(mysql_num_rows($q)) {
} else {
echo i18n("No contact");
}
echo "<td align=\"center\"><input style=\"padding: 0px; margin: 0px;\" type=\"checkbox\" name=\"thanked[]\" value=\"$r->id\" onclick=\"return thanked($r->id)\"></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
@ -196,6 +162,7 @@ if(mysql_num_rows($q)) {
echo "<br />\n";
}
?>
</form>
<br />
<h4><?=i18n("Receipts to Issue")?></h4>
@ -284,5 +251,49 @@ if(mysql_num_rows($q)) {
echo i18n("No proposals upcoming");
}
exit;
}
else if (count($_POST['thanked'])) {
foreach($_POST['thanked'] AS $t) {
mysql_query("UPDATE fundraising_donations SET thanked='yes' WHERE id='$t'");
}
}
send_header("Fundraising",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
"fundraising"
);
?>
<script type="text/javascript">
$(document).ready(function() {
refreshDashboard();
});
function refreshDashboard() {
$("#dashboard").load("fundraising.php?action=refresh");
}
function thanked() {
$.post("fundraising.php",$("#thankyouform").serializeArray(),function() {
refreshDashboard();
});
}
//key is initial or followup
//start is either 'new' to start with a blank, or 'existing' to load an existing email to start from
function opencommunicationsender(uid,template) {
$("#content").empty();
$("#content").load("communication.php?action=dialog_sender&uid="+uid+"&template=fundraising_thankyou_template",null,function() {
});
return false;
}
</script>
<div id="dashboard"></div>
<?
send_footer();
?>