Box improvement and some experimental signalk code in webgui

This commit is contained in:
2026-09-15 08:42:56 +02:00
parent 57c42d1398
commit a76848e1da
6 changed files with 91 additions and 9 deletions
+42 -2
View File
@@ -60,7 +60,12 @@ switch ($submit = form_get_action()) {
$p[':label'] = gpc_get_string($_POST, 'label');
$p[':content'] = gpc_get_string($_POST, 'content');
$p[':color'] = gpc_get_color($_POST, 'color');
$p[':wx'] = gpc_get_int($_POST, 'wx');
$p[':wy'] = gpc_get_int($_POST, 'wy');
$p[':wz'] = gpc_get_int($_POST, 'wz');
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 99.99);
$p[':weight_net'] = min(gpc_get_float($_POST, 'weight_net'), 99.99);
$p[':price'] = gpc_get_currency($_POST, 'price');
$p[':sid'] = gpc_get_uint($_POST, 'sid');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
db_exec_update('box', $p, 'boxid');
@@ -163,7 +168,8 @@ foreach ($opt_storage as $k => $v) {
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT boxtype, label, content, box.color, weight, box.remarks, box.sid, sname "
$sql = "SELECT boxtype, label, content, box.color, weight, weight_net, price, "
. "box.wx, box.wy, box.wz, box.sid, box.remarks, sname "
. "FROM box LEFT JOIN storage USING (sid) "
. "WHERE boxid=?";
$sth = $pdo->prepare($sql);
@@ -181,7 +187,10 @@ echo '<table class="table">', "\n";
echo '<tr><th style="width:20%">', _('Box type'),"</th><td>", ($opt_boxtype[$box->boxtype] ?? ''), "</td></tr>\n";
echo '<tr><th>', _('Content'),"</th><td>", $box->content, "</td></tr>\n";
echo '<tr><th>', _('Color'), '</th><td>', format_color($box->color), "</td></tr>\n";
# TODO also show sum of content weights for comparison
echo '<tr><th>', _('Weight'), '</th><td>', format_float($box->weight, 2, 'kg'), "</td></tr>\n";
echo '<tr><th>', _('Empty&nbsp;Weight'), '</th><td>', format_float($box->weight_net, 2, 'kg'), "</td></tr>\n";
echo '<tr><th>', _('Price'),"</th><td>", format_currency($box->price), "</td></tr>\n";
echo '<tr><th>', _('Storage'),"</th><td>", $box->sname, '&nbsp;';
echo '<a title="', _('View'), '" href="storage.php?f=view&id=', $box->sid, '"><i class="bi-eye"></i></a>';
echo "</td></tr>\n";
@@ -276,10 +285,13 @@ if ($res) {
echo '<p>', _('Box is empty'), "</p>\n";
}
# TODO provisions in box
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT boxtype, label, content, color, weight, sid, remarks "
$sql = "SELECT boxtype, label, content, color, weight, weight_net, price, "
. "sid, wx, wy, wz, remarks "
. "FROM box "
. "WHERE boxid=?";
$sth = $pdo->prepare($sql);
@@ -305,10 +317,38 @@ echo '<h2>', _('Edit Box'), "</h2>\n";
<label for="color"><?=_('Color')?></label>
<input type="color" class="form-control" id="color" name="color" value="#<?=$box->color ?>">
</div>
<div class="mb-3">
<label class="form-label"><?=_('Dimensions (L × W × H)')?></label>
<div class="input-group">
<input type="number" class="form-control" name="wx"
value="<?=$box->wx;?>" min="0" step="1"
aria-label="<?=_('Length')?>">
<span class="input-group-text">×</span>
<input type="number" class="form-control" name="wy"
value="<?=$box->wy;?>" min="0" step="1"
aria-label="<?=_('Width')?>">
<span class="input-group-text">×</span>
<input type="number" class="form-control" name="wz"
value="<?=$box->wz;?>" min="0" step="1"
aria-label="<?=_('Height')?>">
<span class="input-group-text">mm</span>
</div>
<div class="form-text">
<?=_('Length × Width × Height')?>
</div>
</div>
<div class="mb-3">
<label for="weight" class="form-label"><?=_('Weight, kg')?></label>
<input type="text" class="form-control" id="weight" name="weight" value="<?=format_float($box->weight); ?>">
</div>
<div class="mb-3">
<label for="weight_net" class="form-label"><?=_('Weight net, kg')?></label>
<input type="text" class="form-control" id="weight_net" name="weight_net" value="<?=format_float($box->weight_net); ?>">
</div>
<div class="mb-3">
<label for="price" class="form-label"><?=sprintf(_('Price, %s'), $g_lconv['currency_symbol']); ?></label>
<input type="text" class="form-control" id="price" name="price" value="<?=format_float($box->price) ?>">
</div>
<?php form_create_select('sid', _('Storage'), $opt_storage, $box->sid); ?>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>