2005-02-23 23:00:45 +00:00
< ?
/*
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 " );
2007-11-21 17:02:09 +00:00
require_once ( " ../user.inc.php " );
2007-11-18 23:50:23 +00:00
user_auth_required ( 'committee' , 'admin' );
2005-02-23 23:00:45 +00:00
2007-11-18 23:50:23 +00:00
send_header ( " Award Contacts " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
2007-12-05 15:54:12 +00:00
'Awards Main' => 'admin/awards.php' ,
2007-12-06 04:03:32 +00:00
'Awards Sponsors' => 'admin/award_sponsors.php' ));
2005-02-23 23:00:45 +00:00
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' ];
?>
< ?
$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 " .
2006-10-16 03:36:39 +00:00
" salutation=' " . mysql_escape_string ( stripslashes ( $_POST [ 'salutation' ])) . " ', " .
2005-02-23 23:00:45 +00:00
" firstname=' " . mysql_escape_string ( stripslashes ( $_POST [ 'firstname' ])) . " ', " .
" lastname=' " . mysql_escape_string ( stripslashes ( $_POST [ 'lastname' ])) . " ', " .
2006-09-20 16:24:52 +00:00
" position=' " . mysql_escape_string ( stripslashes ( $_POST [ 'position' ])) . " ', " .
2005-02-23 23:00:45 +00:00
" 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 " );
}
2007-12-05 16:10:07 +00:00
if ( $_GET [ 'action' ] == " edit " || $_GET [ 'action' ] == " add " )
2005-02-23 23:00:45 +00:00
{
echo " <a href= \" award_contacts.php?award_sponsors_id= $award_sponsors_id\ " >& lt ; & lt ; " .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 );
}
2007-12-05 16:10:07 +00:00
else if ( $_GET [ 'action' ] == " add " )
2005-02-23 23:00:45 +00:00
{
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 " ;
2006-10-16 03:36:39 +00:00
echo " <tr><td> " . i18n ( " Salutation " ) . " </td><td><input type= \" text \" name= \" salutation \" value= \" " . htmlspecialchars ( $r -> salutation ) . " \" size= \" 4 \" maxlength= \" 8 \" /></td></tr> \n " ;
2005-02-23 23:00:45 +00:00
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 " ;
2007-12-05 16:10:07 +00:00
echo " <tr><td> " . i18n ( " Position " ) . " </td><td><input type= \" text \" name= \" position \" value= \" " . htmlspecialchars ( $r -> position ) . " \" size= \" 60 \" maxlength= \" 64 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " Phone (Work) " ) . " </td><td><input type= \" text \" name= \" phonework \" value= \" " . htmlspecialchars ( $r -> phonework ) . " \" size= \" 16 \" maxlength= \" 32 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " Phone (Cell) " ) . " </td><td><input type= \" text \" name= \" phonecell \" value= \" " . htmlspecialchars ( $r -> phonecell ) . " \" size= \" 16 \" maxlength= \" 32 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " Phone (Home) " ) . " </td><td><input type= \" text \" name= \" phonehome \" value= \" " . htmlspecialchars ( $r -> phonehome ) . " \" size= \" 16 \" maxlength= \" 32 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " Fax " ) . " </td><td><input type= \" text \" name= \" fax \" value= \" " . htmlspecialchars ( $r -> fax ) . " \" size= \" 16 \" maxlength= \" 32 \" /></td></tr> \n " ;
2005-02-23 23:00:45 +00:00
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 " ;
2006-10-16 03:36:39 +00:00
echo " <td> " ;
if ( $r -> salutation ) echo $r -> salutation . " " ;
echo " $r->firstname $r->lastname </td> \n " ;
2005-02-23 23:00:45 +00:00
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 ();
?>