Webgui code improvements and fixes
This commit is contained in:
1 parent
dacf32b401
commit
5fe9a52f15
14 files changed
+205
-311
No files matched your search
+32
-32
@@ -206,16 +206,13 @@ echo '<h2>', _('Add Storage'), "</h2>\n";
|
||||
?>
|
||||
<form method="post" action="<?=$g_scriptname?>">
|
||||
<?php
|
||||
/*
|
||||
<div class="mb-3">
|
||||
<label for="sname" class="form-label"><?=_('Name')?></label>
|
||||
<input type="text" class="form-control" id="sname" name="sname">
|
||||
</div> */
|
||||
form_create_text('sname', _('Name'), 40);
|
||||
form_create_select('stype', _('Type'), $opt_stype);
|
||||
?>
|
||||
<button type="submit" name="submit[insert]" class="btn btn-primary"><?=_('Save')?></button>
|
||||
<a href="<?=$g_scriptname?>" class="btn btn-secondary"><?=_('Back')?></a>
|
||||
<div class="container-fluid px-0 my-3">
|
||||
<button type="submit" name="submit[insert]" class="btn btn-primary"><?=_('Save')?></button>
|
||||
<a href="<?=$g_scriptname?>" class="btn btn-secondary"><?=_('Back')?></a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
@@ -230,7 +227,7 @@ $sql = "SELECT sid, sname, stype, capacity, capaunit, x, y, z, wx, wy, wz, angle
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$id]);
|
||||
$storage = $sth->fetch(PDO::FETCH_OBJ);
|
||||
echo '<h1>', _('Storage'), ': ', $storage->sname, "</h1>\n";
|
||||
echo '<h1>', sprintf(_('Storage: %s'), h($storage->sname)), "</h1>\n";
|
||||
|
||||
echo '<table class="table">', "\n";
|
||||
echo '<tr><th style="width:33%">', _('Typ'),"</th><td>", $opt_stype[$storage->stype], "</td></tr>\n";
|
||||
@@ -238,7 +235,7 @@ echo '<tr><th>', _('Capacity'),"</th><td>", $storage->capacity, ' ', $storage->c
|
||||
echo '<tr><th>', _('Location (x, y, z)'),"</th><td>(", $storage->x, ', ', $storage->y, ', ', $storage->z, ")</td></tr>\n";
|
||||
echo '<tr><th>', _('Width (wx, wy, wz)'),"</th><td>(", $storage->wx, ', ', $storage->wy, ', ', $storage->wz, ")</td></tr>\n";
|
||||
echo '<tr><th>', _('Angle'),"</th><td>", $storage->angle, "°</td></tr>\n";
|
||||
echo '<tr><th>', _('Color'),"</th><td>", $storage->color, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Color'),"</th><td>", format_color($storage->color), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Remarks'),"</th><td>", h($storage->remarks), "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
@@ -311,7 +308,8 @@ elseif ($action == ACT_EDIT):
|
||||
|
||||
echo '<h2>', _('Edit Storage'), "</h2>\n";
|
||||
|
||||
$sql = "SELECT sid, sname, stype, x, y, z, wx, wy, wz, angle, capacity, capaunit, remarks "
|
||||
$sql = "SELECT sid, sname, stype, x, y, z, wx, wy, wz, angle, capacity, "
|
||||
. "color, capaunit, remarks "
|
||||
. "FROM storage "
|
||||
. "WHERE sid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -326,19 +324,20 @@ $storage = $sth->fetch(PDO::FETCH_OBJ);
|
||||
<input type="text" class="form-control" id="sname" name="sname" value="<?=h($storage->sname)?>">
|
||||
</div>
|
||||
<?php
|
||||
form_create_text('sname', _('Name'), $storage->name, 40);
|
||||
form_create_select('stype', _('Type'), $opt_stype, $storage->stype);
|
||||
?>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?=_('Position (x, y, z) in mm')?></label>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="x" name="x" min="0" value="<?=$storage->x ?>">
|
||||
<input type="number" class="form-control" id="x" name="x" min="0" max="65535" value="<?=$storage->x ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="y" name="y" value="<?=$storage->y ?>">
|
||||
<input type="number" class="form-control" id="y" name="y" min="-32768" max="32767" value="<?=$storage->y ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="z" name="z" value="<?=$storage->z ?>">
|
||||
<input type="number" class="form-control" id="z" name="z" min="-32768" max="32767" value="<?=$storage->z ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -346,40 +345,41 @@ form_create_select('stype', _('Type'), $opt_stype, $storage->stype);
|
||||
<label class="form-label"><?=_('Width (x, y, z) in mm')?></label>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="wx" name="wx" min="0" value="<?=$storage->wx ?>">
|
||||
<input type="number" class="form-control" id="wx" name="wx" min="0" max="65535" value="<?=$storage->wx ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="wy" name="wy" min="0" value="<?=$storage->wy ?>">
|
||||
<input type="number" class="form-control" id="wy" name="wy" min="0" max="65535" value="<?=$storage->wy ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="wz" name="wz" min="0" value="<?=$storage->wz ?>">
|
||||
<input type="number" class="form-control" id="wz" name="wz" min="0" max="65535" value="<?=$storage->wz ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="angle" class="form-label"><?=_('Angle, deg.')?></label>
|
||||
<input type="number" class="form-control" id="angle" name="angle" value="<?=$storage->angle ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="capacity" class="form-label"><?=_('Capacity')?></label>
|
||||
<input type="number" class="form-control" id="capacity" name="capacity" value="<?=$storage->capacity ?>">
|
||||
</div>
|
||||
<?php
|
||||
form_create_numeric('angle', _('Anglem deg.'), $storage->angle, 0, 359, 1);
|
||||
form_create_numeric('capacity', _('Capacity'), $storage->capacity, 0, 32767);
|
||||
form_create_select('capaunit', _('Capacity Unit'), $opt_capaunit, $storage->capaunit);
|
||||
/* <div class="mb-3">
|
||||
<label for="color"><?=_('Color')?></label>
|
||||
<input type="color" class="form-control" id="color" name="color" value="#<?=$storage->color ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($storage->remarks)?></textarea>
|
||||
</div> */
|
||||
form_create_color('color', _('Color'), $storage->color);
|
||||
form_create_textarea('remarks', _('Remarks'), 3, 150, $storage->remarks);
|
||||
?>
|
||||
<button type="submit" name="submit[update]" class="btn btn-primary"><?=_('Save')?></button>
|
||||
<a href="<?=$g_scriptname?>?f=view&id=<?=$id?>" class="btn btn-secondary"><?=_('Back')?></a>
|
||||
</form>
|
||||
<script>
|
||||
document.getElementById('capaunit').addEventListener('change', function () {
|
||||
const capacity = document.getElementById('capacity');
|
||||
if (this.value === 'pcs') {
|
||||
capacity.step = 1;
|
||||
decpl = 0;
|
||||
} else {
|
||||
capacity.step = 0.01;
|
||||
decpl = 2;
|
||||
}
|
||||
if (capacity.value !== '' && Number.isFinite(Number(capacity.value))) {
|
||||
capacity.value = Number(capacity.value).toFixed(decpl);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
||||
elseif ($action == ACT_DELETE):
|
||||
|
||||
Reference in new issue
Block a user