This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?> prepare("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='".$config['FISCALYEAR']."'"); $q->execute(); if(!$q->rowCount()) { $q=$pdo->prepare("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='-1'"); $q->execute(); while($r=$q->fetch(PDO::FETCH_OBJ)) { $pdo->prepare("INSERT INTO fundraising_donor_levels (`level`,`min`,`max`,`description`,`fiscalyear`) VALUES ( '".$r->level."', '".$r->min."', '".$r->max."', '".$r->description."', '".$config['FISCALYEAR'].")')"); $pdo->execute(); } } //first, insert any default fundraising goals $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE fiscalyear='".$config['FISCALYEAR']."'"); $q->execute(); if(!$q->rowCount()) { $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE fiscalyear='-1'"); $q->execute(); while($r=$q->fetch(PDO::FETCH_OBJ)) { $stmt = pdo->prepare("INSERT INTO fundraising_goals (`goal`,`name`,`description`,`system`,`budget`,`fiscalyear`) VALUES ( '".stripslashes($r->goal)."', '".stripslashes($r->name)."', '".stripslashes($r->description)."', '".$r->system."', '".$r->budget."', '".$config['FISCALYEAR']."')"); $stmt->execute(); } } switch(get_value_from_array($_GET, 'gettab')) { case "levels": $q=$pdo->prepare("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY max"); $q->execute(); echo "
\n"; while($r=$q->fetch(PDO::FETCH_OBJ)) { echo "

$r->level (".format_money($r->min,false)." to ".format_money($r->max,false).")

\n"; echo "
id\">\n"; echo "
id\" onsubmit=\"return level_save($r->id)\">\n"; echo "id\">\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo i18n("Level Name").":level)."\">
"; echo i18n("Value Range").":\$min\"> to \$max\">
\n"; echo "
"; echo i18n("Description/Benefits").":
"; echo "
\n"; echo "
"; echo ""; echo ""; echo "id)\" >"; echo "
\n"; echo "
"; echo "
\n"; } echo "

Create New Level

\n"; echo "
\n"; echo "
\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo i18n("Level Name").":
"; echo i18n("Value Range").":\$ to \$
\n"; echo "
"; echo i18n("Description/Benefits").":
"; echo "
\n"; echo "
"; echo ""; echo ""; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; exit; break; case "goals": $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name"); $q->execute(); echo "
\n"; while($r=$q->fetch(PDO::FETCH_OBJ)) { echo "

$r->name (".format_money($r->budget,false).") Deadline: ".format_date($r->deadline)."

\n"; echo "
id\">\n"; echo "
id\" onsubmit=\"return goal_save($r->id)\">\n"; echo "id\">\n"; echo ""; echo "\n"; echo ""; echo ""; echo "\n"; echo "
"; echo i18n("Purpose").":name)."\">
"; echo i18n("Budget Amount").":\$budget\">
"; echo i18n("Deadline").":deadline\">
"; echo i18n("Description").":
"; echo "
\n"; echo "
"; echo ""; echo ""; echo "id)\" >"; echo "
\n"; echo "
"; echo "
\n"; } echo "

Create New Purpose

