+ echo "Action = " . $_POST['action'] . "<br>";
+ // See if we have an update for the database
+ if (isset($_POST['action']) && $_POST['action'] == 'Create Parameter')
+ {
+ $name = $_POST['paramname'];
+ $class = $_POST['paramclass'];
+ $description = $_POST['paramdescr'];
+
+ echo "<h2>Creating parameter $name of class $class.</h2>";
+
+ echo "<form action='parameter.php?oid=$ObjId' method='post'>";
+ echo "<input type='hidden' name='paramclass' value='$class'>";
+ echo "<input type='hidden' name='paramname' value='$name'>";
+ echo "Description : <input type='text' name='paramdescr' value='$description'>";
+ echo "<br>";
+ echo "<table>";
+ echo "<tr><th>Property</th><th>Description</th><th>Value</th></tr>";
+
+ $class_res = pg_exec($this->database, "SELECT * FROM parameter_class WHERE name='$class'");
+ for ($row = 0; $row < pg_numrows($class_res); $row++)
+ {
+ $prop = pg_fetch_object($class_res, $row);
+ echo "<tr>";
+ echo "<td>", $prop->property_name, "</td><td>", $prop->description, "</td>";
+ echo "<td><input type='text' name='" . $prop->property_name . "'></td>";
+ echo "</tr>";
+ }
+ echo "</table>";
+ echo "<input type='submit' name='action' value='Save New Parameter'>";
+ echo "</form>";
+ }
+
+ if (isset($_POST['action']) && $_POST['action'] == 'Save New Parameter')
+ {
+ $name = $_POST['paramname'];
+ $class = $_POST['paramclass'];
+ $description = $_POST['paramdescr'];
+
+ echo "<h2>Saving new parameter $name of class $class.</h2>";
+
+ echo "Description : $description";
+ echo "<br>";
+
+ $insertion = "insert into parameter (objectid, name, class, description) values ";
+ $insertion .= "('$ObjId', '$name', '$class', '$description')";
+ pg_exec($this->database, $insertion);
+ $par = pg_fetch_object(pg_exec($this->database, "select currval('paramid_seq')"), 0);
+
+ echo "<table>";
+ echo "<tr><th>Property</th><th>Description</th><th>Value</th></tr>";
+
+ $class_res = pg_exec($this->database, "SELECT * FROM parameter_class WHERE name='$class'");
+ for ($row = 0; $row < pg_numrows($class_res); $row++)
+ {
+ $prop = pg_fetch_object($class_res, $row);
+ $insertion = "insert into property (paramid, name, value, type, min, max) values ('";
+ $insertion .= $par->currval . "', '" . $prop->property_name . "', '";
+ $insertion .= $_POST[$prop->property_name] . "', '" . $prop->property_type . "', '";
+ $insertion .= $prop->min . "', '" . $prop->max . "')";
+
+ pg_exec($this->database, $insertion);
+
+ $insertion = "insert into history (paramid, modified, change_nature, changed_property, new_value)";
+ $insertion .= " values ('" . $par->currval . "', '";
+ $insertion .= date('Y-m-d H:i:s') . "', 'CREATED', '";
+ $insertion .= $prop->property_name . "', '" . $_POST[$prop->property_name] . "')";
+
+ pg_exec($this->database, $insertion);
+
+ echo "<tr>";
+ echo "<td>", $prop->property_name, "</td><td>", $prop->description, "</td>";
+ echo "<td>" . $_POST[$prop->property_name] . "</td>";
+ echo "</tr>";
+ }
+ echo "</table>";
+ }
+