<?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[DatabaseID]) { $_SESSION[var_DatabaseID] = $_GET[DatabaseID]; }
if ($_GET[TableID]) { $_SESSION[var_TableID] = $_GET[TableID]; }
if ($_GET[FieldID]) { $_SESSION[var_FieldID] = $_GET[FieldID]; }
$DatabaseID=$_SESSION[var_DatabaseID];
$TableID=$_SESSION[var_TableID];
$FieldID=$_SESSION[var_FieldID];
$part_rights=array();
function get_part($part) {
global $sql, $user_ID;
$sql->Query("SELECT user_part.part, user_part.right, count(user_rights.user) AS allowed FROM user_part
LEFT JOIN user_rights ON user_rights.user='$user_ID' AND user_rights.right=user_part.user
WHERE user_part.part=$part GROUP BY user_part.part, user_part.right");
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
echo "$sql->data[part]/$sql->data[right]=$sql->data[allowed]<br>";
if ($sql->data[allowed]<>'0') {
$part_rights[$sql->data[part].'/'.$sql->data[right]]=1;
}
}
}
get_part (19); get_part (20); get_part (21);
?>
<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>
<table id=main><tr><td id=menu><?php
include 'menu.php';
?>
</td><td id=workarea><?php
$sql->QueryItem("SELECT tables.TableName as F441, tables.Title as F445, tables.Subject as F444, tables.IDfield as F487, tables.ListOrderByField as F491, tables.ListOrderByAscDec as F492, tables.ScreenWidth as F490, tables.ScreenHeight as F488, tables.Checks as F555 FROM `tables`
WHERE TableID = '$TableID'
ORDER BY `TableName` ASC LIMIT 1");
$TableName = $sql->data['F441'];
$Title = $sql->data['F445'];
$Subject = $sql->data['F444'];
$IDfield = $sql->data['F487'];
$ListOrderByField = $sql->data['F491'];
$ListOrderByAscDec = $sql->data['F492'];
$ScreenWidth = $sql->data['F490'];
$ScreenHeight = $sql->data['F488'];
$checks = $sql->data['F555'];
echo ('<table class=record>');
echo ("<tr><th>SQL name</th>
<td>$TableName</td>");
echo ("<th>OrderBy</th>
<td>$ListOrderByField</td>
</tr>");
echo ("<tr><th>Title</th>
<td>$Title</td>");
echo ("<th>Asc/Desc</th>
<td>$ListOrderByAscDec</td>
</tr>");
echo ("<tr><th>Name</th>
<td>$Subject</td>");
echo ("<th>Width</th>
<td>$ScreenWidth</td>
</tr>");
echo ("<tr><th>IDfield</th>
<td>$IDfield</td>");
echo ("<th>Height</th>
<td>$ScreenHeight</td>
</tr>");
echo ("<tr><th>Where</th>
<td>$checks</td>");
echo ("</tr>");
echo ('</table>');
?>
<p><input type=button value="Tablegegevens wijzigen" onClick="javascript: window.open('edittables.php?TableID=<?php echo $TableID; ?>','','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
$lastorder=$_SESSION[last_63];
$_SESSION[last_63]='';
if ($_GET[zoekitem63]) { $zoekitem63 =$_GET[zoekitem63]; } else { $zoekitem63=$_POST[zoekitem63];}
if ($zoekitem63!='')
{
$zoekitem63 = quote('%'.$zoekitem63.'%');
$query = ("
FROM `fields`
WHERE (`FieldName` LIKE $zoekitem63
OR `DisplayName` LIKE $zoekitem63
OR `Name` LIKE $zoekitem63
OR `SessionVar` LIKE $zoekitem63
OR `ListWidth` LIKE $zoekitem63
) AND `fields`.`TableID`='$TableID'
");
}
else
{
$query = ("
FROM `fields`
WHERE 1 AND `fields`.`TableID`='$TableID'
");
}
$lastrec=-1;
$sql->QueryItem("SELECT COUNT(*) AS records$query");
$records=$sql->data[records];
if ($zoekitem63<>'') {$fromrec=0;} else {
if ($lastorder=='') {$fromrec=20*$_POST[pagina];} else {
$sql->QueryItem("SELECT COUNT(*) AS fromrec$query AND `order` < $lastorder");
$fromrec=$sql->data[fromrec]-10;
if($fromrec<0) {$fromrec=0; }
$lastrec=$sql->data[fromrec]-$fromrec;
}}
$sql->Query("SELECT fields.FieldID as F494, fields.FieldName as F465, fields.TableID as F464, fields.DisplayName as F466, fields.Name as F533, fields.SessionVar as F475, fields.ListWidth as F477, fields.Order as F483$query
ORDER BY `order` ASC
LIMIT $fromrec, 20");
if (($part_rights['20/nofilter']==0)) {
echo "<form action=\"\" method=post name=Filter>";
echo "<p class=filter>";
echo "Records: $records ";
$maxpage=(int) (($records+19)/20);
if ($maxpage>1) {
echo "Pagina: ";
echo "<select name=\"pagina\" OnChange=\"Filter.target=''; Filter.action = ''; Filter.submit();\">\n";
for ($i = 0; $i < $maxpage; $i++)
{
$nr=$i+1;
if ($i==$_POST[pagina] && $_POST[Zoek]=='' && $_POST[Reset]=='') {$sel=" selected";} else {$sel="";}
echo "<option value=$i$sel>$nr van $maxpage</option>\n";
}
echo "</select>\n";
}
echo "<input type=text name=\"zoekitem63\" size=25>";
echo "<input type=submit value=\"Zoek\">";
echo "<input type=button value=\"Field toevoegen\" onClick=\"javascript: window.open('addfield.php?FieldID=$FieldID&TableID=$TableID','','width=500,height=600,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>SQLName</th>
<th width=210px>Title</th>
<th width=210px>Name</th>
<th width=210px>SessionVar</th>
<th width=70px>Width</th>
<th width=70px>Order</th>
</tr>
<?php
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$FieldID = $sql->data['F494'];
$FieldName = htmlspecialchars($sql->data['F465']);
$DisplayName = htmlspecialchars($sql->data['F466']);
$Name = htmlspecialchars($sql->data['F533']);
$SessionVar = htmlspecialchars($sql->data['F475']);
$ListWidth = 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?FieldID=$FieldID&TableID=$TableID','wijzigen','width=500,height=600,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes')\">
<td onClick=\"window.open('addfield.php?Order=$Order','toevoegen','width=500,height=600,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes'); no_bubble(event);\"><b>Add</b></td>
<td>$FieldName</td>
<td>$DisplayName</td>
<td>$Name</td>
<td>$SessionVar</td>
<td>$ListWidth</td>
<td>$Order</td>
</tr>");
}
?>
</table>
<br><br><br><table class=ruler><tr><td>Actions</td></tr></table>
<?php
$lastorder=$_SESSION[last_64];
$_SESSION[last_64]='';
if ($_GET[zoekitem64]) { $zoekitem64 =$_GET[zoekitem64]; } else { $zoekitem64=$_POST[zoekitem64];}
if ($zoekitem64!='')
{
$zoekitem64 = quote('%'.$zoekitem64.'%');
$query = ("
FROM `actions`
) AND `actions`.`TableID`='$TableID'
");
}
else
{
$query = ("
FROM `actions`
WHERE 1 AND `actions`.`TableID`='$TableID'
");
}
$lastrec=-1;
$sql->QueryItem("SELECT COUNT(*) AS records$query");
$records=$sql->data[records];
if ($zoekitem64<>'') {$fromrec=0;} else {
if ($lastorder=='') {$fromrec=20*$_POST[pagina];} else {
$sql->QueryItem("SELECT COUNT(*) AS fromrec$query AND `ActionID` < $lastorder");
$fromrec=$sql->data[fromrec]-10;
if($fromrec<0) {$fromrec=0; }
$lastrec=$sql->data[fromrec]-$fromrec;
}}
$sql->Query("SELECT actions.TableID as F460, actions.Action as F461, actions.Part as F462, actions.Code as F463$query
ORDER BY `ActionID` ASC
LIMIT $fromrec, 20");
if (($part_rights['21/nofilter']==0)) {
echo "<form action=\"\" method=post name=Filter>";
echo "<p class=filter>";
echo "Records: $records ";
$maxpage=(int) (($records+19)/20);
if ($maxpage>1) {
echo "Pagina: ";
echo "<select name=\"pagina\" OnChange=\"Filter.target=''; Filter.action = ''; Filter.submit();\">\n";
for ($i = 0; $i < $maxpage; $i++)
{
$nr=$i+1;
if ($i==$_POST[pagina] && $_POST[Zoek]=='' && $_POST[Reset]=='') {$sel=" selected";} else {$sel="";}
echo "<option value=$i$sel>$nr van $maxpage</option>\n";
}
echo "</select>\n";
}
echo "<input type=text name=\"zoekitem64\" size=25>";
echo "<input type=submit value=\"Zoek\">";
echo "<input type=button value=\"Action toevoegen\" onClick=\"javascript: window.open('addaction.php?TableID=$TableID','','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=210px>Action</th>
<th width=210px>Part</th>
<th width=350px>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?TableID=$TableID','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>
</td></tr></table></body>
</html>