forked from science-ation/science-ation
Factor form handler into separate files for each of the dialog forms
Add form handling for fundraising types
This commit is contained in:
parent
b62fa76aab
commit
1d09e7fb38
@ -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 "<table class=\"fundraisingtable\">";
|
||||
/*
|
||||
echo "<tr>";
|
||||
echo " <th colspan=\"2\">".i18n("Fund")."</th>\n";
|
||||
echo " <th>".i18n("Goal")."</th>\n";
|
||||
echo "</tr>\n";
|
||||
*/
|
||||
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
echo "<tr>";
|
||||
echo "<th width=\"30\"><a onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',300,200)\" href=\"#\">edit</a></th>\n";
|
||||
|
39
admin/fundraising_sponsorship_handler.inc.php
Normal file
39
admin/fundraising_sponsorship_handler.inc.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?
|
||||
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()));
|
||||
}
|
||||
|
||||
?>
|
43
admin/fundraising_types_handler.inc.php
Normal file
43
admin/fundraising_types_handler.inc.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?
|
||||
if($_POST['action']=="fundedit" || $_POST['action']=="fundadd") {
|
||||
$fundraising_id=intval($_POST['fundraising_id']);
|
||||
if($fundraising_id) {
|
||||
$q=mysql_query("SELECT * FROM fundraising WHERE id='$fundraising_id'");
|
||||
$f=mysql_fetch_object($q);
|
||||
$system=$f->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()));
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user