Add sponsorship levels editor

Add description to funrdaising types
Add description/benefits to sponsorship levels
This commit is contained in:
james 2008-11-06 21:06:40 +00:00
parent 5970cc2782
commit fb53a2cb2c
6 changed files with 86 additions and 7 deletions

View File

@ -43,7 +43,7 @@ require_once("../dialog.inc.php");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM fundraising WHERE year='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO fundraising (`type`,`name`,`system`,`goal`,`year`) VALUES ('$r->type','".mysql_real_escape_string($r->name)."','$r->system','$r->goal','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO fundraising (`type`,`name`,`description`,`system`,`goal`,`year`) VALUES ('$r->type','".mysql_real_escape_string($r->name)."','".mysql_real_escape_string($r->description)."','$r->system','$r->goal','".$config['FAIRYEAR']."')");
}
}
@ -53,7 +53,7 @@ require_once("../dialog.inc.php");
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',300,230)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
if($r->system=="no") {
echo "<a title=\"".i18n("Remove Fund")."\" onclick=\"return confirmClick('Are you sure you want to remove this fund and all sponsorships inside it?')\" href=\"fundraising.php?action=funddelete&delete=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
}
@ -129,7 +129,10 @@ require_once("../dialog.inc.php");
echo "</table>\n";
echo "<br />\n";
echo "<br />\n";
echo "<a href=\"sponsorship_levels.php\">Manage Sponsorship Levels</a>\n";
echo "<br />\n";
echo "<a href=\"sponsors.php\">Manage Sponsors</a>\n";
echo "<br />\n";
send_footer();
?>

View File

@ -52,6 +52,7 @@
echo "<tr><th>".i18n("Name")."</th><td><input type=\"text\" name=\"name\" value=\"".htmlspecialchars($fund->name)."\"></td></tr>\n";
echo "<tr><th>".i18n("Key")."</th><td><input type=\"text\" name=\"type\" value=\"".htmlspecialchars($fund->type)."\"></td></tr>\n";
}
echo "<tr><th>".i18n("Description")."</th><td><textarea style=\"width: 100%; height: 4em;\" name=\"description\">".htmlspecialchars($fund->description)."</textarea></td></tr>\n";
echo "<tr><th>".i18n("Goal")."</th><td><input type=\"text\" size=\"8\" name=\"goal\" value=\"$fund->goal\"></td></tr>\n";
echo "</table>\n";

View File

@ -26,16 +26,17 @@ if($_POST['action']=="fundedit" || $_POST['action']=="fundadd") {
}
$name=mysql_real_escape_string($_POST['name']);
$type=mysql_real_escape_string($_POST['type']);
$description=mysql_real_escape_string($_POST['description']);
$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'");
mysql_query("UPDATE fundraising SET goal='$goal', description='$description' WHERE id='$fundraising_id'");
}
else {
mysql_query("UPDATE fundraising SET goal='$goal', type='$type', name='$name' WHERE id='$fundraising_id'");
mysql_query("UPDATE fundraising SET goal='$goal', description='$description', type='$type', name='$name' WHERE id='$fundraising_id'");
}
if(mysql_error())
message_push(error(mysql_error()));
@ -49,7 +50,7 @@ if($_POST['action']=="fundedit") {
}
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']}')");
mysql_query("INSERT INTO fundraising (type,name,description,system,goal,year) VALUES ('$type','$name','$description','no','$goal','{$config['FAIRYEAR']}')");
message_push(happy(i18n("Added new fund")));
}
else

View File

@ -172,7 +172,10 @@
echo "<br />";
$q=mysql_query("SELECT * FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
WHERE year='".$config['FAIRYEAR']."' AND sponsors_id='$sponsors_id' ORDER BY lastname,firstname");
WHERE year='".$config['FAIRYEAR']."'
AND sponsors_id='$sponsors_id'
AND deleted='no'
ORDER BY lastname,firstname");
echo mysql_Error();
if(mysql_num_rows($q))

View File

@ -170,7 +170,7 @@
$numr=mysql_fetch_object($numq);
$numsponsorships=$numr->num;
$numq=mysql_query("SELECT COUNT(users_id) AS num FROM users_sponsor, users WHERE sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.year='".$config['FAIRYEAR']."'");
$numq=mysql_query("SELECT COUNT(users_id) AS num FROM users_sponsor, users WHERE sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.year='".$config['FAIRYEAR']."' and users.deleted='no'");
$numr=mysql_fetch_object($numq);
$numcontacts=$numr->num;

View File

@ -0,0 +1,71 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 James Grant <james@lightbox.org>
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.
*/
?>
<?
require("../common.inc.php");
require("../tableeditor.class.php");
require_once("../user.inc.php");
//first, insert any defaults
$q=mysql_query("SELECT * FROM sponsorships_levels WHERE year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM sponsorships_levels WHERE year='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO sponsorships_levels (`level`,`min`,`max`,`description`,`year`) VALUES (
'".mysql_real_escape_string($r->level)."',
'".mysql_real_escape_string($r->min)."',
'".mysql_real_escape_string($r->max)."',
'".mysql_real_escape_string($r->description)."',
'".$config['FAIRYEAR']."')");
}
}
user_auth_required('committee', 'admin');
send_header("Sponsorship Levels",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
"internal_document_management"
);
$editor=new TableEditor("sponsorships_levels",
array("level"=>"Level Name",
"min"=>"Minimum Amount",
"max"=>"Maximum Amount",
)
,
array("level"=>"Level Name",
"min"=>"Minimum Amount",
"max"=>"Maximum Amount",
"description"=>"Description / Benefits",
)
,array("year"=>$config['FAIRYEAR'])
);
$editor->setPrimaryKey("id");
$editor->setDefaultSortField("max");
$editor->setRecordType("Level");
$editor->filterList('year',$config['FAIRYEAR']);
$editor->execute();
send_footer();
?>