2009-09-09 00:26:12 +00:00
< ?
2009-09-17 21:48:57 +00:00
if ( $_POST [ 'action' ] == " funddelete " && $_POST [ 'delete' ]) {
2009-09-09 00:26:12 +00:00
//first lookup all the sponsorships inside the fund
2009-09-17 21:48:57 +00:00
$id = intval ( $_POST [ 'delete' ]);
2009-10-02 16:46:13 +00:00
$q = mysql_query ( " SELECT * FROM fundraising_goals WHERE id=' $id ' AND year=' " . $config [ 'FISCALYEAR' ] . " ' " );
2009-09-09 00:26:12 +00:00
$f = mysql_fetch_object ( $q );
//hold yer horses, no deleting system funds!
if ( $f ) {
if ( $f -> system == " no " ) {
2009-10-02 16:46:13 +00:00
mysql_query ( " DELETE FROM fundraising_donations WHERE fundraising_goal=' " . mysql_real_escape_string ( $f -> type ) . " ' AND fiscalyear=' " . $config [ 'FISCALYEAR' ] . " ' " );
mysql_query ( " DELETE FROM fundraising_goals WHERE id=' $id ' " );
2009-09-09 00:26:12 +00:00
if ( mysql_affected_rows ())
2009-09-18 19:25:26 +00:00
happy_ ( " Successfully removed fund %1 " , array ( $f -> name ));
2009-09-09 00:26:12 +00:00
}
else {
2009-09-18 19:25:26 +00:00
error_ ( " Cannot remove system fund " );
2009-09-09 00:26:12 +00:00
}
}
2009-09-17 21:48:57 +00:00
exit ;
2009-09-09 00:26:12 +00:00
}
if ( $_POST [ 'action' ] == " fundedit " || $_POST [ 'action' ] == " fundadd " ) {
$fundraising_id = intval ( $_POST [ 'fundraising_id' ]);
if ( $fundraising_id ) {
2009-10-02 16:46:13 +00:00
$q = mysql_query ( " SELECT * FROM fundraising_goals WHERE id=' $fundraising_id ' " );
2009-09-09 00:26:12 +00:00
$f = mysql_fetch_object ( $q );
$system = $f -> system ;
}
$name = mysql_real_escape_string ( $_POST [ 'name' ]);
2009-10-02 16:46:13 +00:00
$goal = mysql_real_escape_string ( $_POST [ 'goal' ]);
2009-09-09 00:26:12 +00:00
$description = mysql_real_escape_string ( $_POST [ 'description' ]);
2009-10-02 16:46:13 +00:00
$budget = intval ( $_POST [ 'budget' ]);
2009-09-09 00:26:12 +00:00
}
if ( $_POST [ 'action' ] == " fundedit " ) {
2009-10-02 16:46:13 +00:00
if ( ( $system == " yes " && $budget ) || ( $system == " no " && $budget && $goal && $name ) ) {
2009-09-09 00:26:12 +00:00
if ( $system == " yes " ) {
2009-10-02 16:46:13 +00:00
mysql_query ( " UPDATE fundraising SET budget=' $budget ', description=' $description ' WHERE id=' $fundraising_id ' " );
2009-09-09 00:26:12 +00:00
}
else {
2009-10-02 16:46:13 +00:00
mysql_query ( " UPDATE fundraising SET budget=' $budget ', description=' $description ', goal=' $goal ', name=' $name ' WHERE id=' $fundraising_id ' " );
2009-09-09 00:26:12 +00:00
}
if ( mysql_error ())
2009-09-18 19:25:26 +00:00
error_ ( " MySQL Error: %1 " , array ( mysql_error ()));
2009-09-09 00:26:12 +00:00
else
2009-09-18 19:25:26 +00:00
happy_ ( " Saved fund changes " );
2009-09-09 00:26:12 +00:00
}
else {
2009-09-18 19:25:26 +00:00
error_ ( " Required fields were missing, please try again " );
2009-09-09 00:26:12 +00:00
}
2009-09-17 21:48:57 +00:00
exit ;
2009-09-09 00:26:12 +00:00
}
if ( $_POST [ 'action' ] == " fundadd " ) {
if ( $goal && $type && $name ) {
2009-10-02 16:46:13 +00:00
mysql_query ( " INSERT INTO fundraising_goals (goal,name,description,system,budget,fiscalyear) VALUES (' $goal ',' $name ',' $description ','no',' $budget ',' { $config [ 'FISCALYEAR' ] } ') " );
2009-09-18 19:25:26 +00:00
happy_ ( " Added new fund " );
2009-09-09 00:26:12 +00:00
}
else
2009-09-18 19:25:26 +00:00
error_ ( " Required fields were missing, please try again " );
2009-09-09 00:26:12 +00:00
if ( mysql_error ())
2009-09-18 19:25:26 +00:00
error_ ( " MySQL Error: %1 " , array ( mysql_error ()));
2009-09-17 21:48:57 +00:00
exit ;
2009-09-09 00:26:12 +00:00
}
?>