Update fundraising to use jquery dialogs instead of my homebrew dialogs

This commit is contained in:
james 2009-09-17 21:48:57 +00:00
parent ca9b2bb5a1
commit d51b2d9576
7 changed files with 227 additions and 152 deletions

View File

@ -29,6 +29,7 @@
include ("fundraising_sponsorship_handler.inc.php");
include ("fundraising_types_handler.inc.php");
include ("fundraising_main.inc.php");
send_header("Fundraising",
array('Committee Main' => 'committee_main.php',
@ -36,7 +37,107 @@
"fundraising"
);
require_once("../dialog.inc.php");
?>
<script type="text/javascript">
$(document).ready(function() {
//initialize the dialog
$("#sponsorship_editor").dialog({
bgiframe: true, autoOpen: false,
modal: true, resizable: false,
draggable: false
});
$("#fund_editor").dialog({
bgiframe: true, autoOpen: false,
modal: true, resizable: false,
draggable: false
});
refresh_fundraising_table();
});
function popup_sponsorship_editor(url) {
var w = (document.documentElement.clientWidth * 0.6);
$('#sponsorship_editor').dialog('option','width',w);
//let the height autocalculate
/*
var h = (document.documentElement.clientHeight * 0.6);
$('#sponsorship_editor').dialog('option','height',h);
*/
$('#sponsorship_editor').dialog('option','buttons',{ "<?=i18n("Save")?>": function() { save_sponsorship(); },
"<?=i18n("Cancel")?>": function(){ $(this).dialog("close");}});
$('#sponsorship_editor').dialog('open');
$('#sponsorship_editor_content').load(url);
return false;
}
function save_sponsorship() {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
$("#fundraisingsponsorship").serialize(),
function(data) {
$('#sponsorship_editor').dialog('close');
});
refresh_fundraising_table();
return false;
}
function popup_fund_editor(url) {
var w = (document.documentElement.clientWidth * 0.6);
$('#fund_editor').dialog('option','width',w);
//let the height autocalculate
/*
var h = (document.documentElement.clientHeight * 0.6);
$('#fund_editor').dialog('option','height',h);
*/
$('#fund_editor').dialog('option','buttons',{ "<?=i18n("Save")?>": function() { save_fund(); },
"<?=i18n("Cancel")?>": function(){ $(this).dialog("close");}});
$('#fund_editor').dialog('open');
$('#fund_editor_content').load(url);
return false;
}
function save_fund() {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
$("#fundraisingfundraising").serialize(),
function(data) {
$('#fund_editor').dialog('close');
});
refresh_fundraising_table();
return false;
}
function delete_fund(id) {
if(confirmClick('Are you sure you want to remove this fund?')) {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
{ action: 'funddelete', delete: id }
);
refresh_fundraising_table();
}
return false;
}
function delete_sponsorship(id) {
if(confirmClick('Are you sure you want to remove this sponsorship?')) {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
{ action: 'sponsorshipdelete', delete: id }
);
refresh_fundraising_table();
}
return false;
}
function refresh_fundraising_table() {
$("#fundraisingmain").load("fundraising.php?action=fundraisingmain");
}
</script>
<?
//require_once("../dialog.inc.php");
//first, insert any defaults
$q=mysql_query("SELECT * FROM fundraising WHERE year='".$config['FAIRYEAR']."'");
@ -47,89 +148,9 @@ require_once("../dialog.inc.php");
}
}
//this table is eventually going to be massive, and probably not in a tableview format, it'll show goals as well as all ongoing fund pledges, probabilities, etc as well as over/under, etc, all prettily colour coded.. basically a good overview of the total fundraising status of the fair.
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY system DESC,type");
echo "<table class=\"fundraisingtable\">";
echo "<div id=\"fundraisingmain\">";
echo "</div>";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
if($r->system=="no") {
echo "<a title=\"".i18n("Remove Fund")."\" onclick=\"return confirmClick('Are you sure you want to remove this fund and all sponsorships inside it?')\" href=\"fundraising.php?action=funddelete&delete=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
}
echo "</th>\n";
echo "<th colspan=\"5\">".i18n($r->name)."</th>\n";
echo "<th style=\"text-align: right\"><nobr>".format_money($r->goal)."</nobr></th>\n";
echo "</tr>\n";
if($r->type=="general")
$orsql.="OR fundraising_type IS NULL";
$typetotal=0;
$typeprobtotal=0;
$sq=mysql_query("SELECT sponsorships.id, sponsors.organization, sponsorships.value, sponsorships.status, sponsorships.probability
FROM sponsorships
JOIN sponsors ON sponsorships.sponsors_id=sponsors.id
WHERE (sponsorships.fundraising_type='$r->type' $orsql)
AND sponsorships.year='{$config['FAIRYEAR']}'
ORDER BY status DESC, probability DESC, organization");
while($sr=mysql_fetch_object($sq)) {
echo "<tr id=\"sponsorships_$sr->id\" class=\"fundraising{$sr->status}\">";
echo "<td>";
echo "<a title=\"".i18n("Remove sponsorship")."\" onclick=\"return confirmClick('Are you sure you want to remove this sponsorship?')\" href=\"fundraising.php?action=sponsorshipdelete&delete=$sr->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a></nobr>";
echo "</td>";
echo "<td><a title=\"".i18n("Edit sponsorship details")."\" onclick=\"return SFIABDialog(event,'fundraising_sponsorship.php?id=$sr->id&fundraising_type=$r->type',400,250)\" href=\"#\">$sr->organization</a></td>\n";
/*
echo "<a href=\"communication.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
//only user emails can be deleted, system ones are required and cannot be removed
if($r->type=="user")
{
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove email?')\" href=\"communication.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a href=\"communication.php?action=send&send=$r->id\">Send</a>";
}
*/
echo "<td>$sr->status</td>";
echo "<td>";
if($sr->status=="pending")
{
echo "$sr->probability%";
echo "</td>";
echo "<td><nobr>".format_money($sr->value)."</nobr></td>";
}
else
echo "</td><td></td>\n";
$probval=$sr->probability/100*$sr->value;
echo "<td style=\"text-align: right\"><nobr>".format_money($probval)."</nobr></td>";
echo "<td></td>\n";
echo "</tr>\n";
$typeprobtotal+=$probval;
$typetotal+=$sr->value;
}
echo "<tr>";
echo "<td><a onclick=\"return SFIABDialog(event,'fundraising_sponsorship.php?fundraising_type=$r->type',400,250)\" href=\"#\">add</a></td>";
echo "<td colspan=\"3\" style=\"text-align: right; font-weight: bold;\">".i18n("%1 Total",array($r->name),array("Fundraising type total, eg) Award Sponsorship Total"))."</td>\n";
echo "<td style=\"font-weight: bold; text-align: right;\"><nobr>".format_money($typetotal)."</nobr></td>\n";
echo "<td style=\"font-weight: bold; text-align: right;\"><nobr>".format_money($typeprobtotal)."</nobr></td>\n";
$typediff=$typeprobtotal-$r->goal;
echo "<td style=\"font-weight: bold; text-align: right;\"><nobr>".format_money($typediff)."</nobr></td>\n";
echo "</tr>\n";
$totalgoal+=$r->goal;
$totaldiff+=$typediff;
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>\n";
}
echo "<tr>";
echo "<td colspan=\"2\"><a onclick=\"return SFIABDialog(event,'fundraising_types.php',400,250)\" href=\"#\">add fund type</a></td>";
echo "<td colspan=\"4\" style=\"font-weight: bold; text-align: right;\">".i18n("Total Net Position")."</td><td style=\"text-align: right; font-weight: bold;\">".format_money($totaldiff)."</td></tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<br />\n";
echo "<a href=\"sponsorship_levels.php\">Manage Sponsorship Levels</a>\n";
@ -137,5 +158,15 @@ require_once("../dialog.inc.php");
echo "<a href=\"sponsors.php\">Manage Sponsors</a>\n";
echo "<br />\n";
?>
<div style="display: none" title="<?=i18n("Sponsorship Editor")?>" id="sponsorship_editor">
<div id="sponsorship_editor_content">
</div>
</div>
<div style="display: none" title="<?=i18n("Fund Editor")?>" id="fund_editor">
<div id="fund_editor_content">
</div>
</div>
<?
send_footer();
?>