\n"; echo "
\n"; echo "
\n"; echo ""; echo "\n"; echo ""; echo ""; echo "\n"; echo "
"; echo i18n("Purpose Name").":
"; echo i18n("Budget Amount").":\$
"; echo i18n("Deadline").":
"; echo i18n("Description").":
"; echo "
\n"; echo "
"; echo ""; echo ""; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; exit; break; case "setup": echo "
"; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo ""; echo ""; echo "\n"; echo "
".i18n("Current Fiscal Year").""; echo $config['FISCALYEAR']; echo "
".i18n("Fiscal Year End").""; list($month,$day)=explode("-",$config['fiscal_yearend']); emit_month_selector("fiscalendmonth",$month); emit_day_selector("fiscalendday",$day); echo "
".i18n("Is your organization a registered charity?").""; if($config['registered_charity']=="yes") $ch="checked=\"checked\""; else $ch=""; echo ""; echo "   "; if($config['registered_charity']=="no") $ch="checked=\"checked\""; else $ch=""; echo ""; echo "
".i18n("Charity Registration Number")."
\n"; echo "
\n"; exit; break; } switch(get_value_from_array($_GET, 'action')) { case "level_save": $id=$_POST['id']; if(! ($_POST['level'] && $_POST['min'] && $_POST['max'])) { error_("Level name, minimum and maximum value range are required"); exit; } if($_POST['min']>=$_POST['max']) { error_("Value range minimum must be smaller than range maximum"); exit; } if($id) { $stmt = $pdo->prepare("UPDATE fundraising_donor_levels SET min='".$_POST['min']."', max='".$_POST['max']."', level='".stripslashes($_POST['level'])."', description='".stripslashes($_POST['description'])."' WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}' "); $stmt->execute(); happy_("Level Saved"); } else { $stmt = $pdo->prepare("INSERT INTO fundraising_donor_levels (`level`,`min`,`max`,`description`,`fiscalyear`) VALUES ( '".$_POST['level']."', '".$_POST['min']."', '".$_POST['max']."', '".$_POST['description']."', '{$config['FISCALYEAR']}')"); $stmt->execute(); happy_("Level Created"); } exit; break; case "level_delete": $id=$_POST['id']; $stmt = $pdo->prepare("DELETE FROM fundraising_donor_levels WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'"); $stmt->execute(); happy_("Level Deleted"); exit; break; case "goal_save": $id=$_POST['id']; if(! ($_POST['name'] && $_POST['budget'])) { error_("Purpose name and budget are required"); exit; } if($id) { $stmt = $pdo->prepare("UPDATE fundraising_goals SET budget='".$_POST['budget']."', deadline='".$_POST['deadline']."', name='".stripslashes($_POST['name'])."', description='".stripslashes($_POST['description'])."' WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}' "); $stmt->execute(); happy_("Purpose Saved"); } else { $goal=strtolower($_POST['name']); $goal=ereg_replace("[^a-z]","",$goal); $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}'"); $q->execute(); echo $pdo->errorInfo(); if($q->rowCount()) { error_("The automatically generated purpose key (%1) generated from (%2) is not unique. Please try a different Purpose Name",array($goal,$_POST['name'])); exit; } $stmt = $pdo->prepare("INSERT INTO fundraising_goals (`goal`,`name`,`budget`,`deadline`,`description`,`fiscalyear`) VALUES ( '".$goal."', '".$_POST['name']."', '".$_POST['budget']."', '".$_POST['deadline']."', '".$_POST['description']."', '{$config['FISCALYEAR']}')"); $stmt->execute(); happy_("Purpose Created"); } exit; break; case "goal_delete": $id=$_POST['id']; //they cant delete system ones $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'"); $q->execute(); if(!$r=$q->fetch(PDO::FETCH_OBJ)) { error_("Invalid goal to delete"); exit; } if($r->system=="yes") { error_("Fundraising goals created automatically and used by the system cannot be deleted"); exit; } $q=$pdo->prepare("SELECT * FROM fundraising_donations WHERE fundraising_goal='$r->goal' AND fiscalyear='{$config['FISCALYEAR']}'"); $q->execute(); if($q->rowCount()) { error_("This goal already has donations assigned to it, it cannot be deleted"); exit; } $stmt = $pdo->prepare("DELETE FROM fundraising_goals WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'"); $stmt->execute(); happy_("Purpose Deleted"); exit; break; case "setup_save": $fye=sprintf("%02d-%02d",intval($_POST['fiscalendmonth']),intval($_POST['fiscalendday'])); $stmt = $pdo->prepare("UPDATE config SET val='$fye' WHERE var='fiscal_yearend' AND year='{$config['FAIRYEAR']}'"); $stmt->execute(); $stmt = $pdo->prepare("UPDATE config SET val='".$_POST['registeredcharity']."' WHERE var='registered_charity' AND year='{$config['FAIRYEAR']}'"); $stmt->execute(); $stmt = $pdo->prepare("UPDATE config SET val='".$_POST['charitynumber']."' WHERE var='charity_number' AND year='{$config['FAIRYEAR']}'"); $stmt->execute(); happy_("Fundraising module setup saved"); exit; break; } send_header("Fundraising Setup", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Fundraising' => 'admin/fundraising.php') ); ?>