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 "
\n";
+ echo "
+
+ }
+ ?>
+
+
+
+
+ exit;
+ break;
}
function save_campaign_info(){
- if($_POST["campaign_id"] == -1){
- // this is a new campaign. let's create it.
+ global $config;
+ if(!$_POST['name']){
+ error_("Campaign Name is required");
+ return;
+ }
+ if(!$_POST['startdate']) $startdate=date("Y-m-d"); else $startdate=$_POST['startdate'];
- // first, we'll make sure we have some reasonable data
- if(array_key_exists('name', $_POST)) $name = $_POST['name'];
- if($name == NULL) $name = i18n("New Campaign");
-
- if(array_key_exists('startdate', $_POST)) $startdate = $_POST['startdate'];
- if($startdate == NULL) $startdate = date("Y-m-d");
-
- if(array_key_exists('enddate', $_POST)) $enddate = $_POST['enddate'];
- if($enddate == NULL) $enddate = date("Y-m-d");
-
- // now we need to create some default data to fill the record
- $type = ""; //FIXME - these need more sensible and controlled values
- $active = "yes";
- $target = 0;
- $goal_id = "";
- $fiscalyear = $config['FISCALYEAR'];
-
- $query = "INSERT INTO fundraising_campaigns (name, type, startdate, enddate, followupdate, active, target, fundraising_goal, fiscalyear) VALUES (
- '$campagin_name,'$type','$startdate',
- '$enddate',
- DATE_ADD('$startdate', INTERVAL 1 MONTH),
- '$active',
- '$target',
- '$goal_id',
- '$fiscalyear')";
-
- mysql_query($query);
-
- // Let's grab the new campaign ID for further use
+ if(!$_GET['id']) {
+ $query = "INSERT INTO fundraising_campaigns (name,fiscalyear) VALUES (
+ '".mysql_real_escape_string($_POST['name'])."','{$config['FISCALYEAR']}')";
+ mysql_query($query);
$id = mysql_insert_id();
- echo json_encode(array("id"=>$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",
-