From f109e2621fbc25e0949bb753957999afe70e0ae7 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Sun, 14 Jun 2026 10:56:17 +0200 Subject: [PATCH] Webgui: More mobile friendly touch and much more improvements --- README | 3 + db/mariadb.sql | 39 +- db/minimal.sql | 12 +- locale/de.po | 52 +- webgui/box.php | 32 +- webgui/checklist.php | 7 + webgui/company.php | 24 +- webgui/dl.php | 2 +- webgui/documents.php | 54 +- webgui/equipment.php | 92 +- webgui/globals.inc | 2 +- webgui/header.php | 2 + webgui/index.php | 21 +- webgui/inventory.php | 69 +- webgui/locale/de_DE.po | 1329 +++++++++++++++++------- webgui/locale/de_DE/LC_MESSAGES/yms.mo | Bin 12218 -> 19198 bytes webgui/login.php | 46 +- webgui/maintenance.php | 72 +- webgui/manual.php | 24 +- webgui/measurement.php | 7 +- webgui/projects.php | 120 ++- webgui/provisions.php | 120 ++- webgui/storage.php | 39 +- webgui/tag.php | 2 +- webgui/task.php | 37 +- 25 files changed, 1624 insertions(+), 583 deletions(-) diff --git a/README b/README index 7724611..a5e6393 100644 --- a/README +++ b/README @@ -3,3 +3,6 @@ Prototype Many features are incomplete, buggy or missing. Use at your own risk! + +If inserting a new user you have also to insert a setting value +to assign boat 0. diff --git a/db/mariadb.sql b/db/mariadb.sql index 3bfdfb9..ce37a13 100644 --- a/db/mariadb.sql +++ b/db/mariadb.sql @@ -8,7 +8,7 @@ CREATE TABLE user ( login varchar(20) NOT NULL, pass binary(60) NOT NULL, displayname varchar(100) NOT NULL, - role set('vessel', 'captain','helmsman','sailor') NOT NULL DEFAULT 'sailor', + role enum('vessel','captain','helmsman','sailor') NOT NULL DEFAULT 'sailor', flags set('deleted','locked'), language char(2) NOT NULL DEFAULT 'en', PRIMARY KEY (userid), @@ -48,7 +48,7 @@ CREATE TABLE dropdown ( ddtext varchar(50) NOT NULL, ddshort varchar(4) DEFAULT NULL, color char(6) DEFAULT NULL, - flags enum('locked', 'fixed') DEFAULT NULL, + flags enum('locked','fixed') DEFAULT NULL, PRIMARY KEY (ddid, ddval) ); @@ -77,13 +77,15 @@ CREATE TABLE storage ( sname varchar(40) NOT NULL, stype tinyint(3) NOT NULL DEFAULT 0, capacity smallint(6) DEFAULT NULL, - capaunit enum('kg', 'l') DEFAULT NULL, + capaunit enum('kg','l') DEFAULT NULL, x smallint(6) UNSIGNED NOT NULL DEFAULT 0, y smallint(6) NOT NULL DEFAULT 0, z smallint(6) NOT NULL DEFAULT 0, wx smallint(6) UNSIGNED NOT NULL DEFAULT 0, wy smallint(6) UNSIGNED NOT NULL DEFAULT 0, wz smallint(6) UNSIGNED NOT NULL DEFAULT 0, + angle smallint(4) NOT NULL DEFAULT 0, + color char(6) DEFAULT NULL, remarks varchar(150) DEFAULT NULL, PRIMARY KEY (sid) ); @@ -137,7 +139,7 @@ CREATE TABLE equipment ( price decimal(12,2) DEFAULT NULL, weight float(5,2) UNSIGNED DEFAULT NULL, remarks varchar(150) DEFAULT NULL, - flags set('ordered','deleted') DEFAULT NULL, + flags set('ordered','removed','deleted') DEFAULT NULL, PRIMARY KEY(eid) ); @@ -157,16 +159,19 @@ CREATE TABLE inventory ( PRIMARY KEY (invid), INDEX ix_invname (invname) ); - +/* + TODO: unit -> unit1, unit2, unit3 + */ CREATE TABLE measurement ( mid smallint(6) NOT NULL AUTO_INCREMENT, + mtype enum('generic','cable','fuse') NOT NULL default 'generic', mname varchar(80) NOT NULL, nval tinyint(1) UNSIGNED NOT NULL DEFAULT 1, val1 int(10) NOT NULL, val2 int(10) NOT NULL, val3 int(10) NOT NULL, unit tinyint(3) NOT NULL DEFAULT 1, - accuracy enum('unknown', 'precise', 'normal', 'rough', 'estimated') NOT NULL DEFAULT 'unknown', + accuracy enum('unknown','precise','normal','rough','estimated') NOT NULL DEFAULT 'unknown', mdate date DEFAULT NULL, note varchar(80) DEFAULT NULL, eid smallint(6) DEFAULT NULL, @@ -178,7 +183,10 @@ CREATE TABLE provisions ( provname varchar(40) NOT NULL, provcat tinyint(3) DEFAULT NULL, sid smallint(6) DEFAULT NULL, + boxid smallint(6) NOT NULL DEFAULT 1, number smallint(6) UNSIGNED NOT NULL DEFAULT 1, + weight float(5,2) UNSIGNED DEFAULT NULL, + weight_net float(5,2) UNSIGNED DEFAULT NULL, unit tinyint(3) DEFAULT NULL, storedate date DEFAULT CURRENT_DATE, shelflife date DEFAULT NULL, @@ -187,7 +195,7 @@ CREATE TABLE provisions ( CREATE TABLE document ( docid smallint(6) NOT NULL AUTO_INCREMENT, - doctype enum('generic', 'manual', 'invoice', 'drawing', 'picture') NOT NULL DEFAULT 'generic', + doctype enum('generic','manual','invoice','drawing','picture') NOT NULL DEFAULT 'generic', mimetype varchar(80) NOT NULL DEFAULT 'application/octet-stream', filename varchar(200) NOT NULL, extension char(3) NOT NULL, @@ -197,13 +205,14 @@ CREATE TABLE document ( title varchar(40) DEFAULT NULL, pages smallint(6) unsigned NOT NULL DEFAULT 1, remarks varchar(150) DEFAULT NULL, + roleaccess enum('captain','helmsman','sailor','unauth') NOT NULL DEFAULT 'captain', PRIMARY KEY (docid), UNIQUE INDEX ix_hash (hash) ) ENGINE=InnoDB; CREATE TABLE docref ( drid int(10) NOT NULL AUTO_INCREMENT, - reftype enum('vessel', 'box', 'equipment', 'project', 'task', 'user', 'company') NOT NULL DEFAULT 'vessel', + reftype enum('vessel','box','equipment','project','task','user','company') NOT NULL DEFAULT 'vessel', docid smallint(6) NOT NULL, refid smallint(6) NOT NULL, PRIMARY KEY (drid), @@ -270,7 +279,8 @@ CREATE TABLE task ( projid smallint(6) DEFAULT NULL, taskname varchar(60) NOT NULL, priority enum('high','medium','low') DEFAULT NULL, - taskstate enum('pending','waiting','deleted','completed') NOT NULL DEFAULT 'pending', + taskstate enum('pending','active','waiting','deleted','completed') NOT NULL DEFAULT 'pending', + state_ts timestamp DEFAULT NULL, plandate date DEFAULT NULL, duedate date DEFAULT NULL, started datetime DEFAULT NULL, @@ -280,9 +290,10 @@ CREATE TABLE task ( PRIMARY KEY (taskid) ); +// Notes can be assigned to tasks,maintenances and equipment CREATE TABLE note ( noteid int(10) NOT NULL AUTO_INCREMENT, - notetype enum('task','maint') NOT NULL DEFAULT 'task', + notetype enum('task','maint','equip') NOT NULL DEFAULT 'task', refid smallint(6) NOT NULL, annotation text NOT NULL, PRIMARY KEY (noteid) @@ -291,6 +302,7 @@ CREATE TABLE note ( CREATE TABLE checklist ( clid smallint(6) NOT NULL AUTO_INCREMENT, title varchar(30) NOT NULL, + parent smallint(6) DEFAULT NULL, clstate enum('new','open','closed') NOT NULL DEFAULT 'new', PRIMARY KEY (clid) ); @@ -299,6 +311,7 @@ CREATE TABLE checkitem ( checkid int(10) NOT NULL AUTO_INCREMENT, checkname varchar(60) NOT NULL, groupid tinyint(3) DEFAULT NULL, + checkresult enum('unchecked','checked','unused') NOT NULL DEFAULT 'unused', PRIMARY KEY (checkid) ); @@ -308,3 +321,9 @@ CREATE TABLE checkref ( sort smallint(6) DEFAULT NULL, PRIMARY KEY (clid, checkid) ); + +CREATE TABLE checkgroup ( + groupid int(10) NOT NULL, + title varchar(30) NOT NULL, + PRIMARY KEY (groupid) +); diff --git a/db/minimal.sql b/db/minimal.sql index 9d29b7f..8973133 100644 --- a/db/minimal.sql +++ b/db/minimal.sql @@ -12,13 +12,19 @@ INSERT INTO user (userid, login, pass, displayname, role) VALUES (1, 'captain', '$2y$10$naVMnC4S6bZ3IakxLJPJK.iSazlkYxVLeiRt9CB/j0jSExQZU1SCK', 'Captain', 'captain'); INSERT INTO settings (userid, sno, valint) VALUES -(0, 0, 1), -- Databankschema-Version -(0, 1, 0), -- Keine Bootszuordnung für SYSTEM -(1, 1, 0); -- Keine Bootszuordnung für Benutzer "captain" +(0, 0, 1), -- Database schema version +(0, 1, 0), -- No vessel assignment to SYSTEM +(1, 1, 0), -- No vessel assignment to user "captain" +(0, 20, 1280), -- Image width limit +(0, 21, 1024); -- Image height limit /* setting descriptions */ INSERT INTO settings (userid, sno, valstr) VALUES (-1, 1, 'vessel id'), +(-1, 2, 'date format'), +(-1, 10, 'rows in table'), +(-1, 20, 'maximum image width'), +(-1, 21, 'maximum image height'), (-1, 100, 'equipment sorting order'), (-1, 101, 'inventory sorting order'), (-1, 102, 'provision sorting order'), diff --git a/locale/de.po b/locale/de.po index 2b00994..c5fb25f 100644 --- a/locale/de.po +++ b/locale/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: YMS 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-15 09:05+0200\n" +"POT-Creation-Date: 2026-05-07 11:50+0200\n" "PO-Revision-Date: 2025-05-15 09:05+0200\n" "Last-Translator: Thomas Hooge \n" "Language-Team: de \n" @@ -16,11 +16,11 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ymsgui.py:98 +#: ymsgui.py:150 msgid "Configuration file not found" msgstr "Konfigurationsdatei nicht gefunden" -#: ymsgui.py:110 +#: ymsgui.py:172 msgid "Database connection cannot be established" msgstr "Datenbankverbindung kann nicht hergestellt werden" @@ -28,46 +28,68 @@ msgstr "Datenbankverbindung kann nicht hergestellt werden" msgid "YMS" msgstr "" -#: yms/ui/main.ui:27 +#: yms/ui/main.ui:28 msgid "empty" msgstr "leer" -#: yms/ui/main.ui:55 +#: yms/ui/main.ui:56 msgid "Name" msgstr "" -#: yms/ui/main.ui:76 +#: yms/ui/main.ui:77 msgid "Model" msgstr "Modell" -#: yms/ui/main.ui:109 +#: yms/ui/main.ui:119 msgid "Vessel" msgstr "Boot" -#: yms/ui/main.ui:138 +#: yms/ui/main.ui:148 msgid "Lists" msgstr "Listen" -#: yms/ui/main.ui:173 +#: yms/ui/main.ui:186 msgid "Ok" msgstr "" -#: yms/ui/main.ui:194 +#: yms/ui/main.ui:207 msgid "User" msgstr "Benutzer" -#: yms/ui/main.ui:207 +#: yms/ui/main.ui:220 msgid "Base data" msgstr "Basisdaten" -#: yms/ui/main.ui:217 yms/ui/main.ui:238 -msgid "label" +#: yms/ui/main.ui:230 +msgid "" +"Equipment\n" +"Here be dragons" msgstr "" -#: yms/ui/main.ui:227 +#: yms/ui/main.ui:241 msgid "Equipment" msgstr "Ausrüstung" -#: yms/ui/main.ui:248 +#: yms/ui/main.ui:252 +msgid "label" +msgstr "" + +#: yms/ui/main.ui:262 msgid "Inventory" msgstr "Inventar" + +#: yms/ui/main.ui:292 +msgid "Provisions" +msgstr "Verpflegung" + +#: yms/ui/main.ui:322 +msgid "Maintenance" +msgstr "Wartung" + +#: yms/ui/main.ui:352 +msgid "Projects" +msgstr "Projekte" + +#: yms/ui/main.ui:382 +msgid "Documents" +msgstr "Dokumente" diff --git a/webgui/box.php b/webgui/box.php index 64ddc95..bf249ec 100644 --- a/webgui/box.php +++ b/webgui/box.php @@ -1,11 +1,18 @@ fetchAll(); echo '', "\n"; echo "\n"; echo ""; -echo ""; -echo ""; -echo ""; -echo ""; +echo ''; +echo ""; +echo ""; +echo ""; +echo ""; echo '"; echo ""; echo "\n"; +$i = 0; foreach ($res as $row) { + $i++; // record number echo "\n"; + echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; - form_action_buttons($g_scriptname, $row['boxid']); + // Edit current record button + echo "\n"; echo "\n"; } // Table summary @@ -110,7 +126,7 @@ elseif ($action == ACT_ADD): echo '

', _('Add Box'), "

\n"; ?> - +
@@ -143,7 +159,7 @@ foreach ($opt_storage as $k => $v) { elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== -$sql = "SELECT boxtype, label, content, color, weight, box.remarks, box.sid, sname " +$sql = "SELECT boxtype, label, content, box.color, weight, box.remarks, box.sid, sname " . "FROM box LEFT JOIN storage USING (sid) " . "WHERE boxid=?"; $sth = $pdo->prepare($sql); diff --git a/webgui/checklist.php b/webgui/checklist.php index a91e8ba..746d94d 100644 --- a/webgui/checklist.php +++ b/webgui/checklist.php @@ -127,6 +127,13 @@ $checklist = $sth->fetch(PDO::FETCH_OBJ);
" . _('Label') . "" . _('Type') . "" . _('Color') . "" . _('Content') . "#", _('Label'), "", _('Type'), "", _('Color'), "", _('Content'), "', _('Weight'), "
', $i; + echo '', "\n"; + echo "', $row['label'], "', ($opt_boxtype[$row['boxtype']] ?? ''), "', format_color(strtoupper($row['color'])), "', $row['content'], "', format_float($row['weight'], 2), ""; + echo '', "\n"; + echo "
Add($e->getMessage()); $g_error->Add($sql); $g_error->Add(print_r($p, true)); + $g_error->PrintOut(); } $numrows = $sth->fetchColumn(); -$lastpage = ceil($numrows/$g_rows_pp); $page = gpc_get_int($_REQUEST, 'p', 1); +$rows_pp = gpc_get_int($_REQUEST, 'n', $g_rows_pp); +$lastpage = ceil($numrows/$rows_pp); $sql = "SELECT compid, compname, comptype, remarks " . "FROM company"; @@ -156,7 +158,7 @@ $opt_special = array( ?>
-
Filter
+
Filter
@@ -323,7 +347,7 @@ echo $pagination; echo '', "\n"; echo "\n"; echo ""; -echo ""; +echo ''; echo ""; echo ""; echo ""; @@ -331,23 +355,28 @@ echo ""; echo ""; echo "\n"; echo "\n"; + +$i = ($page - 1) * $rows_pp; +$i0 = $i + 1; foreach ($res as $row) { + $i++; // record number echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; - // Action buttons + // Edit current record button echo "\n"; echo "\n"; } // Table summary echo "\n"; -echo '', "\n"; +echo '', "\n"; echo "\n"; echo "
", _('ID'), "#", _('Type'), "", _('Filename'), "", _('Title'), "", _('Links'), " 
", $row['docid'], "", $i; + echo '', "\n"; + echo "", $opt_doctype[$row['doctype']], "", $row['filename'], "", $row['title'], "", $row['refcount'], ""; - echo '', "\n"; echo '', "\n"; echo "
', sprintf(_('%d records'), count($res)), '
', sprintf(_('Records %d to %d of %d'), $i0, $i, $numrows), '
\n"; @@ -402,7 +431,7 @@ elseif ($action == ACT_VIEW): /* mutool: preview of page thumbs */ $sql = "SELECT docid, doctype, mimetype, filename, extension, hash," - . " docsize, doctime, title, pages, remarks " + . " docsize, doctime, title, pages, remarks, roleaccess " . "FROM document " . "WHERE docid=?"; $sth = $pdo->prepare($sql); @@ -428,13 +457,14 @@ if ($document->doctype == 'picture') { echo '
'; // gallery ?> +
diff --git a/webgui/maintenance.php b/webgui/maintenance.php index c6b4696..fa4e3bd 100644 --- a/webgui/maintenance.php +++ b/webgui/maintenance.php @@ -84,10 +84,11 @@ $opt_special = array( ?>
-
Filter
-
- - $v) { echo ''; } ?> - - - + +
+
+ + +
+
+ @@ -107,32 +113,66 @@ foreach ($opt_special + $opt_equipment as $k => $v) {
'm.maintid', + 2 => 'm.maintid DESC' +); + +$w = array('m.vid=:vid'); +$p = array(':vid' => $user->vid); + +if ($flt->equip == -1 or $flt->equip == 0) { + $w[] = 'm.eid IS NULL'; +} elseif ($flt->equip > 0) { + $w[] = 'm.eid=:eid'; + $p[':eid'] = $flt->equip; +} +if (strlen($flt->txt) > 1) { + $w[] = '(m.activities LIKE :txt OR m.remarks LIKE :txt)'; + $p[':txt'] = '%'.$flt->txt.'%'; +} + +$where = join(' AND ', $w); +$order = ' ORDER BY m.maintid'; + + $sql = "SELECT m.maintid, m.activities, m.remarks, e.ename " - . "FROM maintenance AS m LEFT OUTER JOIN equipment AS e USING (eid)" - . "WHERE m.vid=? " - . "ORDER BY m.maintid"; + . "FROM maintenance AS m LEFT OUTER JOIN equipment AS e USING (eid)"; +$sql .= ' WHERE ' . $where; +$sql .= $order; + +// if pagination: +// $sql .= ' LIMIT ' . ($page - 1) * $rows_pp . ',' . $rows_pp; + $sth = $pdo->prepare($sql); -$sth->execute([$user->vid]); +$sth->execute($p); $res = $sth->fetchAll(); + echo '', "\n"; echo "\n"; echo ""; +echo ''; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; + +$i = ($page - 1) * $rows_pp; +$i0 = $i + 1; foreach ($res as $row) { + $i++; // record number echo "\n"; + echo '\n"; echo "\n"; echo "\n"; echo "\n"; - // Action buttons -/* echo "\n"; */ - form_action_buttons($g_scriptname, $row['maintid']); + echo "\n"; echo "\n"; } // Table summary diff --git a/webgui/manual.php b/webgui/manual.php index a2fddb0..01039c0 100644 --- a/webgui/manual.php +++ b/webgui/manual.php @@ -13,6 +13,9 @@ require 'header.php'; ?>

Yacht Management System

+ +

Hinweis: Es handelt sich hier um einen Prototyp!

+

Integriertes Handbuch

Es können mehrere Yachten mit dem Programm verwaltet werden. @@ -47,6 +50,10 @@ Wasserlinie.

Ausrüstung ist zumeist fest mit der Yacht verbunden, jeder Ausrüstungsgegenstand existiert nur ein mal und kann eine Seriennummer besitzen.

Ausrüstung kann gewartet werden.

+

Ein Ausrüstungsgegenstand kann als bestellt, entfernt oder gelöscht gekennzeichnet +werden. Entfernt bedeutet der Gegenstand ist noch vorhanden aber nicht auf dem +Boot installiert. Gelöschte Gegenstände werden bei der nächsten Reorganisation +komplett aus dem System entfernt.

Inventar

Unter Inventar sind bewegliche Dinge zusammengefaßt. @@ -54,6 +61,8 @@ Ein Inventargegenstand kann auch mehrfach vorkommen. Beispiel: Winschkurbel, Anzahl: 3

Inventar kann in einem Stauraum abgelegt werden oder aber in einer Kiste.

+

Inventar welches einem Ausrüstungsgegenstand zugeordnet ist, wird +als Ersatzteil geführt.

Proviant

Proviant ist verderblich. @@ -61,7 +70,9 @@ Es wird das Einlagerungsdatum erfaßt und das Haltbarkeitsdatum

Proviant kann einem Stauraum und somit einem Boot zugeordnet sein oder aber frei. Freier Proviant kann später zugeordnet -werden. Er ist erkennbar am Einkaufswagen-Symbol .

+werden. Er ist erkennbar am Einkaufswagen-Symbol .

+ +

TODO/Noch nichtimplementiert: Proviant kann auch in eine Kiste gelegt werden

Wartung

Es können einmalige und wiederkehrende Wartungen erfaßt werden

@@ -74,8 +85,11 @@ z.B. neu, laufend oder erledigt.

Aufgaben

Aufgaben sind normalerweise den aktuell ausgewählten Boot zugeordnet, -können aber auch bootsunabhängig angelegt werden. Eine projektzuordnung -ist ebenfalls vorgesehen

+können aber auch bootsunabhängig angelegt werden. Eine Projektzuordnung +ist ebenfalls vorgesehen.

+

Die Aufgaben sind nicht als Menüpunkt auf oberster Ebene vorhanden. +Die Aufgabenübersicht kann über Zusatzmodule auf der Startseine erreicht +werden.

Firmen

Es können verschiedene Arten von Firmen hinterlegt werden, wie @@ -108,6 +122,10 @@ ist es möglich Flächen (L x B) oder Volumen (L x B x H) zusammenhängend zu erfassen.

+

Notizen

+

Notizen können für verschiedene Aufgaben und Wartungen hinterlegt werden. +Es handelt sich um die Eingabemöglichkeit in ein einzelnes Textfeld.

+

Benutzer

Benutzer können nicht über die Web-GUI eingerichtet werden.

Es gibt die Berechtigungsebenen Kapitän (captain), diff --git a/webgui/measurement.php b/webgui/measurement.php index 09d9f22..8c9fc8e 100644 --- a/webgui/measurement.php +++ b/webgui/measurement.php @@ -11,6 +11,7 @@ $pagetitle = _('Measurements'); $id = gpc_get_int($_REQUEST, 'id', 0); +$opt_mtype = db_load_enum('measurement', 'mtype', true, false); $opt_unit = db_get_options(8); $opt_accuracy = array( 'unknown' => _('Unknown'), @@ -147,9 +148,11 @@ $opt_special = array( ?>

-
Filter
+
Filter
- + diff --git a/webgui/projects.php b/webgui/projects.php index e319cec..1d021b3 100644 --- a/webgui/projects.php +++ b/webgui/projects.php @@ -19,6 +19,18 @@ foreach ($sth->fetchAll() as $row) { } $opt_state = db_load_enum('project', 'projstate', true, true); +/* Nur für choices benötigt +$local_script = " + document.addEventListener('DOMContentLoaded', function () { + const element = document.getElementById('flt_state[]'); + const choices = new Choices(element, { + removeItemButton: true, + duplicateItemsAllowed: false, + searchEnabled: false + }); + }); +"; */ + // ========== ACTIONS START =================================================== switch ($submit = form_get_action()) { @@ -33,7 +45,7 @@ switch ($submit = form_get_action()) { case 'filter': $flt = array(); $flt['name'] = gpc_get_string($_POST, 'flt_name'); - $flt['state'] = gpc_get_string($_POST, 'flt_state'); + $flt['state'] = $_POST['flt_state']; // Array! gpc_get_string($_POST, 'flt_state'); $flt['remarks'] = gpc_get_string($_POST, 'flt_remarks'); db_save_filter($flt, 205); $action = ACT_DEFAULT; @@ -95,45 +107,79 @@ page_caption_search($pagetitle); // load filter from db $flt = db_get_filter($user->id, 205); -$w = array(); -$p = array(); +// name, status, text + +$w = array('vid=:vid'); +$p = array(':vid' => $user->vid); + +if (strlen($flt->txt) > 1) { + $w[] = '(projname LIKE :txt OR remarks LIKE :txt)'; + $p[':txt'] = '%'.$flt->txt.'%'; +} $where = join(' AND ', $w); -$order = ' ORDER BY comptype, compname'; +$order = ' ORDER BY projname'; // grand total of records for current vessel -$grandtotal = $pdo->query("SELECT COUNT(*) FROM project")->fetchColumn(); +$sth = $pdo->prepare("SELECT COUNT(*) FROM project WHERE " . $where); +try { + $sth->execute($p); +} catch(PDOException $e) { + $g_error->Add($e->getMessage()); + $g_error->Add($sql); + $g_error->Add(print_r($p, true)); + $g_error->PrintOut(); +} +$numrows = $sth->fetchColumn(); +$page = gpc_get_int($_REQUEST, 'p', 1); +$rows_pp = gpc_get_int($_REQUEST, 'n', $g_rows_pp); +$lastpage = ceil($numrows/$rows_pp); + +// $grandtotal = $pdo->query("SELECT COUNT(*) FROM project WHERE " . $where)->fetchColumn(); + +$sql = "SELECT projid, projname, startdate, duration, projstate, remarks " + . "FROM project"; +$sql .= " WHERE " . $where; +$sql .= $order; + +// if pagination: +$sql .= ' LIMIT ' . ($page - 1) * $g_rows_pp . ',' . $g_rows_pp; + +$sth = $pdo->prepare($sql); +$sth->execute($p); +$res = $sth->fetchAll(); // Filter ?> - +
-
Filter
-
- - +
Filter
+
+
+ + +
state); +filter_create_select('flt_state[]', _('State'), $g_opt_all + $opt_state, $flt->state, FALSE); ?> - - - - +
+ + +
+
+
prepare($sql); -$sth->execute([$user->vid]); -$res = $sth->fetchAll(); + echo '
#", _('Activities'), "", _('Equipment'), "", _('Remarks'), "
', $i; + echo '', "\n"; + echo "". $row['activities'] ."". $row['ename'] ."". $row['remarks'] .""; - echo '', "\n"; + echo ""; + // Edit current record button echo '', "\n"; - echo "
'. "\n"; echo "\n"; echo ""; +echo ''; echo ""; echo ""; echo ""; @@ -142,15 +188,24 @@ echo ""; echo ""; echo "\n"; echo "\n"; +$i = ($page - 1) * $rows_pp; +$i0 = $i + 1; foreach ($res as $row) { + $i++; // record number echo "\n"; + echo '\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; - // Action buttons - form_action_buttons($g_scriptname, $row['projid']); + // Edit current record button + echo "\n"; + echo "\n"; } echo "\n"; @@ -172,15 +227,28 @@ $res = $sth->fetchAll(); echo '
#" . _('Name') . "" . _('Start date') . "" . _('Duration') . "" . _('Remarks') . " 
', $i; + echo '', "\n"; + echo "". $row['projname'] ."". $row['startdate'] ."". $row['duration'] ."". $row['projstate'] ."". $row['remarks'] .""; + echo '', "\n"; + echo "
', "\n"; echo "\n"; echo ""; +echo ''; echo ""; echo ""; echo "\n"; echo "\n"; + +// TODO own pagination +// $i = ($page - 1) * $rows_pp; +$i = 0; +$i0 = $i + 1; foreach ($res as $row) { + $i++; // record number echo "\n"; + echo '\n"; echo "\n"; echo "\n"; - form_action_buttons('task.php', $row['taskid']); + // Edit current record button + echo "\n"; echo "\n"; } // Table summary @@ -230,7 +298,7 @@ echo '\n"; echo '\n"; echo '\n"; -echo '\n"; +echo '\n"; echo "
#" . _('Name') . "" . _('State') . "
', $i; + echo '', "\n"; + echo "". $row['taskname'] ."". $row['taskstate'] .""; + echo '', "\n"; + echo "
', _('Responsible'),"", $opt_user[$project->r echo '
', _('Start date'),"", $project->startdate, "
', _('Duration'),"", $project->duration, "
', _('State'),"", $project->projstate, "
', _('Remarks'),"", $project->remarks, "
', _('Remarks'),"", nl2br($project->remarks), "
\n"; form_view_buttons($g_scriptname, $id); diff --git a/webgui/provisions.php b/webgui/provisions.php index ddfe33c..42b5f35 100644 --- a/webgui/provisions.php +++ b/webgui/provisions.php @@ -54,10 +54,13 @@ switch ($submit = form_get_action()) { $p[':provname'] = gpc_get_string($_POST, 'provname'); $p[':provcat'] = gpc_get_int($_POST, 'provcat'); $p[':number'] = gpc_get_int($_POST, 'number'); + $p[':weight'] = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value + $p[':weight_net'] = min(gpc_get_float($_POST, 'weight_net'), 999.99); $p[':unit'] = gpc_get_int($_POST, 'unit'); $p[':storedate'] = gpc_get_string($_POST, 'storedate'); $p[':shelflife'] = gpc_get_string($_POST, 'shelflife'); $p[':sid'] = gpc_get_int($_POST, 'sid'); + if ($p[':sid'] <= 0) $p[':sid'] = NULL; db_exec_update('provisions', $p, 'provid'); $action = ACT_VIEW; break; @@ -88,11 +91,19 @@ require 'header.php'; if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= +page_caption_search($pagetitle); + // load filter from db $flt = db_get_filter($user->id, 202); $w = array('(vid=:vid OR sid IS NULL)'); $p = array(':vid' => $user->vid); +if ($flt->cat == -1) { + $w[] = 'provcat IS NULL'; +} elseif ($flt->cat > 0) { + $w[] = 'provcat=:provcat'; + $p[':provcat'] = $flt->cat; +} if (strlen($flt->txt) > 1) { $w[] = 'provname LIKE :txt'; $p[':txt'] = '%'.$flt->txt.'%'; @@ -101,67 +112,116 @@ $where = join(' AND ', $w); $order = ' ORDER BY provid'; +// get total record count for pagination and limit +$sql = "SELECT COUNT(*) FROM provisions LEFT OUTER JOIN storage USING (sid) WHERE " . $where; +$sth = $pdo->prepare($sql); +try { + $sth->execute($p); +} catch(PDOException $e) { + $g_error->Add($e->getMessage()); + $g_error->Add($sql); + $g_error->Add(print_r($p, true)); + $g_error->PrintOut(); +} +$numrows = $sth->fetchColumn(); +$page = gpc_get_int($_REQUEST, 'p', 1); +$rows_pp = gpc_get_int($_REQUEST, 'n', $g_rows_pp); +$lastpage = ceil($numrows/$rows_pp); + // provisions can be assigned to a store or be free +// d0 is the maximum number of days age +// d1 is the current age in days. If negative then it is over limit +// TODO display over with warning levels: 50% over, 100% over etc. $sql = "SELECT provid, provname, number, unit, storedate, shelflife, sid," - . " DATEDIFF(shelflife, storedate) AS d0, DATEDIFF (CURDATE(), storedate) AS d1 " + . " DATEDIFF(shelflife, storedate) AS d0, DATEDIFF (shelflife, CURDATE()) AS d1 " . "FROM provisions LEFT OUTER JOIN storage USING (sid)"; $sql .= ' WHERE ' . $where; $sql .= $order; + +// if pagination: +$sql .= ' LIMIT ' . ($page - 1) * $rows_pp . ',' . $rows_pp; + $sth = $pdo->prepare($sql); $sth->execute($p); $res = $sth->fetchAll(); -page_caption_search($pagetitle); ?>
-
Filter
-
+
Filter
+
cat); ?> - - - - +
+ + +
+
+
', "\n"; echo "\n"; echo "\n"; +echo '#'; echo '', _('Description'), ""; echo '', _('Number'), ""; echo '', _('Unit'), ""; echo '', _('Stored'), ""; echo '', _('Best before'), ""; -echo ""; -echo "\n"; +echo ""; // Meter +echo "\n"; // Buttons echo "\n"; echo "\n"; + +$i = ($page - 1) * $rows_pp; +$i0 = $i + 1; foreach ($res as $row) { + $i++; // record number echo "\n"; - echo "", ! isset($row['sid']) ? ' ' : '', $row['provname'], "\n"; - echo "". $row['number'] ."\n"; - echo "". $opt_unit[$row['unit']] ."\n"; - echo "". $row['storedate'] ."\n"; - echo "". $row['shelflife'] ."\n"; - echo ""; - echo ''; - // Action buttons - form_action_buttons($g_scriptname, $row['provid']); + echo "", $i; + echo '', "\n"; echo "\n"; + echo "", ! isset($row['sid']) ? ' ' : '', $row['provname'], "\n"; + echo "", $row['number'], "\n"; + echo "", $opt_unit[$row['unit']], "\n"; + echo "", $row['storedate'], "\n"; + echo "", $row['shelflife'], "\n"; + // TODO shelflife in der Vergangenheit + echo ""; + if ($row['d1'] > 0) { + echo ''; + } else { + if ($row['d1'] < 0) { + echo ' ', abs($row['d1']); + } + } + echo "\n"; + // Edit current record button + echo ""; + echo ''; + echo "\n"; + echo "\n"; } // Table summary echo "\n"; -echo '', sprintf(_('%d records'), count($res)), '', "\n"; +echo '', sprintf(_('%d records'), count($res)), '', "\n"; echo "\n"; echo "\n"; +echo $pagination; + form_add_button($g_scriptname); elseif ($action == ACT_ADD): @@ -187,7 +247,7 @@ echo '

', _('Add provisions'), "

\n";
- '- none -'] + $opt_storage); ?> +
@@ -198,7 +258,7 @@ echo '

', _('Add provisions'), "

\n"; elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== -$sql = "SELECT provname, provcat, number, unit, storedate, shelflife, sid " +$sql = "SELECT provname, provcat, number, unit, weight, weight_net, storedate, shelflife, sid " . "FROM provisions " . "WHERE provid=?"; $sth = $pdo->prepare($sql); @@ -209,6 +269,8 @@ echo '

', $prov->provname, "

\n"; echo '', "\n"; echo '\n"; +echo "\n"; +echo "\n"; echo '\n"; echo '\n"; echo '\n"; @@ -221,7 +283,7 @@ form_view_buttons($g_scriptname, $id); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== -$sql = "SELECT provname, provcat, number, unit, storedate, shelflife, sid " +$sql = "SELECT provname, provcat, number, weight, weight_net, unit, storedate, shelflife, sid " . "FROM provisions " . "WHERE provid=?"; $sth = $pdo->prepare($sql); @@ -240,9 +302,17 @@ echo '

', _('Edit provision'), "

\n"; +
+ + +
+
+ + +
unit); -form_create_select('provcat', _('Category'), array_merge($g_opt_none, $opt_category), $prov->provcat); +form_create_select('provcat', _('Category'), $g_opt_none + $opt_category, $prov->provcat); ?>
@@ -253,7 +323,7 @@ form_create_select('provcat', _('Category'), array_merge($g_opt_none, $opt_categ
sid); +form_create_select('sid', _('Storage'), $g_opt_none + $opt_storage, $prov->sid); form_edit_buttons($g_scriptname, $id); echo "\n"; diff --git a/webgui/storage.php b/webgui/storage.php index 1e11f22..9e7fc7f 100644 --- a/webgui/storage.php +++ b/webgui/storage.php @@ -1,7 +1,7 @@ fetchAll(); echo '
', _('Number'),"", $prov->number, "
", _('Weight'), "", format_float($prov->weight, 2, 'kg'), "
", _('Weight net'), "", format_float($prov->weight_net, 2, 'kg'), "
', _('Unit'),"", $opt_unit[$prov->unit], "
', _('Category'),"", $opt_category[$prov->provcat] ?? 'n/a', "
', _('Storedate'),"", $prov->storedate, "
', "\n"; echo "\n"; echo ""; +echo ''; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; +$i = 0; foreach ($res as $row) { + $i++; // record number echo "\n"; + echo '\n"; echo "\n"; - echo "\n"; + if ($row['angle'] != 0) { + $angle = " (" . $row['angle'] . "°)"; + } else { + $angle = ""; + } + echo "\n"; echo "\n"; - form_action_buttons($g_scriptname, $row['sid']); + // Edit current record button + echo "\n"; echo "\n"; } echo "\n"; -echo '', "\n"; +echo '', "\n"; echo "\n"; echo "
#", _('Name'), "", _('Position'), "", _('Remarks'), " 
', $i; + echo '', "\n"; + echo "", $row['sname'], "", join(',', array($row['x'] ?? '?', $row['y'] ?? '?', $row['z'])), "", join(',', array($row['x'] ?? '?', $row['y'] ?? '?', $row['z'])), $angle, "", $row['remarks'], ""; + echo '', "\n"; + echo "
', sprintf(_('%d records'), count($res)), '
', sprintf(_('%d records'), count($res)), '
\n"; @@ -136,17 +150,26 @@ $res = $sth->fetchAll(); echo '', "\n"; echo "\n"; echo ""; +echo ''; echo ""; echo ""; echo ""; echo ""; echo "\n"; +$i = 0; foreach ($res as $row) { + $i++; // record number echo "\n"; + echo '\n"; echo "\n"; echo '\n"; echo "\n"; - form_action_buttons('box.php', $row['boxid']); + // Edit current record button + echo "\n"; echo "\n"; } // Table summary @@ -189,7 +212,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, wx, wy, wz, remarks " +$sql = "SELECT sid, sname, stype, capacity, capaunit, x, y, z, wx, wy, wz, angle, color, remarks " . "FROM storage " . "WHERE sid=?"; $sth = $pdo->prepare($sql); @@ -202,6 +225,8 @@ echo '\n"; echo '\n"; echo '\n"; +echo '\n"; +echo '\n"; echo '\n"; echo "
#" . _('Label') . "" . _('Color') . "" . _('Content') . "
', $i; + echo '', "\n"; + echo "". $row['label'] ."', format_color($row['color']), "". $row['content'] .""; + echo '', "\n"; + echo "
', _('Typ'),"", $stype[$storage->stype] echo '
', _('Capacity'),"", $storage->capacity, ' ', $storage->capaunit, "
', _('Location (x, y, z)'),"(", $storage->x, ', ', $storage->y, ', ', $storage->z, ")
', _('Width (wx, wy, wz)'),"(", $storage->wx, ', ', $storage->wy, ', ', $storage->wz, ")
', _('Angle'),"", $storage->angle, "°
', _('Color'),"", $storage->color, "
', _('Remarks'),"", $storage->remarks, "
\n"; diff --git a/webgui/tag.php b/webgui/tag.php index 2b4beea..210147c 100644 --- a/webgui/tag.php +++ b/webgui/tag.php @@ -88,7 +88,7 @@ echo "

$pagetitle

\n"; ?>
-
Filter
+
Filter
diff --git a/webgui/task.php b/webgui/task.php index 863c66a..7e3d124 100644 --- a/webgui/task.php +++ b/webgui/task.php @@ -35,6 +35,11 @@ switch ($submit = form_get_action()) { $action = ACT_DEFAULT; break; + case 'freset': + db_clear_filter(206); + $action = ACT_DEFAULT; + break; + case 'insert': $p[':vid'] = $user->vid; $p[':projid'] = gpc_get_int($_POST, 'projid'); @@ -42,6 +47,7 @@ switch ($submit = form_get_action()) { $p[':projid'] = NULL; } $p[':taskname'] = gpc_get_string($_POST, 'taskname'); + $p[':responsible'] = $user->id; $id = db_exec_insert('task', $p); $action = ACT_VIEW; break; @@ -62,6 +68,7 @@ switch ($submit = form_get_action()) { $p[':started'] = gpc_get_datetime($_POST, 'started'); $p[':finished'] = gpc_get_datetime($_POST, 'finished'); $p[':taskstate'] = gpc_get_enum($_POST, 'taskstate', array_keys($opt_state)); + $p[':responsible'] = gpc_get_int($_POST, 'responsible'); db_exec_update('task', $p, 'taskid'); $action = ACT_VIEW; break; @@ -137,7 +144,7 @@ $where = join(' AND ', $w); $order = ' ORDER BY t.taskid'; // get total recond count for pagination and limit -$sql = "SELECT COUNT(*) FROM task"; +$sql = "SELECT COUNT(*) FROM task AS t"; if ($where) $sql .= " WHERE $where"; $sth = $pdo->prepare($sql); @@ -147,10 +154,12 @@ try { $g_error->Add($e->getMessage()); $g_error->Add($sql); $g_error->Add(print_r($p, true)); + $g_error->PrintOut(); } $numrows = $sth->fetchColumn(); -$lastpage = ceil($numrows/$g_rows_pp); $page = gpc_get_int($_REQUEST, 'p', 1); +$rows_pp = gpc_get_int($_REQUEST, 'n', $g_rows_pp); +$lastpage = ceil($numrows/$rows_pp); $sql = "SELECT t.taskid, t.vid, t.projid, t.taskname, t.priority, t.taskstate," . " p.projname " @@ -167,13 +176,14 @@ try { $g_error->Add('SQL-Error: '. $e->getMessage()); $g_error->Add($sql); $g_error->Add(print_r($p, true)); + $g_error->Printout(); } $res = $sth->fetchAll(); ?>
-
Filter
+
Filter
prio); @@ -200,16 +210,23 @@ echo ""; echo "\n"; echo "\n"; echo "\n"; +$i = ($page - 1) * $rows_pp; +$i0 = $i + 1; foreach ($res as $row) { + $i++; // record number echo "\n"; // mark generic tasks with braces - echo "", $row['vid'] ? $row['taskid'] : '('.$row['taskid'].')', "\n"; + echo "", $row['vid'] ? $i : "($i)"; + echo ''; + echo "\n"; echo "", $row['taskname'], "\n"; echo "", $row['projname'], "\n"; echo "", ($opt_priority[$row['priority']] ?? ''), "\n"; echo "", ($opt_state[$row['taskstate']]), "\n"; - // Action buttons - form_action_buttons($g_scriptname, $row['taskid']); + // Edit current record button + echo ""; + echo '', "\n"; + echo "\n"; echo "\n"; } // Table summary @@ -247,8 +264,10 @@ elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== $sql = "SELECT t.taskname, t.priority, t.plandate, t.duedate," - . " t.started, t.finished, t.taskstate, p.projname " + . " t.started, t.finished, t.taskstate, t.responsible," + . " u.displayname, p.projname " . "FROM task AS t LEFT JOIN project AS p USING (projid) " + . " LEFT JOIN user AS u ON (t.responsible=u.userid) " . "WHERE taskid=?"; $sth = $pdo->prepare($sql); $sth->execute([$id]); @@ -264,6 +283,7 @@ echo '', _('Due date'),"", $task->duedate, "\n"; echo '', _('Started at'),"", $task->started, "\n"; echo '', _('Finished at'),"", $task->finished, "\n"; echo '', _('Status'),"", $opt_state[$task->taskstate], "\n"; +echo '', _('Responsible'),"", $task->displayname, "\n"; echo "\n"; form_view_buttons($g_scriptname, $id); @@ -297,6 +317,8 @@ echo '

', _('Not yet implemented'), "

"; elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== +$opt_user = db_get_opt_user($user->id); // only used here + $sql = "SELECT taskname, projid, priority, plandate, duedate, started, finished," . " taskstate " . "FROM task " @@ -337,6 +359,7 @@ form_create_select('priority', _('Priority'), $opt_none + $opt_priority, $task->
taskstate); +form_create_select('responsible', _('Responsible'), $opt_user, $user->id); form_edit_buttons($g_scriptname, $id); echo "\n";