From 1d09e7fb38c162f7c1cf24a04b0e884854f92f04 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 24 Oct 2008 22:46:35 +0000 Subject: [PATCH] Factor form handler into separate files for each of the dialog forms Add form handling for fundraising types --- admin/fundraising.php | 47 ++----------------- admin/fundraising_sponsorship_handler.inc.php | 39 +++++++++++++++ admin/fundraising_types_handler.inc.php | 43 +++++++++++++++++ 3 files changed, 86 insertions(+), 43 deletions(-) create mode 100644 admin/fundraising_sponsorship_handler.inc.php create mode 100644 admin/fundraising_types_handler.inc.php diff --git a/admin/fundraising.php b/admin/fundraising.php index 7716481..fea53f4 100644 --- a/admin/fundraising.php +++ b/admin/fundraising.php @@ -26,43 +26,9 @@ require_once("../user.inc.php"); user_auth_required('committee', 'admin'); -if($_POST['action']=="sponsorshipedit" || $_POST['action']=="sponsorshipadd") { - $sponsors_id=intval($_POST['sponsors_id']); - $sponsorships_id=intval($_POST['sponsorships_id']); - $fundraising_type=mysql_real_escape_string($_POST['fundraising_type']); - - $value=mysql_real_escape_string($_POST['value']); - $status=mysql_real_escape_string($_POST['status']); - $probability=mysql_real_escape_string($_POST['probability']); - - if($status=="confirmed" || $status=="received") $probability="100"; - if($probability==100 && $status=="pending") $status="confirmed"; -} - -if($_POST['action']=="sponsorshipedit") { - if($sponsorships_id && $sponsors_id && $fundraising_type && $value) { - mysql_query("UPDATE sponsorships SET sponsors_id='$sponsors_id', fundraising_type='$fundraising_type', value='$value', status='$status', probability='$probability' WHERE id='$sponsorships_id'"); - if(mysql_error()) - message_push(error(mysql_error())); - else - message_push(happy(i18n("Saved sponsorship changes"))); - } - else { - message_push(error(i18n("Required fields were missing, please try again"))); - } - -} -if($_POST['action']=="sponsorshipadd") { - if($sponsors_id && $fundraising_type && $value) { - mysql_query("INSERT INTO sponsorships (sponsors_id,fundraising_type,value,status,probability,year) VALUES ('$sponsors_id','$fundraising_type','$value','$status','$probability','{$config['FAIRYEAR']}')"); - message_push(happy(i18n("Added new sponsorship"))); - } - else - message_push(error(i18n("Required fields were missing, please try again"))); - if(mysql_error()) - message_push(error(mysql_error())); -} - + + include ("fundraising_sponsorship_handler.inc.php"); + include ("fundraising_types_handler.inc.php"); send_header("Fundraising", array('Committee Main' => 'committee_main.php', @@ -84,12 +50,7 @@ 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,type"); echo ""; - /* - echo ""; - echo " \n"; - echo " \n"; - echo "\n"; - */ + while($r=mysql_fetch_object($q)) { echo ""; echo "\n"; diff --git a/admin/fundraising_sponsorship_handler.inc.php b/admin/fundraising_sponsorship_handler.inc.php new file mode 100644 index 0000000..5725b24 --- /dev/null +++ b/admin/fundraising_sponsorship_handler.inc.php @@ -0,0 +1,39 @@ + diff --git a/admin/fundraising_types_handler.inc.php b/admin/fundraising_types_handler.inc.php new file mode 100644 index 0000000..0e51ca4 --- /dev/null +++ b/admin/fundraising_types_handler.inc.php @@ -0,0 +1,43 @@ +system; + } + $name=mysql_real_escape_string($_POST['name']); + $type=mysql_real_escape_string($_POST['type']); + $goal=intval($_POST['goal']); +} + +if($_POST['action']=="fundedit") { + if( ($system=="yes" && $goal) || ($system=="no" && $goal && $type && $name) ) { + if($system=="yes") { + mysql_query("UPDATE fundraising SET goal='$goal' WHERE id='$fundraising_id'"); + } + else { + mysql_query("UPDATE fundraising SET goal='$goal', type='$type', name='$name' WHERE id='$fundraising_id'"); + } + if(mysql_error()) + message_push(error(mysql_error())); + else + message_push(happy(i18n("Saved fund changes"))); + } + else { + message_push(error(i18n("Required fields were missing, please try again"))); + } + +} +if($_POST['action']=="fundadd") { + if( $goal && $type && $name) { + mysql_query("INSERT INTO fundraising (type,name,system,goal,year) VALUES ('$type','$name','no','$goal','{$config['FAIRYEAR']}')"); + message_push(happy(i18n("Added new fund"))); + } + else + message_push(error(i18n("Required fields were missing, please try again"))); + if(mysql_error()) + message_push(error(mysql_error())); +} + +?>
".i18n("Fund")."".i18n("Goal")."
id',300,200)\" href=\"#\">edit