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 >
2009-01-21 22:33:27 +00:00
Copyright ( C ) 2009 James Grant < james @ lightbox . org >
2005-01-24 18:00:03 +00:00
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 " ;
2011-03-03 21:55:05 +00:00
user_auth_required ( " participant " );
2004-12-10 20:38:16 +00:00
//send the header
send_header ( " Participant Registration - Safety Information " );
2011-03-03 21:55:05 +00:00
$u = user_load ( $_SESSION [ 'users_id' ]);
2004-12-10 20:38:16 +00:00
echo " <a href= \" register_participants_main.php \" ><< " . i18n ( " Back to Participant Registration Summary " ) . " </a><br /> " ;
echo " <br /> " ;
2009-01-21 22:33:27 +00:00
if ( $_POST [ 'action' ] == " save " ) {
if ( registrationFormsReceived ()) {
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
}
2009-01-21 22:33:27 +00:00
else if ( registrationDeadlinePassed ()) {
2005-05-12 17:32:50 +00:00
echo error ( i18n ( " Cannot make changes to forms after registration deadline " ));
}
2009-01-21 22:33:27 +00:00
else {
2005-01-13 18:50:07 +00:00
//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
2011-03-03 21:55:05 +00:00
mysql_query ( " DELETE FROM safety WHERE registrations_id=' " . $u [ 'registrations_id' ] . " ' AND conferences_id=' " . $conference [ 'id' ] . " ' " );
2009-01-21 22:33:27 +00:00
if ( is_array ( $_POST [ 'safety' ])) {
2006-02-01 17:53:04 +00:00
$safetyids = array_keys ( $_POST [ 'safety' ]);
2009-01-21 22:33:27 +00:00
foreach ( $safetyids AS $key => $val ) {
2010-11-01 15:24:59 +00:00
mysql_query ( " INSERT INTO safety (registrations_id,safetyquestions_id,conferences_id,answer) VALUES ( " .
2011-03-03 21:55:05 +00:00
" ' " . $u [ 'registrations_id' ] . " ', " .
2006-02-01 17:53:04 +00:00
" ' $val ', " .
2010-11-01 15:24:59 +00:00
" ' " . $conference [ 'id' ] . " ', " .
2006-02-01 17:53:04 +00:00
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'safety' ][ $val ])) . " ') " );
echo mysql_error ();
}
2005-01-13 18:50:07 +00:00
}
}
2004-12-10 20:38:16 +00:00
}
//output the current status
2011-03-03 21:55:05 +00:00
$newstatus = safetyStatus ( $u [ 'registrations_id' ]);
2009-01-21 22:33:27 +00:00
if ( $newstatus != " complete " ) {
2006-01-27 01:14:16 +00:00
echo error ( i18n ( " Safety Information Incomplete. You must agree to / answer all required safety questions! " ));
2004-12-10 20:38:16 +00:00
}
2009-01-21 22:33:27 +00:00
else if ( $newstatus == " complete " ) {
2004-12-10 20:38:16 +00:00
echo happy ( i18n ( " Safety Information Complete " ));
}
2011-03-03 21:55:05 +00:00
$q = mysql_query ( " SELECT * FROM safety WHERE registrations_id=' " . $u [ 'registrations_id' ] . " ' " );
2009-01-21 22:33:27 +00:00
while ( $r = mysql_fetch_object ( $q )) {
2004-12-10 21:23:59 +00:00
$safetyanswers [ $r -> safetyquestions_id ] = $r -> answer ;
}
2010-11-01 15:24:59 +00:00
$q = mysql_query ( " SELECT * FROM safetyquestions WHERE conferences_id=' " . $conference [ 'id' ] . " ' ORDER BY ord " );
2009-01-21 22:33:27 +00:00
if ( mysql_num_rows ( $q )) {
2006-02-01 17:50:27 +00:00
echo i18n ( " Please agree to / answer the following safety questions by checking the box next to the question, or choosing the appropriate answer " );
echo " <br /> " ;
echo " <br /> " ;
echo " <form method= \" post \" action= \" register_participants_safety.php \" > \n " ;
echo " <input type= \" hidden \" name= \" action \" value= \" save \" > \n " ;
2009-01-21 22:33:27 +00:00
echo " <table class= \" tableedit \" > \n " ;
2006-02-01 17:50:27 +00:00
$num = 1 ;
2009-01-21 22:33:27 +00:00
while ( $r = mysql_fetch_object ( $q )) {
$trclass = ( $num % 2 == 0 ? " odd " : " even " );
echo " <tr class= \" $trclass\ " >< td >< b > $num </ b >. </ td >< td > " ;
2006-02-01 17:50:27 +00:00
if ( $r -> required == " yes " ) echo REQUIREDFIELD ;
echo i18n ( $r -> question ) . " </td> " ;
echo " <td> " ;
2009-01-21 22:33:27 +00:00
if ( $r -> type == " check " ) {
2006-02-01 17:50:27 +00:00
if ( $safetyanswers [ $r -> id ] == " checked " ) $ch = " checked= \" checked \" " ; else $ch = " " ;
echo " <input $ch type= \" checkbox \" name= \" safety[ $r->id ] \" value= \" checked \" /> " ;
}
2009-01-21 22:33:27 +00:00
else if ( $r -> type == " yesno " ) {
2006-02-01 17:50:27 +00:00
echo " <nobr> " ;
if ( $safetyanswers [ $r -> id ] == " yes " ) $ch = " checked= \" checked \" " ; else $ch = " " ;
echo " <input $ch type= \" radio \" name= \" safety[ $r->id ] \" value= \" yes \" /> " ;
echo i18n ( " Yes " );
echo " </nobr><br /><nobr> " ;
if ( $safetyanswers [ $r -> id ] == " no " ) $ch = " checked= \" checked \" " ; else $ch = " " ;
echo " <input $ch type= \" radio \" name= \" safety[ $r->id ] \" value= \" no \" /> " ;
echo i18n ( " No " );
echo " </nobr> " ;
}
echo " </td> " ;
echo " </tr> " ;
$num ++ ;
}
echo " </table> " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Save Safety Information " ) . " \" /> \n " ;
echo " </form> " ;
}
else
echo notice ( i18n ( " There are no safety questions to be answered " ));
2004-12-10 20:38:16 +00:00
2011-03-03 02:57:40 +00:00
2004-12-10 20:38:16 +00:00
send_footer ();
?>