2005-01-24 18:00:03 +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 .
*/
?>
2004-12-10 20:38:16 +00:00
< ?
require ( " common.inc.php " );
include " register_participants.inc.php " ;
//authenticate based on email address and registration number from the SESSION
if ( ! $_SESSION [ 'email' ])
{
header ( " Location: register_participants.php " );
exit ;
}
if ( ! $_SESSION [ 'registration_number' ])
{
header ( " Location: register_participants.php " );
exit ;
}
$q = mysql_query ( " SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students " .
" WHERE students.email=' " . $_SESSION [ 'email' ] . " ' " .
" AND registrations.num=' " . $_SESSION [ 'registration_number' ] . " ' " .
" AND registrations.id=' " . $_SESSION [ 'registration_id' ] . " ' " .
" AND students.registrations_id=registrations.id " .
" AND registrations.year= " . $config [ 'FAIRYEAR' ] . " " .
" AND students.year= " . $config [ 'FAIRYEAR' ]);
echo mysql_error ();
if ( mysql_num_rows ( $q ) == 0 )
{
header ( " Location: register_participants.php " );
exit ;
}
$authinfo = mysql_fetch_object ( $q );
//send the header
send_header ( " Participant Registration - Safety Information " );
echo " <a href= \" register_participants_main.php \" ><< " . i18n ( " Back to Participant Registration Summary " ) . " </a><br /> " ;
echo " <br /> " ;
if ( $_POST [ 'action' ] == " save " )
{
2005-01-13 18:50:07 +00:00
if ( registrationFormsReceived ())
2004-12-10 20:38:16 +00:00
{
2005-01-13 18:50:07 +00:00
echo error ( i18n ( " Cannot make changes to forms once they have been received by the fair " ));
2004-12-10 20:38:16 +00:00
}
2005-05-12 17:32:50 +00:00
else if ( registrationDeadlinePassed ())
{
echo error ( i18n ( " Cannot make changes to forms after registration deadline " ));
}
2005-01-13 18:50:07 +00:00
else
{
//first we will delete all their old answer, its easier to delete and re-insert in this case then it would be to find the corresponding answers and update them
mysql_query ( " DELETE FROM safety WHERE registrations_id=' " . $_SESSION [ 'registration_id' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
$safetyids = array_keys ( $_POST [ 'safety' ]);
foreach ( $safetyids AS $key => $val )
{
mysql_query ( " INSERT INTO safety (registrations_id,safetyquestions_id,year,answer) VALUES ( " .
" ' " . $_SESSION [ 'registration_id' ] . " ', " .
" ' $val ', " .
" ' " . $config [ 'FAIRYEAR' ] . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'safety' ][ $val ])) . " ') " );
echo mysql_error ();
}
}
2004-12-10 20:38:16 +00:00
}
2005-01-13 18:50:07 +00:00
2004-12-10 20:38:16 +00:00
//output the current status
$newstatus = safetyStatus ();
if ( $newstatus != " complete " )
{
2006-01-12 16:27:47 +00:00
echo error ( i18n ( " Safety Information Incomplete. You must agree to all safety questions! " ));
2004-12-10 20:38:16 +00:00
}
else if ( $newstatus == " complete " )
{
echo happy ( i18n ( " Safety Information Complete " ));
}
echo " <form method= \" post \" action= \" register_participants_safety.php \" > \n " ;
echo " <input type= \" hidden \" name= \" action \" value= \" save \" > \n " ;
echo " <table> \n " ;
2004-12-10 21:23:59 +00:00
$q = mysql_query ( " SELECT * FROM safety WHERE registrations_id=' " . $_SESSION [ 'registration_id' ] . " ' " );
while ( $r = mysql_fetch_object ( $q ))
{
$safetyanswers [ $r -> safetyquestions_id ] = $r -> answer ;
}
2005-12-08 15:35:41 +00:00
$q = mysql_query ( " SELECT * FROM safetyquestions WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY ord " );
2004-12-10 20:38:16 +00:00
$num = 1 ;
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr><td><b> $num </b>. </td><td> " . i18n ( $r -> question ) . " </td> " ;
echo " <td> " ;
if ( $r -> type == " check " )
{
2004-12-10 21:23:59 +00:00
if ( $safetyanswers [ $r -> id ] == " checked " ) $ch = " checked= \" checked \" " ; else $ch = " " ;
echo " <input $ch type= \" checkbox \" name= \" safety[ $r->id ] \" value= \" checked \" /> " ;
2004-12-10 20:38:16 +00:00
}
echo " </td> " ;
echo " </tr> " ;
$num ++ ;
}
echo " </table> " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Save Safety Information " ) . " \" /> \n " ;
echo " </form> " ;
send_footer ();
?>