save the safety responses in the safety table

This commit is contained in:
james 2004-12-10 21:23:59 +00:00
parent f11226ebd4
commit d5a5e9800f

View File

@ -39,29 +39,19 @@ echo mysql_error();
if($_POST['action']=="save")
{
/*
do nothing yet
//first, lets make sure this project really does belong to them
$q=mysql_query("SELECT * FROM projects WHERE id='".$_POST['id']."' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)==1)
//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("UPDATE projects SET ".
"title='".mysql_escape_string(stripslashes($_POST['title']))."', ".
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
"language='".mysql_escape_string(stripslashes($_POST['language']))."', ".
"req_table='".mysql_escape_string(stripslashes($_POST['req_table']))."', ".
"req_electricity='".mysql_escape_string(stripslashes($_POST['req_electricity']))."', ".
"req_special='".mysql_escape_string(stripslashes($_POST['req_special']))."', ".
"summary='".mysql_escape_string(stripslashes($_POST['summary']))."' ".
"WHERE id='".$_POST['id']."'");
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();
echo notice(i18n("Safety information successfully updated"));
}
else
{
echo error(i18n("Invalid project to update"));
}
*/
}
@ -81,16 +71,22 @@ else if($newstatus=="complete")
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>\n";
$q=mysql_query("SELECT * FROM safety WHERE registrations_id='".$_SESSION['registration_id']."'");
while($r=mysql_fetch_object($q))
{
$safetyanswers[$r->safetyquestions_id]=$r->answer;
}
$q=mysql_query("SELECT * FROM safetyquestions ORDER BY ord");
$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")
{
echo "<input type=\"checkbox\" name=\"safety[$r->id]\" value=\"checked\" />";
if($safetyanswers[$r->id]=="checked") $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"safety[$r->id]\" value=\"checked\" />";
}
echo "</td>";
echo "</tr>";