This commit is contained in:
james 2005-05-13 17:36:01 +00:00
parent a32964de2d
commit 2e125d263c
2 changed files with 163 additions and 0 deletions

View File

@ -32,6 +32,7 @@
echo "<hr />";
echo "<a href=\"committees.php\">Committee Management</a> <br />";
echo "<a href=\"awards.php\">Awards Management</a> <br />";
echo "<a href=\"schools.php\">School Management</a> <br />";
echo "<a href=\"judges.php\">Judging Management</a> <br />";
echo "<hr />";
echo "<a href=\"winners.php\">Enter Winning Projects</a> <br />";

162
admin/schools.php Normal file
View File

@ -0,0 +1,162 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 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");
auth_required('admin');
send_header("Administration - Schools");
?>
<?
echo "<a href=\"index.php\">&lt;&lt; ".i18n("Back to Administration")."</a>\n";
if($_POST['save']=="edit" || $_POST['save']=="add")
{
if($_POST['save']=="add")
{
$q=mysql_query("INSERT INTO schools (year) VALUES ('".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
}
else
$id=$_POST['id'];
$exec="UPDATE schools SET ".
"school='".mysql_escape_string(stripslashes($_POST['school']))."', ".
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
"city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
"province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
"phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
"sciencehead='".mysql_escape_string(stripslashes($_POST['sciencehead']))."', ".
"scienceheadphone='".mysql_escape_string(stripslashes($_POST['scienceheadphone']))."', ".
"scienceheademail='".mysql_escape_string(stripslashes($_POST['scienceheademail']))."', ".
"accesscode='".mysql_escape_string(stripslashes($_POST['accesscode']))."' ".
"WHERE id='$id'";
mysql_query($exec);
echo mysql_error();
if($_POST['save']=="add")
echo happy("School successfully added");
else
echo happy("Successfully saved changes to school");
}
if($_GET['action']=="delete" && $_GET['delete'])
{
mysql_query("DELETE FROM schools WHERE id='".$_GET['delete']."'");
echo happy("School successfully deleted");
}
if($_GET['action']=="edit" || $action=="add")
{
echo "<a href=\"schools.php\">&lt;&lt; ".i18n("Back to Schools")."</a>\n";
if($_GET['action']=="edit")
{
echo "<h3>".i18n("Edit School")."</h3>\n";
$buttontext="Save School";
$q=mysql_query("SELECT * FROM schools WHERE id='".$_GET['edit']."'");
$r=mysql_fetch_object($q);
}
else if($action=="add")
{
echo "<h3>".i18n("Add New School")."</h3>\n";
$buttontext="Add School";
}
$buttontext=i18n($buttontext);
echo "<form method=\"post\" action=\"schools.php\">\n";
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
if($_GET['action']=="edit")
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("School Name")."</td><td><input type=\"text\" name=\"school\" value=\"".htmlspecialchars($r->school)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><td>".i18n("Address")."</td><td><input type=\"text\" name=\"address\" value=\"".htmlspecialchars($r->address)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><td>".i18n("City")."</td><td><input type=\"text\" name=\"city\" value=\"".htmlspecialchars($r->city)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Province")."</td><td>";
emit_province_selector("province_code",$r->province_code);
echo "</td></tr>\n";
echo "<tr><td>".i18n("Postal Code")."</td><td><input type=\"text\" name=\"postalcode\" value=\"$r->postalcode\" size=\"8\" maxlength=\"7\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone")."</td><td><input type=\"text\" name=\"phone\" value=\"".htmlspecialchars($r->phone)."\" size=\"16\" maxlength=\"16\" /></td></tr>\n";
echo "<tr><td>".i18n("Fax")."</td><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($r->fax)."\" size=\"16\" maxlength=\"16\" /></td></tr>\n";
echo "<tr><td>".i18n("Access Code")."</td><td><input type=\"text\" name=\"accesscode\" value=\"".htmlspecialchars($r->accesscode)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td colspan=2><br /><b>".i18n("Science head/teacher or science fair contact at school")."</b></td></tr>";
echo "<tr><td>".i18n("Name")."</td><td><input type=\"text\" name=\"sciencehead\" value=\"".htmlspecialchars($r->sciencehead)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone")."</td><td><input type=\"text\" name=\"scienceheadphone\" value=\"".htmlspecialchars($r->scienceheadphone)."\" size=\"16\" maxlength=\"16\" /></td></tr>\n";
echo "<tr><td>".i18n("Email")."</td><td><input type=\"text\" name=\"scienceheademail\" value=\"".htmlspecialchars($r->scienceheademail)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
else
{
echo "<br />";
echo "<a href=\"schools.php?action=add\">Add New School</a>\n";
echo "<br />";
echo "<table class=\"summarytable\">";
echo "<tr>";
echo " <th>School</th>";
echo " <th>Address</th>";
echo " <th>Phone</th>";
echo " <th>Contact</th>";
echo " <th>Action</th>";
echo "</tr>\n";
$q=mysql_query("SELECT * FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER BY school");
while($r=mysql_fetch_object($q))
{
echo "<tr>\n";
echo " <td>$r->school</td>\n";
echo " <td>$r->address, $r->city, $r->postalcode</td>\n";
echo " <td>$r->phone</td>\n";
echo " <td>$r->sciencehead</td>\n";
echo " <td align=\"center\">";
echo "<a href=\"schools.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this school?')\" href=\"schools.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo " </td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
send_footer();
?>