<?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[project]) { $_SESSION[var_project] = $_GET[project]; }
if ($_GET[table]) { $_SESSION[var_table] = $_GET[table]; }
if ($_GET[field]) { $_SESSION[var_field] = $_GET[field]; }
if ($_GET[action]) { $_SESSION[var_action] = $_GET[action]; }
if ($_GET[table_order]) { $_SESSION[var_table_order] = $_GET[table_order]; }
$project=$_SESSION[var_project];
$table=$_SESSION[var_table];
$field=$_SESSION[var_field];
$action=$_SESSION[var_action];
$table_order=$_SESSION[var_table_order];
?>
<html>
<head>
<link href="list.css" type="text/css" rel=stylesheet>
<meta content="text/css" http-equiv="Content-Style-Type">
<title>Screen generator Scherm: Table</title>
</head>
<script type="text/javascript" src="handlers.js" language="JavaScript">
alert ("no code");
</script>
<body>
<?php
include 'menu.php';
include 'makemenu.php';
makeMenu(0, 3, '');
?>
<div id="content">
<?php
$sql->QueryItem("SELECT table.sql as F441, table.name as F801, table.title as F444, table.id_field as F487, table.width as F490, table.height as F488, table.where as F555 FROM `table`
WHERE `table`.`table` = '$table'
LIMIT 1");
$intern = htmlspecialchars($sql->data['F441']);
$name = htmlspecialchars($sql->data['F801']);
$title = htmlspecialchars($sql->data['F444']);
$id_field = htmlspecialchars($sql->data['F487']);
$width = htmlspecialchars($sql->data['F490']);
$height = htmlspecialchars($sql->data['F488']);
$where = htmlspecialchars($sql->data['F555']);
echo ('<table class=record>');
echo ("<tr><th>SQL name</th>
<td>$intern</td>");
echo ("<th>Width</th>
<td>$width</td>
</tr>");
echo ("<tr><th>Name</th>
<td>$name</td>");
echo ("<th>Height</th>
<td>$height</td>
</tr>");
echo ("<tr><th>Title</th>
<td>$title</td>");
echo ("</tr>");
echo ("<tr><th>ID field</th>
<td>$id_field</td>");
echo ("</tr>");
echo ("<tr><th>Where</th>
<td>$where</td>");
echo ("</tr>");
echo ('</table>');
?>
<p><input type=button value="Edit Table" onClick="javascript: window.open('edittable.php?table=<?php echo $table; ?>','','width=500,height=450,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); return false;">
<br><br><br><table class=ruler><tr><td>Fields</td></tr></table>
<?php
if ($_GET[order63]<>'') {
$sql->QueryItem("DELETE FROM user_selection WHERE user=$user_ID and field='sort_63'");
$sql->QueryItem("INSERT INTO user_selection VALUES ('$user_ID', 'sort_63','$_GET[order63]'");
}
$lastid=$_SESSION[last_63];
$lastfilter63=$_SESSION[filter63];
$_SESSION[last_63]='';
if ($_GET[filter63]) { $filter63 =$_GET[filter63]; } else { $filter63=$_POST[filter63];}
if ($_GET[page63]) { $page=$_GET[page63]; } else { $page=$_POST[page63]; }
if ($filter63!=$lastfilter63) {
$_SESSION[filter63]=$filter63;
$page=0;
}
if ($_GET[full_63]=='Fullpage') {
$_SESSION[fullpage_63]='f';
}
if ($_GET[full_63]=='Pages') {
$_SESSION[fullpage_63]='';
}
if ($filter63!='')
{
$qfilter63 = quote('%'.$filter63.'%');
$query = ("
FROM `field`
WHERE (T465.`sql` LIKE $qfilter63
OR field.`title` LIKE $qfilter63
OR field.`name` LIKE $qfilter63
OR field.`sessionvar` LIKE $qfilter63
OR field.`width` LIKE $qfilter63
) AND `field`.`table`='$table'
");
}
else
{
$query = ("
FROM `field`
WHERE 1 AND `field`.`table`='$table'
");
}
$query.=(($sortorder=='' || $sortorder=='6')?" ORDER BY `field`.`Order` ":'');
$lastrec=-1;
$sql->QueryItem("SELECT COUNT(*) AS records$query");
$records=$sql->data[records];
$sortorder=$sql->QueryItem("SELECT value FROM user_selection WHERE user=$user_ID and field='sort_63'");
if ($lastid=='') {$fromrec=20*$page;} else {
$fromrec=0;
$sql->Query("SELECT `field`.`field` AS id $query");
for ($r=0; $r<$sql->rows; $r++) {
$sql->Fetch($r);
if ($sql->data[id]==$lastid) {
$fromrec=$r-10;
if($fromrec<0) $fromrec=0;
$lastrec=$r-$fromrec;
break;
}
}
}
$sql->Query("SELECT field.field as F494, field.sql as F465, field.table as F464, field.title as F466, field.name as F533, field.sessionvar as F475, field.width as F477, field.order as F483$query".
($_SESSION[fullpage_63]==''?"LIMIT $fromrec, 20":''));
if (($part_rights['20/nofilter']==0)) {
echo "<form action=\"\" method=get name=Filter63>";
echo "<p class=filter>";
echo "Records: $records ";
$maxpage=(int) (($records+19)/20);
if ($maxpage>1) {
if ($_SESSION[fullpage_63]=='') {
echo "Page: ";
echo "<select name=\"page63\" OnChange=\"Filter63.submit();\">\n";
for ($i = 0; $i < $maxpage; $i++)
{
$nr=$i+1;
if ($i==$page) {$sel=" selected";} else {$sel="";}
echo "<option value=$i$sel>$nr van $maxpage</option>\n";
}
echo "</select>\n";
echo "<input type=submit name=full_63 value=\"Fullpage\">";
} else {
echo "<input type=submit name=full_63 value=\"Pages\">";
}
}
echo "<input type=text name=\"filter63\" size=25 value=\"$filter63\">";
echo "<input type=submit value=\"Search\">";
echo "<input type=button value=\"Add Field\" onClick=\"javascript: window.open('addfield.php?field=$field&table=$table','','width=500,height=660,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); return false;\">";
echo "</p>";
echo "</form>";
}
?>
<table class=list>
<tr>
<th></th>
<th width=175px>SQLName</th>
<th width=175px>Title</th>
<th width=175px>Name</th>
<th width=175px>SessionVar</th>
<th width=35px>Width</th>
<th width=0px>Order</th>
</tr>
<?php
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$field = $sql->data['F494'];
$intern = htmlspecialchars($sql->data['F465']);
$title = htmlspecialchars($sql->data['F466']);
$Name = htmlspecialchars($sql->data['F533']);
$SessionVar = htmlspecialchars($sql->data['F475']);
$width = htmlspecialchars($sql->data['F477']);
$Order = htmlspecialchars($sql->data['F483']);
if ($lastrec==$i) {$color="style=\"background-color: #aaaaff;\"";} else {$color="";}
echo ("
<tr $color onMouseOver=\"ChangeColor(this)\" onMouseOut=\"ChangeColorBack(this)\" onClick=\"window.open('editfield.php?field=$field&table=$table','wijzigen','width=500,height=660,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes')\">
<td onClick=\"window.open('addfield.php?Order=$Order','add','width=500,height=660,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); no_bubble(event);\"><b>Add</b></td>
<td>$intern</td>
<td>$title</td>
<td>$Name</td>
<td>$SessionVar</td>
<td>$width</td>
<td>$Order</td>
</tr>");
}
?>
</table>
<br><br><br><table class=ruler><tr><td>Ordering</td></tr></table>
<?php
if ($_GET[order121]<>'') {
$sql->QueryItem("DELETE FROM user_selection WHERE user=$user_ID and field='sort_121'");
$sql->QueryItem("INSERT INTO user_selection VALUES ('$user_ID', 'sort_121','$_GET[order121]'");
}
$lastid=$_SESSION[last_121];
$lastfilter121=$_SESSION[filter121];
$_SESSION[last_121]='';
if ($_GET[filter121]) { $filter121 =$_GET[filter121]; } else { $filter121=$_POST[filter121];}
if ($_GET[page121]) { $page=$_GET[page121]; } else { $page=$_POST[page121]; }
if ($filter121!=$lastfilter121) {
$_SESSION[filter121]=$filter121;
$page=0;
}
if ($_GET[full_121]=='Fullpage') {
$_SESSION[fullpage_121]='f';
}
if ($_GET[full_121]=='Pages') {
$_SESSION[fullpage_121]='';
}
if ($filter121!='')
{
$qfilter121 = quote('%'.$filter121.'%');
$query = ("
FROM `table_order`
WHERE (table_order.`name` LIKE $qfilter121
) AND `table_order`.`table`='$table'
");
}
else
{
$query = ("
FROM `table_order`
WHERE 1 AND `table_order`.`table`='$table'
");
}
$query.=(($sortorder=='' || $sortorder=='3')?" ORDER BY `table_order`.`name` ":'');
$lastrec=-1;
$sql->QueryItem("SELECT COUNT(*) AS records$query");
$records=$sql->data[records];
$sortorder=$sql->QueryItem("SELECT value FROM user_selection WHERE user=$user_ID and field='sort_121'");
if ($lastid=='') {$fromrec=20*$page;} else {
$fromrec=0;
$sql->Query("SELECT `table_order`.`table_order` AS id $query");
for ($r=0; $r<$sql->rows; $r++) {
$sql->Fetch($r);
if ($sql->data[id]==$lastid) {
$fromrec=$r-10;
if($fromrec<0) $fromrec=0;
$lastrec=$r-$fromrec;
break;
}
}
}
$sql->Query("SELECT table_order.table_order as F793, table_order.table as F794, table_order.name as F795, table_order.order as F796$query".
($_SESSION[fullpage_121]==''?"LIMIT $fromrec, 20":''));
if (($part_rights['178/nofilter']==0)) {
echo "<form action=\"\" method=get name=Filter121>";
echo "<p class=filter>";
echo "Records: $records ";
$maxpage=(int) (($records+19)/20);
if ($maxpage>1) {
if ($_SESSION[fullpage_121]=='') {
echo "Page: ";
echo "<select name=\"page121\" OnChange=\"Filter121.submit();\">\n";
for ($i = 0; $i < $maxpage; $i++)
{
$nr=$i+1;
if ($i==$page) {$sel=" selected";} else {$sel="";}
echo "<option value=$i$sel>$nr van $maxpage</option>\n";
}
echo "</select>\n";
echo "<input type=submit name=full_121 value=\"Fullpage\">";
} else {
echo "<input type=submit name=full_121 value=\"Pages\">";
}
}
echo "<input type=text name=\"filter121\" size=25 value=\"$filter121\">";
echo "<input type=submit value=\"Search\">";
echo "<input type=button value=\"Add Table ordering\" onClick=\"javascript: window.open('addtable_order.php?table_order=$table_order&table=$table','','width=500,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); return false;\">";
echo "</p>";
echo "</form>";
}
?>
<table class=list>
<tr>
<th></th>
<th width=210px>Ordering</th>
<th width=35px>Order</th>
</tr>
<?php
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$table_order = $sql->data['F793'];
$name = htmlspecialchars($sql->data['F795']);
$order = htmlspecialchars($sql->data['F796']);
if ($lastrec==$i) {$color="style=\"background-color: #aaaaff;\"";} else {$color="";}
echo ("
<tr $color onMouseOver=\"ChangeColor(this)\" onMouseOut=\"ChangeColorBack(this)\" onClick=\"location='order.php?table_order=$table_order&table=$table'\">
<td onClick=\"window.open('addtable_order.php?order=$order','add','width=500,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); no_bubble(event);\"><b>Add</b></td>
<td>$name</td>
<td>$order</td>
</tr>");
}
?>
</table>
<br><br><br><table class=ruler><tr><td>Actions</td></tr></table>
<?php
if ($_GET[order64]<>'') {
$sql->QueryItem("DELETE FROM user_selection WHERE user=$user_ID and field='sort_64'");
$sql->QueryItem("INSERT INTO user_selection VALUES ('$user_ID', 'sort_64','$_GET[order64]'");
}
$lastid=$_SESSION[last_64];
$lastfilter64=$_SESSION[filter64];
$_SESSION[last_64]='';
if ($_GET[filter64]) { $filter64 =$_GET[filter64]; } else { $filter64=$_POST[filter64];}
if ($_GET[page64]) { $page=$_GET[page64]; } else { $page=$_POST[page64]; }
if ($filter64!=$lastfilter64) {
$_SESSION[filter64]=$filter64;
$page=0;
}
if ($_GET[full_64]=='Fullpage') {
$_SESSION[fullpage_64]='f';
}
if ($_GET[full_64]=='Pages') {
$_SESSION[fullpage_64]='';
}
if ($filter64!='')
{
$qfilter64 = quote('%'.$filter64.'%');
$query = ("
FROM `actions`
) AND `actions`.`table`='$table' AND `actions`.`action`='$action'
");
}
else
{
$query = ("
FROM `actions`
WHERE 1 AND `actions`.`table`='$table' AND `actions`.`action`='$action'
");
}
$lastrec=-1;
$sql->QueryItem("SELECT COUNT(*) AS records$query");
$records=$sql->data[records];
$sortorder=$sql->QueryItem("SELECT value FROM user_selection WHERE user=$user_ID and field='sort_64'");
if ($lastid=='') {$fromrec=20*$page;} else {
$fromrec=0;
$sql->Query("SELECT `actions`.`ActionID` AS id $query");
for ($r=0; $r<$sql->rows; $r++) {
$sql->Fetch($r);
if ($sql->data[id]==$lastid) {
$fromrec=$r-10;
if($fromrec<0) $fromrec=0;
$lastrec=$r-$fromrec;
break;
}
}
}
$sql->Query("SELECT actions.table as F460, actions.action as F742, actions.Action as F461, actions.Part as F462, actions.Code as F463$query".
($_SESSION[fullpage_64]==''?"LIMIT $fromrec, 20":''));
if (($part_rights['21/nofilter']==0)) {
echo "<form action=\"\" method=get name=Filter64>";
echo "<p class=filter>";
echo "Records: $records ";
$maxpage=(int) (($records+19)/20);
if ($maxpage>1) {
if ($_SESSION[fullpage_64]=='') {
echo "Page: ";
echo "<select name=\"page64\" OnChange=\"Filter64.submit();\">\n";
for ($i = 0; $i < $maxpage; $i++)
{
$nr=$i+1;
if ($i==$page) {$sel=" selected";} else {$sel="";}
echo "<option value=$i$sel>$nr van $maxpage</option>\n";
}
echo "</select>\n";
echo "<input type=submit name=full_64 value=\"Fullpage\">";
} else {
echo "<input type=submit name=full_64 value=\"Pages\">";
}
}
echo "<input type=text name=\"filter64\" size=25 value=\"$filter64\">";
echo "<input type=submit value=\"Search\">";
echo "<input type=button value=\"Add Action\" onClick=\"javascript: window.open('addaction.php?table=$table&action=$action','','width=500,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); return false;\">";
echo "</p>";
echo "</form>";
}
?>
<table class=list>
<tr>
<th width=0px>Action</th>
<th width=0px>Part</th>
<th width=280px>Code</th>
</tr>
<?php
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$Action = htmlspecialchars($sql->data['F461']);
$Part = htmlspecialchars($sql->data['F462']);
$Code = htmlspecialchars($sql->data['F463']);
if ($lastrec==$i) {$color="style=\"background-color: #aaaaff;\"";} else {$color="";}
echo ("
<tr $color onMouseOver=\"ChangeColor(this)\" onMouseOut=\"ChangeColorBack(this)\" onClick=\"window.open('editaction.php?table=$table&action=$action','wijzigen','width=500,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes')\">
<td>$Action</td>
<td>$Part</td>
<td>$Code</td>
</tr>");
}
?>
</table>
</div></body>
</html>