<?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[screen]) { $_SESSION[var_screen] = $_GET[screen]; }
if ($_GET[part]) { $_SESSION[var_part] = $_GET[part]; }
$screen=$_SESSION[var_screen];
$project=$_SESSION[var_project];
$part=$_SESSION[var_part];
?>
<?php
if ($_POST['type']!='') {
$type = $_POST['type'];
$table = $_POST['table'];
$link = $_POST['link'];
$title = ($_POST['title']);
$code = ($_POST['code']);
$order = $_POST['order'];
}
?>
<html>
<head>
<link href="list.css" type="text/css" rel=stylesheet>
<meta content="text/css" http-equiv="Content-Style-Type">
<title>Part add</title>
</head>
<body class="top" onload="Insert.<?php
if ($_POST[FOCUS]==452) {echo 'table';}
else if ($_POST[FOCUS]==453) {echo 'link';}
else if ($_POST[FOCUS]==454) {echo 'title';}
else {echo 'type';}
?>.focus();">
<form name="Insert" action="postaddpart.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>Part add</th></tr>
<tr><th>Type</th>
<td>
<?php
$current=($_POST['type']!='');
echo ("<select name=\"type\" style=\"width: 70px\" OnChange=\"document.Insert.action=''; Insert.FOCUS.value='452'; Insert.submit();\">");
if ('icon' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"icon\"$sel>icon</option>\n";
if ('link' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"link\"$sel>link</option>\n";
if ('script' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"script\"$sel>script</option>\n";
if ('record' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"record\"$sel>record</option>\n";
if ('edit' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"edit\"$sel>edit</option>\n";
if ('list' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"list\"$sel>list</option>\n";
if ('html' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"html\"$sel>html</option>\n";
if ('multiedit' == $_POST['type']) {$sel='selected ';} else {$sel='';};
echo "<option value=\"multiedit\"$sel>multiedit</option>\n";
echo ("</select>");
?>
</td></tr>
<tr><th>Table</th>
<td>
<?php
$current=($_POST['table']!='');
echo ("<select name=\"table\" style=\"width: 175px\" OnChange=\"Insert.action=''; Insert.FOCUS.value='453'; Insert.submit();\">");
echo ("<option value=\"\"></option>\n");
$sql->Query("SELECT `table`.`name` as F0_1, `table`.table FROM `table` WHERE `table`.project=$project ORDER BY `table`.`name`");
for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i);
$searchID = $sql->data[table];
$name_0=htmlspecialchars($sql->data[F0_1]);
$searchshow = "$name_0";
echo "<option ";
if ($current && $searchID == $_POST['table']) {echo "selected ";};
echo "value=\"$searchID\">$searchshow";
echo "</option>\n";
}
echo ("</select>");
?>
</td></tr>
<tr><th>Link</th>
<td>
<?php
$current=($_POST['link']!='');
echo ("<select name=\"link\" style=\"width: 175px\" OnChange=\"Insert.action=''; Insert.FOCUS.value='454'; Insert.submit();\">");
$sql->Query("SELECT `screen`.`name` as F0_1, `screen`.screen FROM `screen` WHERE screen.project=$project ORDER BY `screen`.`name`");
for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i);
$searchID = $sql->data[screen];
$name_0=htmlspecialchars($sql->data[F0_1]);
$searchshow = "$name_0";
echo "<option ";
if ($current && $searchID == $_POST['link']) {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>Code</th>
<td>
<?php
$current=($_POST['code']!='');
$strdefault = $_POST['code'];
echo "<textarea name=\"code\" rows=5 cols=35>$strdefault</textarea>";
?>
</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>