forked from science-ation/science-ation
192 lines
6.2 KiB
PHP
192 lines
6.2 KiB
PHP
<?php
|
|
/*
|
|
This file is a plug-in to the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2011 At Work Software (dennis@spanogle.net>
|
|
Copyright (C) 2011 Dennis Spanogle <dennis@spanogle.net>
|
|
|
|
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.
|
|
*/
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
|
<head><title>SFIAB Evaluations Levels Editor</title>
|
|
<script language="javascript">
|
|
function confirmClick(msg)
|
|
{
|
|
var okay=confirm(msg);
|
|
if(okay)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
include "sfiab_common.inc.php"; // check SFIAB install and get config etc.
|
|
include "eval_common.inc.php"; // check Evaluations setup and get eval_config
|
|
include "eval_menu_inc.php";
|
|
echo "<h2>Levels Editor</h2><br /><br />";
|
|
if($_POST['action']=="edit")
|
|
{
|
|
if($_POST['scheme_id'] && $_POST['level_id'] && $_POST['level_value'] && $_POST['level_name'] && $_POST['spec_use'] )
|
|
{
|
|
//$q=mysql_query("SELECT id FROM eval_criteria WHERE id='".$_POST['id']."' ");
|
|
//if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
|
//{
|
|
// echo "Criteria ID ".$_POST['id']." already exists!";
|
|
//}
|
|
//else
|
|
//{
|
|
$t = mysql_query("UPDATE eval_levels SET ".
|
|
"scheme_id='".$_POST['scheme_id']."', ".
|
|
"level_id='".$_POST['level_id']."', ".
|
|
"level_value='".$_POST['level_value']."', ".
|
|
"level_name='".$_POST['level_name']."', ".
|
|
"spec_use='".$_POST['spec_use']."', ".
|
|
"spec_use_code='".$_POST['spec_use_code']."' ".
|
|
"WHERE id='".$_POST['saveid']."' ");
|
|
|
|
|
|
echo "Level Saved!";
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
echo "Error: All fields are required!";
|
|
}
|
|
}
|
|
|
|
if($_POST['action']=="new")
|
|
{
|
|
if($_POST['scheme_id'] && $_POST['level_id'] && $_POST['level_value'] && $_POST['level_name'] && $_POST['spec_use'] )
|
|
{
|
|
// $q=mysql_query("SELECT id FROM eval_criteria WHERE id='".$_POST['id']."' ");
|
|
// if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
|
// {
|
|
// echo "Scheme ID ".$_POST['id']." already exists!";
|
|
// }
|
|
// else
|
|
// {
|
|
mysql_query("INSERT INTO eval_levels ( scheme_id, level_id, level_value, level_name, spec_use, spec_use_code) VALUES ( ".
|
|
"'".$_POST['scheme_id']."', ".
|
|
"'".$_POST['level_id']."', ".
|
|
"'".$_POST['level_value']."', ".
|
|
"'".$_POST['level_name']."', ".
|
|
"'".$_POST['spec_use']."', ".
|
|
"'".$_POST['spec_use_code']."' ) ");
|
|
echo "Level Saved!";
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
echo "Error: All fields are required!";
|
|
}
|
|
}
|
|
|
|
if($_GET['action']=="remove" && $_GET['remove'])
|
|
{
|
|
mysql_query("DELETE FROM eval_levels where id='".$_GET['remove']."' ");
|
|
echo "Level successfully removed";
|
|
}
|
|
|
|
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
|
|
|
|
if(! ($_GET['action']=="edit" || $_GET['action']=="new") )
|
|
{
|
|
echo "<a href=\"".$_SERVER['PHP_SELF']."?action=new\"> Add New Level </a>\n";
|
|
echo "<table border=\"1\">";
|
|
echo "<tr>";
|
|
//echo "<th> rec ID </th>\n";
|
|
echo "<th> Scheme ID </th>\n";
|
|
echo "<th> Level ID</th>\n";
|
|
echo "<th> Level Value </th>\n";
|
|
echo "<th> Level Name </th>\n";
|
|
echo "<th> Special Use </th>\n";
|
|
echo "<th> Special Use Code </th>\n";
|
|
echo "<th> Actions </th>\n";
|
|
echo "</tr>";
|
|
}
|
|
|
|
if($_GET['action']=="edit" || $_GET['action']=="new")
|
|
{
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
|
if($_GET['action']=="edit")
|
|
{
|
|
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
|
$q=mysql_query("SELECT * FROM eval_levels WHERE id='".$_GET['edit']."' ");
|
|
$lvlr=mysql_fetch_object($q);
|
|
$buttontext="Save";
|
|
}
|
|
else if($_GET['action']=="new")
|
|
{
|
|
$buttontext="Add";
|
|
}
|
|
echo "<table border=\"1\">";
|
|
echo "<tr>";
|
|
//echo "<th> rec ID </th>\n";
|
|
echo "<th> Scheme ID </th>\n";
|
|
echo "<th> Level ID</th>\n";
|
|
echo "<th> Level Value </th>\n";
|
|
echo "<th> Level Name </th>\n";
|
|
echo "<th> Special Use </th>\n";
|
|
echo "<th> Special Use Code </th>\n";
|
|
echo "<th> Actions </th>\n";
|
|
echo "</tr>";
|
|
echo "<tr>";
|
|
//echo " <td><input type=\"text\" size=\"3\" name=\"id\" value=\"$critr->id\" /></td>";
|
|
echo " <td><input type=\"text\" size=\"3\" name=\"scheme_id\" value=\"$lvlr->scheme_id\" /></td>";
|
|
echo " <td><input type=\"text\" size=\"3\" name=\"level_id\" value=\"$lvlr->level_id\" /></td>";
|
|
echo " <td><input type=\"text\" size=\"3\" name=\"level_value\" value=\"$lvlr->level_value\" /></td>";
|
|
echo " <td><input type=\"text\" size=\"12\" name=\"level_name\" value=\"$lvlr->level_name\" /></td>";
|
|
echo " <td><input type=\"text\" size=\"3\" name=\"spec_use\" value=\"$lvlr->spec_use\" /></td>";
|
|
echo " <td><input type=\"text\" size=\"4\" name=\"spec_use_code\" value=\"$lvlr->spec_use_code\" /></td>";
|
|
echo "</td>";
|
|
echo " <td><input type=\"submit\" value=\"".$buttontext."\" /></td>";
|
|
echo "</tr>";
|
|
}
|
|
else
|
|
{
|
|
$q=mysql_query("SELECT * FROM eval_levels ORDER BY scheme_id, level_id");
|
|
while($r=mysql_fetch_object($q))
|
|
{
|
|
echo "<tr>";
|
|
//echo " <td>$r->id </td>";
|
|
echo " <td>$r->scheme_id </td>";
|
|
echo " <td> $r->level_id </td>";
|
|
echo " <td> $r->level_value </td>";
|
|
echo " <td> $r->level_name </td>";
|
|
echo " <td> $r->spec_use </td>";
|
|
echo " <td> $r->spec_use_code </td>";
|
|
echo " <td>";
|
|
echo "<a title=\"Edit\" href=\"".$_SERVER['PHP_SELF']."?action=edit&edit=$r->id\">Edit</a>";
|
|
echo " ";
|
|
echo "<a title=\"Remove\" onClick=\"return confirmClick('Are you sure you want to remove this level?');\" href=\"".$_SERVER['PHP_SELF']."?action=remove&remove=$r->id\">Remove</a>";
|
|
echo " </td>";
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
echo "</table>";
|
|
echo "</form>";
|
|
echo"Scheme ID Must exist in Schemes!";
|
|
echo "</body>";
|
|
echo "</html>";
|
|
exit;
|
|
?>
|
|
|
|
|