forked from science-ation/science-ation
200 lines
8.1 KiB
PHP
200 lines
8.1 KiB
PHP
<?
|
|
/*
|
|
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 - Award Contacts");
|
|
|
|
if($_GET['award_sponsors_id'])
|
|
$award_sponsors_id=$_GET['award_sponsors_id'];
|
|
else if($_POST['award_sponsors_id'])
|
|
$award_sponsors_id=$_POST['award_sponsors_id'];
|
|
?>
|
|
|
|
<?
|
|
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
|
echo "<a href=\"awards.php\"><< ".i18n("Back to Awards")."</a>\n";
|
|
|
|
$q=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization");
|
|
echo "<form method=\"get\" action=\"award_contacts.php\" name=\"sponsorchange\">";
|
|
echo "<select name=\"award_sponsors_id\" onchange=\"document.forms.sponsorchange.submit()\">";
|
|
echo "<option value=\"\">".i18n("Choose a sponsor to view contacts")."</option>";
|
|
while($r=mysql_fetch_object($q))
|
|
{
|
|
if($r->id == $award_sponsors_id)
|
|
{
|
|
$sel="selected=\"selected\"";
|
|
$award_sponsors_organization=$r->organization;
|
|
}
|
|
else
|
|
$sel="";
|
|
echo "<option $sel value=\"$r->id\">".i18n($r->organization)."</option>";
|
|
}
|
|
echo "</select>";
|
|
echo "</form>";
|
|
|
|
if($award_sponsors_id)
|
|
{
|
|
|
|
|
|
if($_POST['save']=="edit" || $_POST['save']=="add")
|
|
{
|
|
if($_POST['save']=="add")
|
|
{
|
|
$q=mysql_query("INSERT INTO award_contacts (award_sponsors_id,year) VALUES ('$award_sponsors_id','".$config['FAIRYEAR']."')");
|
|
$id=mysql_insert_id();
|
|
}
|
|
else
|
|
$id=$_POST['id'];
|
|
|
|
|
|
$exec="UPDATE award_contacts SET ".
|
|
"salutation='".mysql_escape_string(stripslashes($_POST['salutation']))."', ".
|
|
"firstname='".mysql_escape_string(stripslashes($_POST['firstname']))."', ".
|
|
"lastname='".mysql_escape_string(stripslashes($_POST['lastname']))."', ".
|
|
"position='".mysql_escape_string(stripslashes($_POST['position']))."', ".
|
|
"phonework='".mysql_escape_string(stripslashes($_POST['phonework']))."', ".
|
|
"phonecell='".mysql_escape_string(stripslashes($_POST['phonecell']))."', ".
|
|
"phonehome='".mysql_escape_string(stripslashes($_POST['phonehome']))."', ".
|
|
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
|
|
"email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
|
|
"notes='".mysql_escape_string(stripslashes($_POST['notes']))."' ".
|
|
"WHERE id='$id'";
|
|
mysql_query($exec);
|
|
|
|
if($_POST['save']=="add")
|
|
echo happy("Contact successfully added");
|
|
else
|
|
echo happy("Successfully saved changes to contact");
|
|
}
|
|
|
|
if($_GET['action']=="delete" && $_GET['delete'])
|
|
{
|
|
mysql_query("DELETE FROM award_contacts WHERE id='".$_GET['delete']."'");
|
|
echo happy("Contact successfully deleted");
|
|
}
|
|
|
|
if($_GET['action']=="edit" || $action=="add")
|
|
{
|
|
|
|
echo "<a href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id\"><< ".i18n("Back to %1 Contacts",array($award_sponsors_organization))."</a>\n";
|
|
if($_GET['action']=="edit")
|
|
{
|
|
echo "<h3>".i18n("Edit %1 Contact",array($award_sponsors_organization))."</h3>\n";
|
|
$buttontext="Save Contact";
|
|
$q=mysql_query("SELECT * FROM award_contacts WHERE id='".$_GET['edit']."'");
|
|
$r=mysql_fetch_object($q);
|
|
}
|
|
else if($action=="add")
|
|
{
|
|
echo "<h3>".i18n("Add %1 Contact",array($award_sponsors_organization))."</h3>\n";
|
|
$buttontext="Add Contact";
|
|
}
|
|
$buttontext=i18n($buttontext);
|
|
|
|
echo "<form method=\"post\" action=\"award_contacts.php\">\n";
|
|
echo "<input type=\"hidden\" name=\"award_sponsors_id\" value=\"$award_sponsors_id\">\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("Salutation")."</td><td><input type=\"text\" name=\"salutation\" value=\"".htmlspecialchars($r->salutation)."\" size=\"4\" maxlength=\"8\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname\" value=\"".htmlspecialchars($r->firstname)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname\" value=\"".htmlspecialchars($r->lastname)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("Position")."</td><td><input type=\"text\" name=\"position\" value=\"".htmlspecialchars($r->position)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("Phone (Work)")."</td><td><input type=\"text\" name=\"phonework\" value=\"".htmlspecialchars($r->phonework)."\" size=\"16\" maxlength=\"16\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("Phone (Cell)")."</td><td><input type=\"text\" name=\"phonecell\" value=\"".htmlspecialchars($r->phonecell)."\" size=\"16\" maxlength=\"16\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("Phone (Home)")."</td><td><input type=\"text\" name=\"phonehome\" value=\"".htmlspecialchars($r->phonehome)."\" 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("Email")."</td><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($r->email)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
|
echo "<tr><td>".i18n("Notes")."</td><td><textarea name=\"notes\" rows=\"8\" cols=\"60\">".htmlspecialchars($r->notes)."</textarea></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=\"award_contacts.php?award_sponsors_id=$award_sponsors_id&action=add\">".i18n("Add New Contact to %1",array($award_sponsors_organization))."</a>\n";
|
|
echo "<br />";
|
|
|
|
$q=mysql_query("SELECT * FROM award_contacts WHERE year='".$config['FAIRYEAR']."' AND award_sponsors_id='$award_sponsors_id' ORDER BY lastname,firstname");
|
|
|
|
if(mysql_num_rows($q))
|
|
{
|
|
echo "<table class=\"summarytable\">";
|
|
echo "<tr>";
|
|
echo " <th>".i18n("Name")."</th>";
|
|
echo " <th>".i18n("Email")."</th>";
|
|
echo " <th>".i18n("Phone (Work)")."</th>";
|
|
echo " <th>".i18n("Phone (Cell)")."</th>";
|
|
echo " <th>Actions</th>";
|
|
echo "</tr>\n";
|
|
|
|
|
|
while($r=mysql_fetch_object($q))
|
|
{
|
|
echo "<tr>\n";
|
|
echo " <td>";
|
|
if($r->salutation) echo $r->salutation." ";
|
|
echo "$r->firstname $r->lastname</td>\n";
|
|
echo " <td>";
|
|
if($r->email)
|
|
{
|
|
list($eb,$ea)=split("@",$r->email);
|
|
echo "<script language=\"javascript\" type=\"text/javascript\">em('$eb','$ea')</script>";
|
|
}
|
|
else
|
|
echo " ";
|
|
|
|
echo "</td>";
|
|
echo " <td>$r->phonework</td>\n";
|
|
echo " <td>$r->phonecell</td>\n";
|
|
echo " <td align=\"center\">";
|
|
echo "<a href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id&action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
|
|
echo " ";
|
|
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this contact?')\" href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id&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();
|
|
|
|
?>
|