More work an webgui

This commit is contained in:
2024-04-10 20:13:37 +02:00
parent 4b5ba85a77
commit aaa452cbb5
20 changed files with 842 additions and 359 deletions
+14 -11
View File
@@ -98,13 +98,9 @@ echo "<td></td>";
echo "</tr>\n";
foreach ($res as $row) {
echo "<tr>\n";
echo "<td>". $row['label'] ."</td>\n";
$style = 'background-color:#' . $row['color'];
if (get_color_brightness($row['color']) < 0.4) {
$style .= ';color:white';
}
echo '<td><span style="', $style,'">#'. $row['color'] ."</span></td>\n";
echo "<td>". $row['content'] ."</td>\n";
echo '<td>', $row['label'], "</td>\n";
echo '<td>', format_color(strtoupper($row['color'])), "</td>\n";
echo '<td>', $row['content'], "</td>\n";
echo '<td class="text-end">', format_float($row['weight'], 2), "</td>\n";
form_action_buttons($g_scriptname, $row['boxid']);
echo "</tr>\n";
@@ -123,7 +119,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add Box'), "</h2>\n";
?>
<form method="post">
<form method="post" action="<?=$g_Scriptname?>">
<div class="mb-3">
<label for="label" class="form-label"><?=_('Label')?></label>
<input type="text" maxlength="20" class="form-control" id="label" name="label" autofocus>
@@ -167,7 +163,7 @@ echo '<h2>', $box->label, "</h2>\n";
echo '<table class="table">', "\n";
echo '<tr><th style="width:20%">', _('Content'),"</th><td>", $box->content, "</td></tr>\n";
echo '<tr><th>', _('Color'), '</th><td style="background-color:#', $box->color, '">#', $box->color, "</td></tr>\n";
echo '<tr><th>', _('Color'), '</th><td>', format_color($box->color), "</td></tr>\n";
echo '<tr><th>', _('Weight'), '</th><td>', format_float($box->weight, 2, 'kg'), "</td></tr>\n";
echo '<tr><th>', _('Remarks'),"</th><td>", $box->remarks, "</td></tr>\n";
echo "</table>\n";
@@ -176,25 +172,32 @@ form_view_buttons($g_scriptname, $id);
// Inventory in box
// WIP
$sql = "SELECT invid, invname FROM inventory WHERE boxtype='box' AND boxid=?";
$sql = "SELECT invid, invname, weight FROM inventory WHERE boxtype='box' AND boxid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$res = $sth->fetchAll();
echo '<h3>', _('Inventory in box'), "</h3>\n";
$weight_total = 0.0;
if ($res) {
echo '<table class="table table-striped">', "\n";
echo "<thead>\n";
echo "<tr>";
echo '<th>', _('Inventory'), "</th>";
echo '<th>', _('Weight'), "</th>";
echo "<td></td>";
echo "</tr>\n";
foreach ($res as $row) {
echo "<tr>\n";
echo "<td>", $row['invname'], "</td>\n";
echo "<td>", format_float($row['weight'], 2, 'kg'), "</td>\n";
form_action_buttons('inventory.php', $row['invid']);
echo "</tr>\n";
$weight_total += $row['weight'];
}
echo "<tfoot>";
echo '<tr><td></td><td>', format_float($weight_total, 2, 'kg'), '</td>', "\n";
echo "</tfoot>\n";
echo "</table>\n";
} else {
echo '<p>', _('Box is empty'), "</p>\n";
@@ -212,7 +215,7 @@ $box = $sth->fetch(PDO::FETCH_OBJ);
echo '<h2>', _('Edit Box'), "</h2>\n";
?>
<form method="post">
<form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3">
<label for="label" class="form-label"><?=_('Label')?></label>