diff --git a/db/mariadb.sql b/db/mariadb.sql index a852f01..b0262ed 100644 --- a/db/mariadb.sql +++ b/db/mariadb.sql @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: WTFPL */ -/* MariaDB Scheme +/* MariaDB Scheme Version: 1 */ CREATE TABLE user ( @@ -19,7 +19,7 @@ CREATE TABLE user ( E.g. the currently selected boat. Users logged in via the web are allowed to write to this table. Therefore a separate table and not additional fields in the user data record. - + userid=0: Global program settings sno=0: db_scheme_version sno=1: doc_base_path @@ -95,6 +95,7 @@ CREATE TABLE tag ( tagid smallint(6) NOT NULL AUTO_INCREMENT, tagname varchar(20) NOT NULL, color char(6) DEFAULT NULL, + description varchar(80) DEFAULT NULL, PRIMARY KEY (tagid), UNIQUE INDEX ix_tagname (tagname) ); @@ -102,7 +103,7 @@ CREATE TABLE tag ( CREATE TABLE tagref ( tagid smallint(6) NOT NULL, objid smallint(6) NOT NULL, - objtype enum('equip','inv','prov','doc') NOT NULL, + objtype enum('equip','inv','prov','doc', 'proj', 'task', 'maint') NOT NULL, PRIMARY KEY (tagid, objid, objtype) ); @@ -111,6 +112,7 @@ CREATE TABLE tagref ( CREATE TABLE box ( boxid smallint(6) NOT NULL AUTO_INCREMENT, sid smallint(6) NOT NULL, + boxtype tinyint(3) DEFAULT NULL, parent int(10) DEFAULT NULL, label varchar(20) DEFAULT NULL, color char(6) DEFAULT NULL, @@ -141,7 +143,7 @@ CREATE TABLE equipment ( CREATE TABLE inventory ( invid int(10) NOT NULL AUTO_INCREMENT, invname varchar(80) NOT NULL, - boxtype enum('storage','box') NOT NULL DEFAULT 'storage', + conttype enum('storage','box') NOT NULL DEFAULT 'storage', sid smallint(6) NOT NULL DEFAULT 1, boxid smallint(6) NOT NULL DEFAULT 1, number smallint(6) UNSIGNED NOT NULL DEFAULT 1, @@ -198,7 +200,7 @@ CREATE TABLE document ( CREATE TABLE docref ( drid int(10) NOT NULL AUTO_INCREMENT, - reftype enum('vessel', 'box', 'equipment', 'project', 'task', 'user') 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), @@ -260,12 +262,26 @@ CREATE TABLE project ( CREATE TABLE task ( taskid int(10) NOT NULL AUTO_INCREMENT, + vid smallint(6) DEFAULT NULL, projid smallint(6) DEFAULT NULL, taskname varchar(60) NOT NULL, - taskstate enum('new','finished') NOT NULL DEFAULT 'new', + priority enum('high','medium','low') DEFAULT NULL, + taskstate enum('pending','waiting','deleted','completed') NOT NULL DEFAULT 'pending', + plandate date DEFAULT NULL, + duedate date DEFAULT NULL, + started datetime DEFAULT NULL, + finished datetime DEFAULT NULL, PRIMARY KEY (taskid) ); +CREATE TABLE note ( + noteid int(10) NOT NULL AUTO_INCREMENT, + notetype enum('task','maint') NOT NULL DEFAULT 'task', + refid smallint(6) NOT NULL, + annotation text NOT NULL, + PRIMARY KEY (noteid) +); + CREATE TABLE checklist ( clid smallint(6) NOT NULL AUTO_INCREMENT, title varchar(30) NOT NULL, diff --git a/db/minimal.sql b/db/minimal.sql index 2200f02..922fa14 100644 --- a/db/minimal.sql +++ b/db/minimal.sql @@ -26,7 +26,8 @@ INSERT INTO dropdown (ddid, ddval, ddtext) VALUES (0, 5, 'Proviantkategorien'), (0, 6, 'Provianteinheiten'), (0, 7, 'Sicherungstypen'), -(0, 8 , 'Einheiten'); +(0, 8, 'Einheiten'), +(0, 9, 'Kistentypen'); INSERT INTO dropdown (ddid, ddval, ddtext, flags) VALUES (2, 1, 'Lieferant', 'fixed'), diff --git a/webgui/box.php b/webgui/box.php index b6a436d..b26633d 100644 --- a/webgui/box.php +++ b/webgui/box.php @@ -20,6 +20,8 @@ foreach ($sth->fetchAll() as $row) { $opt_storage[$row['sid']] = $row['sname']; } +$opt_boxtype = db_get_options(9); + // ========== ACTIONS START =================================================== switch ($submit = form_get_action()) { @@ -42,6 +44,8 @@ switch ($submit = form_get_action()) { case 'update': $p[':boxid'] = $id; + $p[':boxtype'] = gpc_get_int($_POST, 'boxtype'); + if ($p[':boxtype'] == -1) $p[':boxtype'] = NULL; $p[':label'] = gpc_get_string($_POST, 'label'); $p[':content'] = gpc_get_string($_POST, 'content'); $p[':color'] = gpc_get_color($_POST, 'color'); @@ -67,7 +71,7 @@ if ($action == ACT_DEFAULT): echo "
| " . _('Label') . " | "; +echo "" . _('Type') . " | "; echo "" . _('Color') . " | "; echo "" . _('Content') . " | "; echo '', _('Weight'), " | "; @@ -84,6 +89,7 @@ echo "||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ', $row['label'], " | \n"; + echo '', ($opt_boxtype[$row['boxtype']] ?? ''), " | \n"; echo '', format_color(strtoupper($row['color'])), " | \n"; echo '', $row['content'], " | \n"; echo '', format_float($row['weight'], 2), " | \n"; @@ -137,7 +143,7 @@ foreach ($opt_storage as $k => $v) { elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== -$sql = "SELECT label, content, color, weight, box.remarks, box.sid, sname " +$sql = "SELECT boxtype, label, content, color, weight, box.remarks, box.sid, sname " . "FROM box LEFT JOIN storage USING (sid) " . "WHERE boxid=?"; $sth = $pdo->prepare($sql); @@ -147,7 +153,8 @@ $box = $sth->fetch(PDO::FETCH_OBJ); echo '
| ', _('Content')," | ", $box->content, " |
|---|---|
| ', _('Box type')," | ", ($opt_boxtype[$box->boxtype] ?? ''), " |
| ', _('Content')," | ", $box->content, " |
| ', _('Color'), ' | ', format_color($box->color), " |
| ', _('Weight'), ' | ', format_float($box->weight, 2, 'kg'), " |
| ', _('Storage')," | ", $box->sname;
@@ -160,7 +167,7 @@ form_view_buttons($g_scriptname, $id);
// Inventory in box
// WIP
-$sql = "SELECT invid, invname, weight FROM inventory WHERE boxtype='box' AND boxid=?";
+$sql = "SELECT invid, invname, weight FROM inventory WHERE conttype='box' AND boxid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$res = $sth->fetchAll();
@@ -194,13 +201,15 @@ if ($res) {
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
-$sql = "SELECT label, content, color, weight, remarks "
+$sql = "SELECT boxtype, label, content, color, weight, remarks "
. "FROM box "
. "WHERE boxid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$box = $sth->fetch(PDO::FETCH_OBJ);
+$opt_none = [ -1 => _('― none ―')];
+
echo '', _('Edit Box'), "\n"; ?> |