View File

@ -0,0 +1,95 @@
<?
if($_GET['action']=="fundraisingmain") {
//this table is eventually going to be massive, and probably not in a tableview format, it'll show goals as well as all ongoing fund pledges, probabilities, etc as well as over/under, etc, all prettily colour coded.. basically a good overview of the total fundraising status of the fair.
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY system DESC,type");
echo "<table class=\"fundraisingtable\">";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return popup_fund_editor('fundraising_types.php?id=$r->id')\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
if($r->system=="no") {
//echo "<a title=\"".i18n("Remove Fund")."\" onclick=\"return confirmClick('Are you sure you want to remove this fund and all sponsorships inside it?')\" href=\"fundraising.php?action=funddelete&delete=$r->id\">";
echo "<img style=\"cursor:pointer\" onclick=\"return delete_fund($r->id)\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\">";
// echo "</a>";
}
echo "</th>\n";
echo "<th colspan=\"5\">".i18n($r->name)."</th>\n";
echo "<th style=\"text-align: right\"><nobr>".format_money($r->goal)."</nobr></th>\n";
echo "</tr>\n";
if($r->type=="general")
$orsql.="OR fundraising_type IS NULL";
$typetotal=0;
$typeprobtotal=0;
$sq=mysql_query("SELECT sponsorships.id, sponsors.organization, sponsorships.value, sponsorships.status, sponsorships.probability
FROM sponsorships
JOIN sponsors ON sponsorships.sponsors_id=sponsors.id
WHERE (sponsorships.fundraising_type='$r->type' $orsql)
AND sponsorships.year='{$config['FAIRYEAR']}'
ORDER BY status DESC, probability DESC, organization");
while($sr=mysql_fetch_object($sq)) {
echo "<tr id=\"sponsorships_$sr->id\" class=\"fundraising{$sr->status}\">";
echo "<td>";
// echo "<a title=\"".i18n("Remove sponsorship")."\" onclick=\"return confirmClick('Are you sure you want to remove this sponsorship?')\" href=\"fundraising.php?action=sponsorshipdelete&delete=$sr->id\">";
echo "<img style=\"cursor:pointer;\" onclick=\"delete_sponsorship($sr->id)\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\">";
// echo "</a></nobr>";
echo "</td>";
echo "<td style=\"cursor: pointer;\" onclick=\"popup_sponsorship_editor('fundraising_sponsorship.php?id=$sr->id&fundraising_type=$r->type')\">";
//echo "<a title=\"".i18n("Edit sponsorship details")."\" onclick=\"return SFIABialog(event,'fundraising_sponsorship.php?id=$sr->id&fundraising_type=$r->type',400,250)\" href=\"#\">$sr->organization</a></td>\n";
echo "$sr->organization</td>\n";
/*
echo "<a href=\"communication.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
//only user emails can be deleted, system ones are required and cannot be removed
if($r->type=="user")
{
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove email?')\" href=\"communication.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a href=\"communication.php?action=send&send=$r->id\">Send</a>";
}
*/
echo "<td>$sr->status</td>";
echo "<td>";
if($sr->status=="pending")
{
echo "$sr->probability%";
echo "</td>";
echo "<td><nobr>".format_money($sr->value)."</nobr></td>";
}
else
echo "</td><td></td>\n";
$probval=$sr->probability/100*$sr->value;
echo "<td style=\"text-align: right\"><nobr>".format_money($probval)."</nobr></td>";
echo "<td></td>\n";
echo "</tr>\n";
$typeprobtotal+=$probval;
$typetotal+=$sr->value;
}
echo "<tr>";
echo "<td><a onclick=\"return popup_sponsorship_editor('fundraising_sponsorship.php?fundraising_type=$r->type')\" href=\"#\">add</a></td>";
echo "<td colspan=\"3\" style=\"text-align: right; font-weight: bold;\">".i18n("%1 Total",array($r->name),array("Fundraising type total, eg) Award Sponsorship Total"))."</td>\n";
echo "<td style=\"font-weight: bold; text-align: right;\"><nobr>".format_money($typetotal)."</nobr></td>\n";
echo "<td style=\"font-weight: bold; text-align: right;\"><nobr>".format_money($typeprobtotal)."</nobr></td>\n";
$typediff=$typeprobtotal-$r->goal;
echo "<td style=\"font-weight: bold; text-align: right;\"><nobr>".format_money($typediff)."</nobr></td>\n";
echo "</tr>\n";
$totalgoal+=$r->goal;
$totaldiff+=$typediff;
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>\n";
}
echo "<tr>";
echo "<td colspan=\"2\"><a onclick=\"return popup_fund_editor('fundraising_types.php')\" href=\"#\">add fund type</a></td>";
echo "<td colspan=\"4\" style=\"font-weight: bold; text-align: right;\">".i18n("Total Net Position")."</td><td style=\"text-align: right; font-weight: bold;\">".format_money($totaldiff)."</td></tr>\n";
echo "</table>\n";
exit;
}

