Webgui code improvements for dropdown handling
This commit is contained in:
@@ -81,7 +81,7 @@ group (here as example 'yms'). The user which runs the local gui (here
|
||||
chgrp yms /var/local/lib/yms/thumb
|
||||
chmod -R 770 /var/local/lib/yms
|
||||
|
||||
4. Setup local GUI
|
||||
5. Setup local GUI
|
||||
|
||||
Create a local database user with same name as your computer user and allow
|
||||
database access with current unix credentials. E.g if your current unix user
|
||||
|
||||
Vendored
+1
@@ -17,6 +17,7 @@ Depends:
|
||||
gir1.2-gtk-3.0,
|
||||
gir1.2-rsvg-2.0,
|
||||
python3-mysqldb,
|
||||
python3-fitz,
|
||||
python3-bcrypt,
|
||||
python3-pyudev,
|
||||
php (>= 8.0),
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ foreach ($sth->fetchAll() as $row) {
|
||||
$opt_storage[$row['sid']] = $row['sname'];
|
||||
}
|
||||
|
||||
$opt_boxtype = db_get_options(9);
|
||||
$opt_boxtype = db_get_options(DD_BOX_TYPE);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ $pagetitle = _('Cables');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_cabletype = db_get_options(11);
|
||||
$opt_techname = db_get_options(12);
|
||||
$opt_cabletype = db_get_options(DD_CABLE_TYPE);
|
||||
$opt_techname = db_get_options(DD_CABLE_TECHNAME);
|
||||
$opt_cablecond = db_load_enum('cable', 'cablecond', true, true);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ require 'lib/gpc.inc';
|
||||
$pagetitle=_('Company');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
$opt_comptype = db_get_options(2);
|
||||
$opt_comptype = db_get_options(DD_COMPANY_TYPE);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
|
||||
+7
-1
@@ -84,6 +84,8 @@ switch ($submit = form_get_action()) {
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
# changing ddval would need to update all dependent data
|
||||
# so this is not intended here!
|
||||
$p[':ddtext'] = gpc_get_string($_POST, 'ddtext');
|
||||
$p[':ddshort'] = gpc_get_string($_POST, 'ddshort');
|
||||
$p[':color'] = gpc_get_color($_POST, 'color');
|
||||
@@ -132,7 +134,7 @@ $sth = $pdo->query($sql);
|
||||
foreach ($sth->fetchAll(PDO::FETCH_NUM) as $row) {
|
||||
$num[$row[0]] = $row[1];
|
||||
}
|
||||
$sql = "SELECT ddval, ddtext FROM dropdown WHERE ddid=0 AND ddval>0";
|
||||
$sql = "SELECT ddval, ddtext, flags FROM dropdown WHERE ddid=0 AND ddval>0";
|
||||
$sth = $pdo->query($sql);
|
||||
|
||||
echo "<h1>$pagetitle</h1>\n";
|
||||
@@ -160,7 +162,11 @@ foreach ($sth->fetchAll() as $row) {
|
||||
echo '<td>', $num[$row['ddval']] ?? 0, '</td>';
|
||||
// form_action_buttons($g_scriptname, $row['ddval']);
|
||||
echo "<td>";
|
||||
if ($row['flags'] == 'locked') {
|
||||
echo _('Locked');
|
||||
} else {
|
||||
echo '<a class="text-nowrap" title="', _('Edit'), '" href="', $g_scriptname, '?f=edit&id=', $row['ddval'], '"><i class="bi bi-pencil ms-2"></i></a>';
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ $id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_supplier = db_get_opt_supp($g_opt_unknown);
|
||||
$opt_manufacturer = db_get_opt_manuf($g_opt_unknown);
|
||||
$opt_ecat = db_get_options(4); // Equipment categories
|
||||
$opt_unit = db_get_options(8);
|
||||
$opt_ecat = db_get_options(DD_EQUIPMENT_CATEGORY);
|
||||
$opt_unit = db_get_options(DD_UNIT);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@ $pagetitle = _('Fuses');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_ftype = db_get_options(7);
|
||||
$opt_location = db_get_options(10);
|
||||
$opt_ftype = db_get_options(DD_FUSE_TYPE);
|
||||
$opt_location = db_get_options(DD_FUSE_BLOCK);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
@@ -94,7 +94,7 @@ if ($action == ACT_DEFAULT):
|
||||
// ========== VARIANT: default behavior =======================================
|
||||
|
||||
// lookup tables
|
||||
$opt_ftype_short = db_get_options(7, '', true);
|
||||
$opt_ftype_short = db_get_options(DD_FUSE_TYPE, '', true);
|
||||
|
||||
// load filter from db
|
||||
$flt = db_get_filter($user->id, 212);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* 0.2.0 2026-08-18 First public release tho
|
||||
* 0.2.1 2026-08-28 Foreign keys, bugfixes and output sanitation tho
|
||||
* 0.2.2 2026-09-21 Lots of improvements and fixes tho
|
||||
* 2026-10-01 Dropdown constants for readability tho
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -47,6 +48,22 @@ define('ROLE_CAPTAIN', 'captain');
|
||||
define('ROLE_HELMSMAN', 'helmsman');
|
||||
define('ROLE_SAILOR', 'sailor');
|
||||
|
||||
define('DD_HULL_TYPE', 1);
|
||||
define('DD_COMPANY_TYPE', 2);
|
||||
define('DD_STORAGE_TYPE', 3);
|
||||
define('DD_EQUIPMENT_CATEGORY', 4);
|
||||
define('DD_PROVISION_CATEGORY', 5);
|
||||
define('DD_PROVISION_UNIT', 6);
|
||||
define('DD_FUSE_TYPE', 7);
|
||||
define('DD_UNIT', 8);
|
||||
define('DD_BOX_TYPE', 9);
|
||||
define('DD_FUSE_BLOCK', 10);
|
||||
define('DD_CABLE_TYPE', 11);
|
||||
define('DD_CABLE_TECHNAME', 12);
|
||||
define('DD_INVENTORY_CATEGORY', 13);
|
||||
define('DD_BBN_VESSELDATA', 14);
|
||||
define('DD_MEASUREMENT_CATEGORY', 15);
|
||||
|
||||
// ========== PAGE START CODE =================================================
|
||||
|
||||
// global version string
|
||||
|
||||
+1
-1
@@ -351,7 +351,7 @@ if ($user->role == 'captain') {
|
||||
|
||||
// Storage: 0 - default, 1 - tank
|
||||
// $stype = [ 0 => _('Default'), 1 => _('Tank')];
|
||||
$stype = db_get_options(3);
|
||||
$stype = db_get_options(DD_STORAGE_TYPE);
|
||||
$sql = "SELECT stype, COUNT(stype) "
|
||||
. "FROM storage "
|
||||
. "WHERE vid=? "
|
||||
|
||||
@@ -18,7 +18,7 @@ $opt_storage = db_get_opt_storage($user->vid);
|
||||
$opt_box = db_get_opt_box($user->vid);
|
||||
$opt_invcond = db_load_enum('inventory', 'invcond', true, true);
|
||||
$opt_equipment = db_get_opt_equip($user->vid, [-1 => _('― none ―')]);
|
||||
$opt_icat = db_get_options(13);
|
||||
$opt_icat = db_get_options(DD_INVENTORY_CATEGORY);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
|
||||
+10
-3
@@ -25,7 +25,8 @@ $pagetitle = _('Measurements');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_unit = db_get_options(8);
|
||||
$opt_unit = db_get_options(DD_UNIT);
|
||||
$opt_category = db_get_options(DD_MEASUREMENT_CATEGORY);
|
||||
$opt_accuracy = db_load_enum('measurement', 'accuracy', true, true);
|
||||
$opt_dimensions = array(
|
||||
1 => _('1D'),
|
||||
@@ -102,6 +103,10 @@ switch ($submit = form_get_action()) {
|
||||
$p[':unit'] = gpc_get_int($_POST, 'unit');
|
||||
$p[':accuracy'] = gpc_get_string($_POST, 'accuracy');
|
||||
$p[':mdate'] = gpc_get_date($_POST, 'mdate');
|
||||
$p[':mcat'] = gpc_get_int($_POST, 'mcat');
|
||||
if ($p[':mcat'] == -1) {
|
||||
$p[':mcat'] = NULL;
|
||||
}
|
||||
$p[':note'] = gpc_get_string($_POST, 'note');
|
||||
$p[':eid'] = gpc_get_int($_POST, 'eid');
|
||||
if ($p[':eid'] == -1) {
|
||||
@@ -291,7 +296,7 @@ form_create_select('eid', _('Equipment'), $opt_equipment, $id);
|
||||
elseif ($action == ACT_VIEW):
|
||||
// ========== VARIANT: view single record =====================================
|
||||
|
||||
$sql = "SELECT mname, unit, nval, val1, val2, val3, accuracy, mdate, note, eid "
|
||||
$sql = "SELECT mname, unit, nval, val1, val2, val3, accuracy, mdate, mcat, note, eid "
|
||||
. "FROM measurement "
|
||||
. "WHERE mid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -310,6 +315,7 @@ echo '<tr><th>', _('Value 3'), '</th><td>', $measurement->val3, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Accuracy'), '</th><td>', get_enum($measurement->accuracy), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Date'), '</th><td>', format_date($measurement->mdate), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Note'), '</th><td>', h($measurement->note), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Category'),"</th><td>", $opt_category[$measurement->mcat] ?? 'n/a', "</td></tr>\n";
|
||||
echo '<tr><th>', _('Equipment'), '</th><td>', $opt_equipment[$measurement->eid], "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
@@ -319,7 +325,7 @@ form_view_buttons($g_scriptname, $id);
|
||||
elseif ($action == ACT_EDIT):
|
||||
// ========== VARIANT: edit single record =====================================
|
||||
|
||||
$sql = "SELECT mname, nval, val1, val2, val3, unit, accuracy, note, eid "
|
||||
$sql = "SELECT mname, nval, val1, val2, val3, unit, accuracy, note, eid, mcat "
|
||||
. "FROM measurement "
|
||||
. "WHERE mid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -356,6 +362,7 @@ form_create_select('nval', _('Dimensions'), $opt_dimensions, $measurement->nval)
|
||||
<?php
|
||||
form_create_select('unit', _('Unit'), $opt_unit, $measurement->unit);
|
||||
form_create_select('accuracy', _('Accuracy'), $opt_accuracy, $measurement->accuracy);
|
||||
form_create_select('mcat', _('Category'), $g_opt_none + $opt_category, $measurement->mcat);
|
||||
form_create_select('eid', _('Equipment'), $opt_equipment, $measurement->eid);
|
||||
|
||||
form_edit_buttons($g_scriptname, $id);
|
||||
|
||||
@@ -15,8 +15,8 @@ $pagetitle=_('Provisions');
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_storage = db_get_opt_storage($user->vid);
|
||||
$opt_category = db_get_options(5);
|
||||
$opt_unit = db_get_options(6);
|
||||
$opt_category = db_get_options(DD_PROVISION_CATEGORY);
|
||||
$opt_unit = db_get_options(DD_PROVISION_UNIT);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
|
||||
+10
-3
@@ -14,7 +14,7 @@ $pagetitle = _('Storage');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_stype = db_get_options(3);
|
||||
$opt_stype = db_get_options(SS_STORAGE_TYPE);
|
||||
$opt_capaunit = $g_opt_empty + db_load_enum('storage', 'capaunit', true, true);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
@@ -50,6 +50,7 @@ switch ($submit = form_get_action()) {
|
||||
$p[':capacity'] = gpc_get_int($_POST, 'capacity');
|
||||
if ($p[':capacity'] == 0) $p[':capacity'] = NULL;
|
||||
$p[':capaunit'] = gpc_get_string($_POST, 'capaunit');
|
||||
$p[':color'] = gpc_get_color($_POST, 'color');
|
||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||
db_exec_update('storage', $p, 'sid');
|
||||
$action = ACT_VIEW;
|
||||
@@ -107,7 +108,7 @@ page_caption_search($pagetitle);
|
||||
|
||||
// Storage
|
||||
// stype from dropdown
|
||||
$sql = "SELECT sid, sname, x, y, z, angle, remarks "
|
||||
$sql = "SELECT sid, sname, color, x, y, z, angle, remarks "
|
||||
. "FROM storage "
|
||||
. "WHERE vid=? "
|
||||
. "ORDER BY sid";
|
||||
@@ -119,6 +120,7 @@ echo "<thead>\n";
|
||||
echo "<tr>";
|
||||
echo '<th>#</th>';
|
||||
echo "<th>", _('Name'), "</th>";
|
||||
echo "<th>", _('Color'), "</th>";
|
||||
echo "<th>", _('Position'), "</th>";
|
||||
echo "<th>", _('Remarks'), "</th>";
|
||||
echo "<th> </th>";
|
||||
@@ -132,6 +134,7 @@ foreach ($res as $row) {
|
||||
echo '<a class="text-nowrap" title="', _('View'), '" href="', $g_scriptname, '?f=view&id=', $row['sid'], '"><i class="bi bi-eye ms-2"></i></a>', "\n";
|
||||
echo "</td>\n";
|
||||
echo "<td>", $row['sname'], "</td>\n";
|
||||
echo '<td>', format_color(strtoupper($row['color'])), "</td>\n";
|
||||
if ($row['angle'] != 0) {
|
||||
$angle = " (" . $row['angle'] . "°)";
|
||||
} else {
|
||||
@@ -216,7 +219,7 @@ form_create_select('stype', _('Type'), $opt_stype);
|
||||
elseif ($action == ACT_VIEW):
|
||||
// ========== VARIANT: view single record =====================================
|
||||
|
||||
$opt_unit = db_get_options(6);
|
||||
$opt_unit = db_get_options(DD_PROVISION_UNIT);
|
||||
$sql = "SELECT sid, sname, stype, capacity, capaunit, x, y, z, wx, wy, wz, angle, color, remarks "
|
||||
. "FROM storage "
|
||||
. "WHERE sid=?";
|
||||
@@ -358,6 +361,10 @@ form_create_select('stype', _('Type'), $opt_stype, $storage->stype);
|
||||
<input type="number" class="form-control" id="capacity" name="capacity" value="<?=$storage->capacity ?>">
|
||||
</div>
|
||||
<?php 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>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH YMS 1 "August 2026" "YMS 0.2" "User Commands"
|
||||
.TH YMS 1 "September 2026" "YMS 0.2" "User Commands"
|
||||
.SH NAME
|
||||
yms - Yacht Management Software
|
||||
.SH SYNOPSIS
|
||||
@@ -50,7 +50,7 @@ the application is running.
|
||||
Per-user configuration file for the YMS graphical user interface.
|
||||
|
||||
.TP
|
||||
.I /var/local/yms/
|
||||
.I /var/local/lib/yms/
|
||||
Persistent storage for files managed by YMS.
|
||||
|
||||
The directory contains photos, documents and other media associated
|
||||
@@ -60,7 +60,7 @@ SVG and PDF.
|
||||
YMS stores application data in two separate locations.
|
||||
|
||||
The directory
|
||||
.I /var/local/yms/
|
||||
.I /var/local/lib/yms/
|
||||
contains user-managed photos and documents and should be included
|
||||
in regular backups.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user