<?php
session_start();
$user_ID=$_SESSION[user_ID];
if (!$user_ID || $user_ID=='0')
{
header('location: index.php');
die('Login failed');
}
require("util.php");
$sql = new MySQL_class;
$sql->Create("generator");
$esql = new MySQL_class;
$esql->Create("generator");
if ($_GET[table]) { $_SESSION[var_table] = $_GET[table]; }
if ($_GET[field]) { $_SESSION[var_field] = $_GET[field]; }
$table=$_SESSION[var_table];
$project=$_SESSION[var_project];
$field=$_SESSION[var_field];
?>
<?php
$sql->QueryItem("SELECT `T583`.`sql` as F583_1 FROM `table` as T583 WHERE `table` = $table");
$sql_583=htmlspecialchars($sql->data[F583_1]);
$table_lup = "$sql_583";
$sql->QueryItem("SELECT `T486`.`sql` as F486_1 FROM `project` as T486 WHERE `project` = $project");
$sql_486=htmlspecialchars($sql->data[F486_1]);
$project_lup = "$sql_486";
if ($_POST['intern']!='') {
$intern = ($_POST['intern']);
$title = ($_POST['title']);
$Name = $_POST['Name'];
$SessionVar = ($_POST['SessionVar']);
$Type = $_POST['Type'];
$suffix = ($_POST['suffix']);
$width = $_POST['width'];
$height = $_POST['height'];
$List = $_POST['List'];
$Record = $_POST['Record'];
$add = $_POST['add'];
$edit = $_POST['edit'];
$link_table = ($_POST['link_table']);
$link_where = ($_POST['link_where']);
$link_field = ($_POST['link_field']);
$link_display = ($_POST['link_display']);
$default = ($_POST['default']);
$order = $_POST['order'];
}
?>
<html>
<head>
<link href="list.css" type="text/css" rel=stylesheet>
<meta content="text/css" http-equiv="Content-Style-Type">
<title>Field add</title>
</head>
<body class="top" onload="Insert.<?php
if ($_POST[FOCUS]==465) {echo 'title';}
else if ($_POST[FOCUS]==478) {echo 'suffix';}
else if ($_POST[FOCUS]==480) {echo 'Record';}
else if ($_POST[FOCUS]==493) {echo 'add';}
else if ($_POST[FOCUS]==762) {echo 'edit';}
else if ($_POST[FOCUS]==763) {echo 'link_table';}
else {echo 'sql';}
?>.focus();">
<form name="Insert" action="postaddfield.php" method="post">
<input type=hidden name="FOCUS" value="">
<input type=hidden name="order" value="<?php echo $_GET[order]; ?>">
<table class=enter>
<tr id=title><th colspan=2>Field add</th></tr>
<tr><th>SQLName</th>
<td>
<?php
$current=($_POST['intern']!='');
echo ("<select name=\"intern\" style=\"width: 175px\" OnChange=\"Insert.action=''; Insert.FOCUS.value='465'; Insert.submit();\">");
echo ("<option value=\"\"></option>\n");
$sql->QueryTry("show fields from $project_lup.$table_lup");
for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i);
$searchID = $sql->data[Field];
$searchshow = $searchID;
echo "<option ";
if ($current && $searchID == $_POST['intern']) {echo "selected ";};
echo "value=\"$searchID\">$searchshow";
echo "</option>\n";
}
echo ("</select>");
?>
</td></tr>
<tr><th>Title</th>
<td>
<?php
$current=($_POST['title']!='');
$strdefault = $_POST['title'];
echo "<input type=text name=\"title\" size=25 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Name</th>
<td>
<?php
$current=($_POST['Name']!='');
$strdefault = $intern;
if ($current) {$strdefault = $_POST['Name'];}
echo "<input type=text name=\"Name\" size=25 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>SessionVar</th>
<td>
<?php
$current=($_POST['SessionVar']!='');
$strdefault = $_POST['SessionVar'];
echo "<input type=text name=\"SessionVar\" size=25 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Type</th>
<td>
<?php
$current=($_POST['Type']!='');
echo ("<select name=\"Type\" OnChange=\"Insert.action=''; Insert.FOCUS.value='478'; Insert.submit();\">");
if ('int' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"int\"$sel>int</option>\n";
if ('enum' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"enum\"$sel>enum</option>\n";
if ('text' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"text\"$sel>text</option>\n";
if ('varchar' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"varchar\"$sel>varchar</option>\n";
if ('date' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"date\"$sel>date</option>\n";
if ('datetime' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"datetime\"$sel>datetime</option>\n";
if ('time' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"time\"$sel>time</option>\n";
if ('html' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"html\"$sel>html</option>\n";
if ('ordering' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"ordering\"$sel>ordering</option>\n";
if ('autonumeric' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"autonumeric\"$sel>autonumeric</option>\n";
if ('password' == $_POST['Type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"password\"$sel>password</option>\n";
echo ("</select>");
?>
</td></tr>
<tr><th>Suffix</th>
<td>
<?php
$current=($_POST['suffix']!='');
$strdefault = $_POST['suffix'];
echo "<input type=text name=\"suffix\" size=5 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Width</th>
<td>
<?php
$current=($_POST['width']!='');
$strdefault = $_POST['width'];
echo "<input type=text name=\"width\" size=5 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Height</th>
<td>
<?php
$current=($_POST['height']!='');
$strdefault = $_POST['height'];
echo "<input type=text name=\"height\" size=5 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>List</th>
<td>
<?php
$current=($_POST['List']!='');
echo ("<select name=\"List\" OnChange=\"Insert.action=''; Insert.FOCUS.value='480'; Insert.submit();\">");
if ('true' == $_POST['List']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"true\"$sel>true</option>\n";
if ('false' == $_POST['List']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"false\"$sel>false</option>\n";
echo ("</select>");
?>
</td></tr>
<tr><th>Record</th>
<td>
<?php
$current=($_POST['Record']!='');
echo ("<select name=\"Record\" OnChange=\"Insert.action=''; Insert.FOCUS.value='493'; Insert.submit();\">");
if ('left' == $_POST['Record']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"left\"$sel>left</option>\n";
if ('right' == $_POST['Record']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"right\"$sel>right</option>\n";
if ('front' == $_POST['Record']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"front\"$sel>front</option>\n";
if ('none' == $_POST['Record']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"none\"$sel>none</option>\n";
if ('edit' == $_POST['Record']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"edit\"$sel>edit</option>\n";
echo ("</select>");
?>
</td></tr>
<tr><th>Add</th>
<td>
<?php
$current=($_POST['add']!='');
echo ("<select name=\"add\" OnChange=\"Insert.action=''; Insert.FOCUS.value='762'; Insert.submit();\">");
if ('true' == $_POST['add']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"true\"$sel>true</option>\n";
if ('false' == $_POST['add']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"false\"$sel>false</option>\n";
echo ("</select>");
?>
</td></tr>
<tr><th>Edit</th>
<td>
<?php
$current=($_POST['edit']!='');
echo ("<select name=\"edit\" OnChange=\"Insert.action=''; Insert.FOCUS.value='763'; Insert.submit();\">");
if ('true' == $_POST['edit']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"true\"$sel>true</option>\n";
if ('false' == $_POST['edit']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"false\"$sel>false</option>\n";
if ('show' == $_POST['edit']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"show\"$sel>show</option>\n";
echo ("</select>");
?>
</td></tr>
<tr><th>Linked Table</th>
<td>
<?php
$current=($_POST['link_table']!='');
$strdefault = $_POST['link_table'];
echo "<input type=text name=\"link_table\" size=40 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Linked where</th>
<td>
<?php
$current=($_POST['link_where']!='');
$strdefault = $_POST['link_where'];
echo "<textarea name=\"link_where\" rows=4 cols=40>$strdefault</textarea>";
?>
</td></tr>
<tr><th>Linked Field</th>
<td>
<?php
$current=($_POST['link_field']!='');
$strdefault = $_POST['link_field'];
echo "<input type=text name=\"link_field\" size=25 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Display</th>
<td>
<?php
$current=($_POST['link_display']!='');
$strdefault = $_POST['link_display'];
echo "<input type=text name=\"link_display\" size=40 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Default</th>
<td>
<?php
$current=($_POST['default']!='');
$strdefault = $_POST['default'];
echo "<input type=text name=\"default\" size=0 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Order</th>
<td>
<?php
$current=($_POST['order']!='');
?>
</td></tr>
</table>
<p id=buttons>
<input type=submit value=Add>
<input type=button value=Cancel onClick="window.close()">
</p>
</form>
</body>
</html>