125 lines
2.7 KiB
PHP
125 lines
2.7 KiB
PHP
<?php
|
|
/*
|
|
parts.php
|
|
OpenLog Online Logbook
|
|
Copyright (C) 2026 Rod Wright
|
|
|
|
SPDX-License-Identifier: GPL-2.0
|
|
*/
|
|
|
|
include("functions.php");
|
|
|
|
if (isset($_SESSION['login'])) {
|
|
$loggedin = TRUE;
|
|
} else {
|
|
$loggedin = FALSE;
|
|
}
|
|
|
|
$print = $_REQUEST['print'] ?? NULL;
|
|
$add = $_REQUEST['add'] ?? NULL;
|
|
$sort = $_REQUEST['sort'] ?? NULL;
|
|
$order = $_REQUEST['order'] ?? NULL;
|
|
|
|
$logname = LOG_NAME;
|
|
$uidtext = UID_TEXT;
|
|
|
|
if ($add) {
|
|
header("Location: partentry.php?add=1");
|
|
}
|
|
|
|
if (! $sort) $sort = "uid";
|
|
if ($order == "asc") {
|
|
$order = "desc";
|
|
} else if ($order == "desc") {
|
|
$order = "asc";
|
|
} else {
|
|
$order = "asc";
|
|
}
|
|
|
|
|
|
if ($print) {
|
|
$sbcolor = P_SIDEBAR_COLOR;
|
|
$mbgcolor = P_MENUBG_COLOR;
|
|
} else {
|
|
$sbcolor = SIDEBAR_COLOR;
|
|
$mbgcolor = MENUBG_COLOR;
|
|
}
|
|
|
|
framework("begin", "$logname", "Parts", $print);
|
|
|
|
pagetable("begin");
|
|
if (!$print) {
|
|
pageblock("left", "begin");
|
|
sidemenu();
|
|
pageblock("left", "end");
|
|
}
|
|
pageblock("right", "begin");
|
|
banner($print);
|
|
if ($loggedin) {
|
|
echo "
|
|
<br><form method=\"post\" action=\"partentry.php\">
|
|
<input type=\"submit\" name=\"add\" value=\"Add New Part\">
|
|
</form><br>
|
|
";
|
|
}
|
|
echo "
|
|
<table width=\"100%\" border=\"1\" cellpadding=\"5\">
|
|
<tr>
|
|
<th><a href=\"parts.php?sort=uid&order=$order\" title=\"Sort by $uidtext\">$uidtext</a></th>
|
|
<th><a href=\"parts.php?sort=partnum&order=$order\" title=\"Sort by Part Number\">Part Number</a></th>
|
|
<th><a href=\"parts.php?sort=sernum&order=$order\" title=\"Sort by Serial Number\">Serial Number</a></th>
|
|
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
|
|
</tr>
|
|
";
|
|
$partqry = mysqli_query($db, "select * from parts order by $sort $order");
|
|
while ($partline = mysqli_fetch_assoc($partqry)) {
|
|
if (!$partline['uid']) {
|
|
$pluidtxt = "none";
|
|
} else {
|
|
$pluidtxt = $partline['uid'];
|
|
}
|
|
if ($loggedin) {
|
|
printf(
|
|
"
|
|
<tr>
|
|
<td>
|
|
<a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a>
|
|
</td>
|
|
<td>%s</td>
|
|
<td>%s</td>
|
|
<td>%s</td>",
|
|
$partline['partid'],
|
|
$pluidtxt,
|
|
$partline['partnum'],
|
|
$partline['sernum'],
|
|
$partline['partname']
|
|
);
|
|
} else {
|
|
printf(
|
|
"
|
|
<tr>
|
|
<td>%s</td>
|
|
<td>%s</td>
|
|
<td>%s</td>
|
|
<td>%s</td>",
|
|
$pluidtxt,
|
|
$partline['partnum'],
|
|
$partline['sernum'],
|
|
$partline['partname']
|
|
);
|
|
}
|
|
echo "
|
|
</tr>
|
|
";
|
|
}
|
|
echo "
|
|
</table>
|
|
";
|
|
|
|
echo "<br><br>";
|
|
banner($print);
|
|
pageblock("right", "end");
|
|
pagetable("end");
|
|
|
|
framework("end", "", "", $print);
|