View File

@ -29,20 +29,19 @@
if($_GET['id']) {
$id=intval($_GET['id']);
$q=mysql_query("SELECT sponsorships.*, sponsors.organization FROM sponsorships,sponsors WHERE sponsorships.id='$id' AND sponsorships.sponsors_id=sponsors.id");
echo "<h2>Edit Sponsorship</h2>";
$sponsorship=mysql_fetch_object($q);
$formaction="sponsorshipedit";
}
else
{
echo "<h2>Create New Sponsorship</h2>";
$formaction="sponsorshipadd";
$fundraising_type=$_GET['fundraising_type'];
}
echo "<form id=\"fundraisingsponsorship\">";
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
echo "<input type=\"hidden\" name=\"sponsorships_id\" value=\"$id\">";
echo "<table cellspacing=0 cellpadding=0 class=\"SFIABDialogTable\">";
echo "<table cellspacing=0 cellpadding=0 class=\"tableedit\">";
echo "<tr><th>".i18n("Sponsor")."</th>";
echo "<td>";
@ -101,5 +100,6 @@
echo "</td></tr>\n";
echo "</table>\n";
echo "</form>\n";
?>

View File

@ -1,8 +1,9 @@
<?
if($_GET['action']=="sponsorshipdelete") {
mysql_query("DELETE FROM sponsorships WHERE id='".intval($_GET['delete'])."'");
if($_POST['action']=="sponsorshipdelete") {
mysql_query("DELETE FROM sponsorships WHERE id='".intval($_POST['delete'])."'");
if(mysql_affected_rows())
message_push(happy(i18n("Successfully removed sponsorship")));
exit;
}
if($_POST['action']=="sponsorshipedit" || $_POST['action']=="sponsorshipadd") {
@ -59,7 +60,7 @@ if($_POST['action']=="sponsorshipedit") {
else {
message_push(error(i18n("Required fields were missing, please try again")));
}
exit;
}
if($_POST['action']=="sponsorshipadd") {
if($sponsors_id && $fundraising_type && $value) {
@ -75,6 +76,7 @@ if($_POST['action']=="sponsorshipadd") {
message_push(error(i18n("Required fields were missing, please try again")));
if(mysql_error())
message_push(error(mysql_error()));
exit;
}
?>

View File

@ -29,19 +29,19 @@
if($_GET['id']) {
$id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising WHERE id='$id'");
echo "<h2>Edit Fund</h2>";
// echo "<h2>Edit Fund</h2>";
$fund=mysql_fetch_object($q);
$formaction="fundedit";
}
else {
echo "<h2>Create New Fund</h2>";
// echo "<h2>Create New Fund</h2>";
$formaction="fundadd";
}
echo "<form id=\"fundraisingfundraising\">";
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
echo "<input type=\"hidden\" name=\"fundraising_id\" value=\"$id\">";
echo "<table class=\"SFIABDialogTable\">";
echo "<table class=\"tableedit\" style=\"width: 90%;\">";
if($fund->system=="yes") {
echo "<tr><th>".i18n("Type")."</th><td>".i18n("System (non-editable)")."</td></tr>\n";
echo "<tr><th>".i18n("Name")."</th><td>".htmlspecialchars($fund->name)."</td></tr>\n";
@ -55,5 +55,6 @@
echo "<tr><th>".i18n("Description")."</th><td><textarea style=\"width: 100%; height: 4em;\" name=\"description\">".htmlspecialchars($fund->description)."</textarea></td></tr>\n";
echo "<tr><th>".i18n("Goal")."</th><td><input type=\"text\" size=\"8\" name=\"goal\" value=\"$fund->goal\"></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
?>

View File

@ -1,7 +1,7 @@
<?
if($_GET['action']=="funddelete" && $_GET['delete']) {
if($_POST['action']=="funddelete" && $_POST['delete']) {
//first lookup all the sponsorships inside the fund
$id=intval($_GET['delete']);
$id=intval($_POST['delete']);
$q=mysql_query("SELECT * FROM fundraising WHERE id='$id' AND year='".$config['FAIRYEAR']."'");
$f=mysql_fetch_object($q);
//hold yer horses, no deleting system funds!
@ -16,6 +16,7 @@ if($_GET['action']=="funddelete" && $_GET['delete']) {
message_push(error(i18n("Cannot remove system fund")));
}
}
exit;
}
if($_POST['action']=="fundedit" || $_POST['action']=="fundadd") {
$fundraising_id=intval($_POST['fundraising_id']);
@ -46,6 +47,7 @@ if($_POST['action']=="fundedit") {
else {
message_push(error(i18n("Required fields were missing, please try again")));
}
exit;
}
if($_POST['action']=="fundadd") {
@ -57,6 +59,7 @@ if($_POST['action']=="fundadd") {
message_push(error(i18n("Required fields were missing, please try again")));
if(mysql_error())
message_push(error(mysql_error()));
exit;
}
?>

View File

@ -315,63 +315,6 @@ tr.externalaward {
}
.SFIABDialog {
font-size: 0.8em;
background-color: #EEEEFF;
border: 3px solid #5C6F90;
z-index: 140;
}
.SFIABDialogInner {
background-color: #EEEEFF;
margin: 4px;
padding: 4px;
z-index: 150;
}
#FadeScreenDiv {
filter:alpha(opacity=50);
-moz-opacity:.50;
opacity:.50;
position: fixed;
display: block;
visibility: hidden;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
z-index: 100;
background-color: black;
_background: none;
margin: 0px 0px 0px 0px;
clear: none;
}
.SFIABDialogTable {
border-spacing: 1px;
color: black;
margin-left: 20px;
margin-right: 20px;
font-size: 0.9em;
border: 0px;
border-collapse: collapse;
}
.SFIABDialogTable td {
border: 0px solid #5C6F90;
padding: 1px;
}
.SFIABDialogTable th {
border: 1px solid #5C6F90;
font-weight: bold;
text-align: left;
color: #FFFFFF;
background-color: #5C6F90;
padding: 2px;
}
div.notice_area {
position: fixed;
}