More webgui development
This commit is contained in:
+19
-14
@@ -39,7 +39,7 @@ switch ($submit = form_get_action()) {
|
||||
case 'insert':
|
||||
$p[':invname'] = gpc_get_string($_POST, 'invname');
|
||||
$p[':number'] = gpc_get_int($_POST, 'number');
|
||||
$p[':boxtype'] = gpc_get_string($_POST, 'boxtype');
|
||||
$p[':conttype'] = gpc_get_string($_POST, 'conttype');
|
||||
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
||||
$p[':boxid'] = gpc_get_int($_POST, 'boxid');
|
||||
$p[':invcond'] = 'good';
|
||||
@@ -51,7 +51,7 @@ switch ($submit = form_get_action()) {
|
||||
$p[':invid'] = $id;
|
||||
$p[':invname'] = gpc_get_string($_POST, 'invname');
|
||||
$p[':number'] = gpc_get_int($_POST, 'number');
|
||||
$p[':boxtype'] = gpc_get_string($_POST, 'boxtype');
|
||||
$p[':conttype'] = gpc_get_string($_POST, 'conttype');
|
||||
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
||||
$p[':boxid'] = gpc_get_int($_POST, 'boxid');
|
||||
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value
|
||||
@@ -121,10 +121,10 @@ $where = join(' AND ', $w);
|
||||
$order = ' ORDER BY invname';
|
||||
|
||||
$sql = "SELECT i.invid, i.invname, i.number, i.invcond, s.sname AS container "
|
||||
. "FROM inventory AS i JOIN storage AS s ON (i.boxtype='storage' AND i.sid=s.sid)";
|
||||
. "FROM inventory AS i JOIN storage AS s ON (i.conttype='storage' AND i.sid=s.sid)";
|
||||
$sql .= ' WHERE ' . $where;
|
||||
$sql .= " UNION SELECT i.invid, i.invname, i.number, i.invcond, b.label AS container "
|
||||
. "FROM inventory AS i JOIN box AS b ON (i.boxtype='box' AND i.boxid=b.boxid) "
|
||||
. "FROM inventory AS i JOIN box AS b ON (i.conttype='box' AND i.boxid=b.boxid) "
|
||||
. " JOIN storage AS s ON (b.sid=s.sid) ";
|
||||
$sql .= ' WHERE ' . $where;
|
||||
$sql .= $order;
|
||||
@@ -193,6 +193,7 @@ echo "<th>", _('Name'), "</th>\n";
|
||||
echo "<th>", _('Container'), "</th>\n";
|
||||
echo "<th>", _('Number'), "</th>\n";
|
||||
echo "<th>", _('Condition'), "</th>\n";
|
||||
echo "<th>", _('Tags'), "</th>\n";
|
||||
echo "<td></td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</thead>\n";
|
||||
@@ -202,6 +203,7 @@ foreach ($res as $row) {
|
||||
echo "<td>", $row['container'], "</td>\n";
|
||||
echo "<td>", $row['number'], "</td>\n";
|
||||
echo "<td>", ($opt_invcond[$row['invcond']] ?? ''), "</td>\n";
|
||||
echo "<td>", _('No tags assigned'), "</td>\n";
|
||||
form_action_buttons($g_scriptname, $row['invid']);
|
||||
echo "</tr>\n";
|
||||
}
|
||||
@@ -228,8 +230,8 @@ echo '<h2>', _('Add Inventory'), "</h2>\n";
|
||||
<input type="number" class="form-control" id="number" name="number" value="1">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="boxtype" class="form-label"><?=_('Boxtype')?></label>
|
||||
<select class="form-select" name="boxtype" id="boxtype">
|
||||
<label for="conttype" class="form-label"><?=_('Container type')?></label>
|
||||
<select class="form-select" name="conttype" id="conttype">
|
||||
<option value="box"><?=_('Box')?></option>
|
||||
<option value="storage"><?=_('Storage')?></option>
|
||||
</select>
|
||||
@@ -248,16 +250,16 @@ form_create_select('boxid', _('Box'), $opt_box);
|
||||
elseif ($action == ACT_VIEW):
|
||||
// ========== VARIANT: view single record =====================================
|
||||
|
||||
$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate,"
|
||||
. " invcond,remarks "
|
||||
$sql = "SELECT invname, conttype, sid, boxid, number, weight, price, purchdate,"
|
||||
. " invcond, remarks "
|
||||
. "FROM inventory "
|
||||
. "WHERE invid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$id]);
|
||||
$inventory = $sth->fetch(PDO::FETCH_OBJ);
|
||||
|
||||
// boxtype can be storage or box
|
||||
switch ($inventory->boxtype) {
|
||||
// container type can be storage or box
|
||||
switch ($inventory->conttype) {
|
||||
case 'storage':
|
||||
$sql = "SELECT sname, vid FROM storage WHERE sid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -286,7 +288,7 @@ switch ($inventory->boxtype) {
|
||||
echo '<h2>', $inventory->invname, "</h2>\n";
|
||||
|
||||
echo '<table class="table">', "\n";
|
||||
echo '<tr><th style="width:20%">', _('Box type'),"</th><td>", $inventory->boxtype, "</td></tr>\n";
|
||||
echo '<tr><th style="width:20%">', _('Box type'),"</th><td>", $inventory->conttype, "</td></tr>\n";
|
||||
|
||||
// Container with link
|
||||
echo "<tr><th>", _('Container'),"</th><td>", sprintf(_('%s in %s'), $box['label'], $storagename);
|
||||
@@ -299,6 +301,9 @@ echo "<tr><th>", _('Price'), "</th><td>", format_currency($inventory->price), "<
|
||||
echo "<tr><th>", _('Purchase date'), "</th><td>", $inventory->purchdate, "</td></tr>\n";
|
||||
echo "<tr><th>", _('Condition'), "</th><td>", $inventory->invcond, "</td></tr>\n";
|
||||
echo "<tr><th>", _('Remarks'), "</th><td>", $inventory->remarks, "</td></tr>\n";
|
||||
|
||||
form_tag_assignment($g_scriptname, $id);
|
||||
|
||||
echo "</table>\n";
|
||||
|
||||
form_view_buttons($g_scriptname, $id);
|
||||
@@ -306,7 +311,7 @@ form_view_buttons($g_scriptname, $id);
|
||||
elseif ($action == ACT_EDIT):
|
||||
// ========== VARIANT: edit single record =====================================
|
||||
|
||||
$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, "
|
||||
$sql = "SELECT invname, conttype, sid, boxid, number, weight, price, purchdate, "
|
||||
. " invcond, remarks "
|
||||
. "FROM inventory "
|
||||
. "WHERE invid=?";
|
||||
@@ -331,8 +336,8 @@ $inventory = $sth->fetch(PDO::FETCH_OBJ);
|
||||
<input type="text" class="form-control" id="weight" name="weight" value="<?=format_float($inventory->weight); ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="boxtype" class="form-label"><?=_('Boxtype')?></label>
|
||||
<select class="form-select" name="boxtype" id="boxtype">
|
||||
<label for="conttype" class="form-label"><?=_('Container type')?></label>
|
||||
<select class="form-select" name="conttype" id="conttype">
|
||||
<option value="box"><?=_('Box')?></option>
|
||||
<option value="storage"><?=_('Storage')?></option>
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user