More webgui work. Filters e.g.
This commit is contained in:
+58
-49
@@ -25,40 +25,24 @@ switch ($submit = form_get_action()) {
|
||||
case 'del': $action = ACT_DELETE; break;
|
||||
|
||||
case 'insert':
|
||||
$sname = gpc_get_string($_POST, 'sname');
|
||||
$stype = gpc_get_int($_POST, 'stype');
|
||||
$sql = "INSERT INTO storage "
|
||||
. " (vid, sname, stype) "
|
||||
. "VALUES "
|
||||
. " (:vid, :sname, :stype)";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->bindValue(':vid', $user->vid, PDO::PARAM_INT);
|
||||
$sth->bindValue(':sname', $sname, PDO::PARAM_STR);
|
||||
$sth->bindValue(':stype', $stype, PDO::PARAM_INT);
|
||||
$sth->execute();
|
||||
$id = $pdo->lastInsertId();
|
||||
$p[':vid'] = $user->vid;
|
||||
$p[':sname'] = gpc_get_string($_POST, 'sname');
|
||||
$p[':stype'] = gpc_get_int($_POST, 'stype');
|
||||
$id = db_exec_insert('storage', $p);
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$sname = gpc_get_string($_POST, 'sname');
|
||||
$x = gpc_get_int($_POST, 'x');
|
||||
$y = gpc_get_int($_POST, 'y');
|
||||
$z = gpc_get_int($_POST, 'z');
|
||||
$remarks = gpc_get_string($_POST, 'remarks', 150);
|
||||
$sql = "UPDATE storage "
|
||||
. "SET sname=:sname,"
|
||||
. " x=:x, y=:y, z=:z,"
|
||||
. " remarks=:remarks "
|
||||
. "WHERE sid=:sid";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->bindValue(':sid', $id, PDO::PARAM_INT);
|
||||
$sth->bindValue(':sname', $sname, PDO::PARAM_STR);
|
||||
$sth->bindValue(':x', $x, PDO::PARAM_INT);
|
||||
$sth->bindValue(':y', $y, PDO::PARAM_INT);
|
||||
$sth->bindValue(':z', $z, PDO::PARAM_INT);
|
||||
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$p[':sid'] = $id;
|
||||
$p[':sname'] = gpc_get_string($_POST, 'sname');
|
||||
$p[':x'] = gpc_get_int($_POST, 'x');
|
||||
$p[':y'] = gpc_get_int($_POST, 'y');
|
||||
$p[':z'] = gpc_get_int($_POST, 'z');
|
||||
$p[':wx'] = gpc_get_int($_POST, 'wx');
|
||||
$p[':wy'] = gpc_get_int($_POST, 'wy');
|
||||
$p[':wz'] = gpc_get_int($_POST, 'wz');
|
||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||
db_exec_update('storage', $p, 'sid');
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
@@ -111,7 +95,7 @@ echo '<h1>', $pagetitle, "</h1>\n";
|
||||
|
||||
// Storage
|
||||
// stype from dropdown
|
||||
$sql = "SELECT sid, sname, remarks "
|
||||
$sql = "SELECT sid, sname, x, y, z, remarks "
|
||||
. "FROM storage "
|
||||
. "WHERE vid=? "
|
||||
. "ORDER BY sid";
|
||||
@@ -121,15 +105,17 @@ $res = $sth->fetchAll();
|
||||
echo '<table class="table table-striped">', "\n";
|
||||
echo "<thead>\n";
|
||||
echo "<tr>";
|
||||
echo "<th>" . _('Name') . "</th>";
|
||||
echo "<th>" . _('Remarks') . "</th>";
|
||||
echo "<th>", _('Name'), "</th>";
|
||||
echo "<th>", _('Position'), "</th>";
|
||||
echo "<th>", _('Remarks'), "</th>";
|
||||
echo "<th> </th>";
|
||||
echo "</tr>\n";
|
||||
echo "</thead>\n";
|
||||
foreach ($res as $row) {
|
||||
echo "<tr>\n";
|
||||
echo "<td>". $row['sname'] ."</td>\n";
|
||||
echo "<td>". $row['remarks'] ."</td>\n";
|
||||
echo "<td>", $row['sname'], "</td>\n";
|
||||
echo "<td>", join(',', array($row['x'] ?? '?', $row['y'] ?? '?', $row['z'])), "</td>\n";
|
||||
echo "<td>", $row['remarks'], "</td>\n";
|
||||
form_action_buttons($g_scriptname, $row['sid']);
|
||||
echo "</tr>\n";
|
||||
}
|
||||
@@ -203,7 +189,7 @@ elseif ($action == ACT_VIEW):
|
||||
// ========== VARIANT: view single record =====================================
|
||||
|
||||
$opt_unit = db_get_options(6);
|
||||
$sql = "SELECT sid, sname, stype, capacity, capaunit, x, y, z, remarks "
|
||||
$sql = "SELECT sid, sname, stype, capacity, capaunit, x, y, z, wx, wy, wz, remarks "
|
||||
. "FROM storage "
|
||||
. "WHERE sid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -212,15 +198,16 @@ $storage = $sth->fetch(PDO::FETCH_OBJ);
|
||||
echo '<h2>', $storage->sname, "</h2>\n";
|
||||
|
||||
echo '<table class="table">', "\n";
|
||||
echo '<tr><th style="width:20%">', _('Typ'),"</th><td>", $stype[$storage->stype], "</td></tr>\n";
|
||||
echo '<tr><th style="width:33%">', _('Typ'),"</th><td>", $stype[$storage->stype], "</td></tr>\n";
|
||||
echo '<tr><th>', _('Capacity'),"</th><td>", $storage->capacity, ' ', $storage->capaunit, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Location (x, y, z)'),"</th><td>(", $storage->x ?? '?', ', ', $storage->y ?? '?', ', ', $storage->z, ")</td></tr>\n";
|
||||
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>', _('Remarks'),"</th><td>", $storage->remarks, "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
form_view_buttons($g_scriptname, $id);
|
||||
|
||||
// Zugeordnete Kisten hier anzeigen
|
||||
// show assigned boxes here
|
||||
echo '<h3>', _('Boxes in storage'), "</h3>\n";
|
||||
|
||||
$sql = "SELECT boxid, label, color FROM box WHERE sid=?";
|
||||
@@ -228,9 +215,15 @@ $sth = $pdo->prepare($sql);
|
||||
$sth->execute([$id]);
|
||||
$res = $sth->fetchall();
|
||||
if (count($res) > 0) {
|
||||
echo '<table class="table table-sm">';
|
||||
foreach ($res as $row) {
|
||||
echo "$boxid $label $color";
|
||||
echo "<tr>";
|
||||
echo '<td>', $row['label'], "</td>";
|
||||
echo '<td>', $row['color'], "</td>";
|
||||
echo '<td><a title="', _('View'), '" href="box.php?f=view&id=', $row['boxid'], '"><i class="bi-eye"></i></a></td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
} else {
|
||||
echo '<p>', _('No boxes contained'), "</p>\n";
|
||||
}
|
||||
@@ -260,7 +253,7 @@ elseif ($action == ACT_EDIT):
|
||||
|
||||
echo '<h2>', _('Edit Storage'), "</h2>\n";
|
||||
|
||||
$sql = "SELECT sid, sname, stype, remarks "
|
||||
$sql = "SELECT sid, sname, stype, x, y, z, wx, wy, wz, remarks "
|
||||
. "FROM storage "
|
||||
. "WHERE sid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -275,16 +268,32 @@ $storage = $sth->fetch(PDO::FETCH_OBJ);
|
||||
<input type="text" class="form-control" id="sname" name="sname" value="<?=$storage->sname ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="x" class="form-label"><?=_('Position x')?></label>
|
||||
<input type="number" class="form-control" id="x" name="x" value="<?=$storage->x ?>">
|
||||
<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 ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="y" name="y" value="<?=$storage->y ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="z" name="z" value="<?=$storage->z ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="y" class="form-label"><?=_('Position y')?></label>
|
||||
<input type="number" class="form-control" id="y" name="y" value="<?=$storage->y ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="z" class="form-label"><?=_('Position z')?></label>
|
||||
<input type="number" class="form-control" id="z" name="z" value="<?=$storage->z ?>">
|
||||
<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 ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="wy" name="wy" min="0" value="<?=$storage->wy ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="wz" name="wz" min="0" value="<?=$storage->wz ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||
|
||||
Reference in New Issue
Block a user