Added position to equipment

This commit is contained in:
2026-09-20 09:19:18 +02:00
parent 2fc74c0677
commit 5fd6c68b4f
8 changed files with 74 additions and 26 deletions
+24 -3
View File
@@ -75,6 +75,9 @@ switch ($submit = form_get_action()) {
if ($p[':manufacturer'] <= 0) $p[':manufacturer'] = NULL;
$p[':ecat'] = gpc_get_int($_POST, 'category');
if ($p[':ecat'] <= 0) $p[':ecat'] = NULL;
$p[':x'] = gpc_get_uint($_POST, 'x');
$p[':y'] = gpc_get_int($_POST, 'y');
$p[':z'] = gpc_get_int($_POST, 'z');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$allowed = db_load_enum('equipment', 'flags');
$p[':flags'] = gpc_get_set($_POST, 'flags', $allowed, true, NULL);
@@ -443,7 +446,8 @@ elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT eid, ename, model, serial, purchdate, price, weight, "
. " supplier, manufacturer, ecat, shortname, remarks, flags "
. "supplier, manufacturer, ecat, shortname, x, y, z, flags, "
. "remarks "
. "FROM equipment "
. "WHERE eid=?";
$sth = $pdo->prepare($sql);
@@ -468,6 +472,9 @@ echo '<tr><th>', _('Price'),"</th><td>", format_currency($equipment->price), "</
echo '<tr><th>', _('Purchase date'),"</th><td>", format_date($equipment->purchdate), "</td></tr>\n";
echo '<tr><th>', _('Supplier'),"</th><td>", $equipment->supplier ? $opt_supplier[$equipment->supplier] : 'n/a', "</td></tr>\n";
echo '<tr><th>', _('Category'),"</th><td>", $opt_ecat[$equipment->ecat], "</td></tr>\n";
if (!empty($equipment->x)) {
echo '<tr><th>', _('Location (x, y, z)'),"</th><td>(", $equipment->x, ', ', $equipment->y, ', ', $equipment->z, ")</td></tr>\n";
}
echo '<tr><th>', _('Remarks'),"</th><td>", h($equipment->remarks, br:true), "</td></tr>\n";
echo '<tr><th>', _('Flags'),"</th><td>", $equipment->flags, "</td></tr>\n";
echo "</table>\n";
@@ -695,8 +702,8 @@ foreach ($sth->fetchAll() as $row) {
$supplier[$row['compid']] = $row['compname'];
}
$sql = "SELECT eid, ename, model, serial, weight, price, purchdate,"
. " supplier, manufacturer, ecat, shortname, remarks, flags "
$sql = "SELECT eid, ename, model, serial, weight, price, purchdate, "
. "supplier, manufacturer, ecat, shortname, x, y, z, remarks, flags "
. "FROM equipment "
. "WHERE eid=?";
$sth = $pdo->prepare($sql);
@@ -739,6 +746,20 @@ $equipment = $sth->fetch(PDO::FETCH_OBJ);
form_create_select('supplier', _('Supplier'), $opt_supplier, $equipment->supplier);
form_create_select('category', _('Category'), $g_opt_unknown + $opt_ecat, $equipment->ecat);
?>
<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="<?=$equipment->x ?>">
</div>
<div class="col">
<input type="number" class="form-control" id="y" name="y" value="<?=$equipment->y ?>">
</div>
<div class="col">
<input type="number" class="form-control" id="z" name="z" value="<?=$equipment->z ?>">
</div>
</div>
</div>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($equipment->remarks, br:false)?></textarea>