From 087e89248ad4cd6b069fce3e7a8857cace712b69 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 7 Oct 2009 19:43:58 +0000 Subject: [PATCH] Working campaign editor --- admin/fundraising_campaigns.php | 212 +++++++++++++++++--------------- 1 file changed, 115 insertions(+), 97 deletions(-) diff --git a/admin/fundraising_campaigns.php b/admin/fundraising_campaigns.php index e229dbe..7b92ca7 100644 --- a/admin/fundraising_campaigns.php +++ b/admin/fundraising_campaigns.php @@ -24,71 +24,82 @@ require("../common.inc.php"); require_once("../user.inc.php"); user_auth_required('committee', 'admin'); + switch($_GET['action']){ case "campaigninfo_save": save_campaign_info(); exit; break; + + case "display": + echo "
\n"; + $q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name"); + while($r=mysql_fetch_object($q)) { + echo "

".htmlspecialchars($r->name)."

\n"; + echo "
id}\">\n"; + echo "
id}\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" onsubmit=\"return campaigninfo_save($r->id)\">\n"; + echo "id}\" />\n"; + echo "\n"; + display_campaign_form($r); + ?> + + +
+
+ ">
+
+
+ +

+
+
+ + + + + +
+
+ ">
+
+
+
+ $id)); - + happy_("Campaign Created"); }else{ - $id = $_POST["campaign_id"]; - // we are updating an existing campaign. - echo "Updating an existing campaign
\n"; - - // build our query - $formfields = array('name', 'type', 'startdate', 'enddate', 'active', 'target', 'fundraising_goal', 'fiscalyear'); - $updates = false; - $query = "UPDATE fundraising_campaigns SET "; - foreach($formfields AS $fieldname){ - if(array_key_exists($fieldname, $_POST)){ - $updates = true; - $query .= $fieldName . "='" . mysql_escape_string(stripslashes($_POST[$fieldname])) . ","; - } - } - if($updates = true){ - $query = rtrim($query, ",") . " WHERE id=" . $id; - } - - // and execute it - echo $query; //FIXME - not yet tested - } + $id = $_GET["id"]; + happy_("Campaign Saved"); + } + mysql_query("UPDATE fundraising_campaigns SET + name='".mysql_real_escape_string($_POST['name'])."', + `type`='".mysql_real_escape_string($_POST['type'])."', + startdate='".mysql_real_escape_string($startdate)."', + followupdate='".mysql_real_escape_string($_POST['followupdate'])."', + enddate='".mysql_real_escape_string($_POST['enddate'])."', + target='".mysql_real_escape_string($_POST['target'])."', + fundraising_goal='".mysql_real_escape_string($_POST['fundraising_goal'])."' + WHERE id='$id'"); } send_header("Campaign Management", @@ -101,67 +112,74 @@ send_header("Campaign Management", -
-

-
-
- + - - - - - - - - -
"/>">
- -
-
+ + + + + startdate) $sd=$r->startdate; + else $sd=date("Y-m-d"); + ?> + + + + + + + $ + + "; + echo "\n"; + while($fgr=mysql_fetch_object($fgq)) { + if($r->fundraising_goal==$fgr->goal) $sel="selected=\"selected\""; else $sel=""; + echo "\n"; + } + echo "\n"; + ?> + + + -

Campaign 123

-
-
+
+