More webgui development

This commit is contained in:
2024-04-30 19:38:28 +02:00
parent c3b5ef95a9
commit 0c09ce2916
21 changed files with 1056 additions and 155 deletions
+48 -6
View File
@@ -16,17 +16,14 @@ require 'header.php';
echo "<h1>$pagetitle</h1>\n";
?>
<p>Search will be implemented later.
This page is currently just a placeholder.</p>
<form method="post" action="<?=$g_scriptname?>">
<div>
<label for="needle">Suche nach:</label>
<input type="text" id="needle" name="needle" value="<?=$needle?>" autofocus>
</div>
<div>
<input type="checkbox" id="remarks" name="ck_remarks">
<label for="remarks">Bemerkungsfelder Berücksichtigen</label>
<input type="checkbox" id="remarks" name="ck_remarks"<?php if (isset($_POST['ck_remarks'])) echo ' checked'; ?>>
<label for="remarks">Bemerkungsfelder berücksichtigen</label>
</div>
<button type="submit" class="btn btn-primary" name="submit[search]"><?=_('Search')?></button>
</form>
@@ -35,6 +32,51 @@ This page is currently just a placeholder.</p>
if (isset($needle)) {
$sqlneedle = '%'.$needle.'%';
}
$remarks = isset($_POST['ck_remarks']) ? ' OR remarks LIKE :needle' : '';
// equipment
$sql = "SELECT eid, ename, model, remarks "
. "FROM equipment "
. "WHERE ename LIKE :needle OR model LIKE :needle" . $remarks;
$sth = $pdo->prepare($sql);
$sth->execute([':needle' => $sqlneedle]);
if ($sth->rowCount() > 0) {
echo '<h3>', _('Equipment'), "</h3>\n";
foreach ($sth->fetchAll() as $row) {
$out = $row['ename'] . ' ' . $row['model'];
// mark needle in result
$p0 = strpos($out, $needle);
if ($p0 > 0) {
$out = substr_replace($out, '</span>', $p0 + strlen($needle), 0);
$out = substr_replace($out, '<span style="background:#ffef00;">', $p0, 0);
}
echo '<p>', $out;
echo '';
echo "</p>\n";
}
}
// inventory
$sql = "SELECT invid, invname, remarks "
. "FROM inventory "
. "WHERE invname LIKE :needle" . $remarks;
$sth = $pdo->prepare($sql);
$sth->execute([':needle' => $sqlneedle]);
if ($sth->rowCount() > 0) {
echo '<h3>', _('Inventory'), "</h3>\n";
foreach ($sth->fetchAll() as $row) {
$out = $row['invname'] . ' ' . $row['model'];
// mark needle in result
$p0 = strpos($out, $needle);
if ($p0 > 0) {
$out = substr_replace($out, '</span>', $p0 + strlen($needle), 0);
$out = substr_replace($out, '<span style="background:#ffef00;">', $p0, 0);
}
echo '<p>', $out;
echo '';
echo "</p>\n";
}
}
}
include 'footer.php';