forked from science-ation/science-ation
save the safety responses in the safety table
This commit is contained in:
parent
f11226ebd4
commit
d5a5e9800f
@ -39,29 +39,19 @@ echo mysql_error();
|
|||||||
|
|
||||||
if($_POST['action']=="save")
|
if($_POST['action']=="save")
|
||||||
{
|
{
|
||||||
/*
|
//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
|
||||||
do nothing yet
|
mysql_query("DELETE FROM safety WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||||
//first, lets make sure this project really does belong to them
|
$safetyids=array_keys($_POST['safety']);
|
||||||
$q=mysql_query("SELECT * FROM projects WHERE id='".$_POST['id']."' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
|
foreach($safetyids AS $key=>$val)
|
||||||
if(mysql_num_rows($q)==1)
|
|
||||||
{
|
{
|
||||||
mysql_query("UPDATE projects SET ".
|
mysql_query("INSERT INTO safety (registrations_id,safetyquestions_id,year,answer) VALUES (".
|
||||||
"title='".mysql_escape_string(stripslashes($_POST['title']))."', ".
|
"'".$_SESSION['registration_id']."', ".
|
||||||
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
|
"'$val', ".
|
||||||
"language='".mysql_escape_string(stripslashes($_POST['language']))."', ".
|
"'".$config['FAIRYEAR']."', ".
|
||||||
"req_table='".mysql_escape_string(stripslashes($_POST['req_table']))."', ".
|
"'".mysql_escape_string(stripslashes($_POST['safety'][$val]))."')");
|
||||||
"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']."'");
|
|
||||||
echo mysql_error();
|
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 "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
|
||||||
echo "<table>\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");
|
$q=mysql_query("SELECT * FROM safetyquestions ORDER BY ord");
|
||||||
$num=1;
|
$num=1;
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q))
|
||||||
{
|
{
|
||||||
|
|
||||||
echo "<tr><td><b>$num</b>. </td><td>".i18n($r->question)."</td>";
|
echo "<tr><td><b>$num</b>. </td><td>".i18n($r->question)."</td>";
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
if($r->type=="check")
|
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 "</td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
Loading…
Reference in New Issue
Block a user