diff --git a/.gitignore b/.gitignore index c9831d1..c0cac9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *~ __pycache__/ +compare_* +*.txt diff --git a/INSTALL b/INSTALL index 896b72a..3dd0fa0 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -YMS Installation +Yacht Management Software (YMS) Installation 1. Install requirements @@ -6,12 +6,12 @@ YMS Installation - MariaDB - Python 3 - python3-bcrypt + - python3-mysqldb - optional - gettext - mupdf-tools for extended pdf file management 1.2 Native GUI -- python3-mysqldb - Python GTK3 - python3-gi - gir1.2-gtk-3.0 @@ -29,7 +29,12 @@ the privileges for accessing and modifying it. CREATE DATABASE yms; -Create database-user for application with minimum necessary rights. +Create system user for native gui. + + CREATE USER 'ymssys'@'localhost' IDENTIFIED BY '********'; + GRANT SELECT, INSERT, UPDATE, DELETE ON yms.* TO 'ymssys'@'localhost'; + +Create database-user for web application with minimum necessary rights. CREATE USER 'ymsweb'@'localhost' IDENTIFIED BY '********'; GRANT SELECT, INSERT, UPDATE, DELETE ON yms.* TO 'ymsweb'@'localhost'; @@ -72,7 +77,7 @@ file. 5.2. Create and edit webgui config file -Rename sample configfile config.php-sample: +Rename sample configfile config.inc-sample: mv config.inc-sample config.inc diff --git a/README b/README index a5e6393..2591208 100644 --- a/README +++ b/README @@ -6,3 +6,8 @@ Use at your own risk! If inserting a new user you have also to insert a setting value to assign boat 0. + +To set your own passwords via console there is a helper script + ymspass.py + +Use it to get an SQL-statement for changing passwords. diff --git a/db/mariadb.sql b/db/mariadb.sql index e2c1ed0..aac3e8d 100644 --- a/db/mariadb.sql +++ b/db/mariadb.sql @@ -3,6 +3,11 @@ /* MariaDB Scheme Version: 1 */ +/* User + userid is signed because nevative values are required for settings + The user table must not be writeable by the webgui user! + */ + CREATE TABLE user ( userid smallint(6) NOT NULL AUTO_INCREMENT, login varchar(20) NOT NULL, @@ -13,7 +18,7 @@ CREATE TABLE user ( language char(2) NOT NULL DEFAULT 'en', PRIMARY KEY (userid), UNIQUE INDEX ix_login (login) -); +) ENGINE=InnoDB; /* Settings E.g. the currently selected boat. Users logged in via the web are allowed @@ -36,11 +41,12 @@ CREATE TABLE settings ( valstr varchar(200) DEFAULT NULL, valint int(10) DEFAULT NULL, PRIMARY KEY (userid, sno) -); +) ENGINE=InnoDB; /* ddid=0 is list of lists, not editable flags: fixed=not deletable, value not changeable - locked=not editable */ + locked=not editable + */ CREATE TABLE dropdown ( ddid tinyint(3) UNSIGNED NOT NULL, ddval tinyint(3) NOT NULL, @@ -50,13 +56,14 @@ CREATE TABLE dropdown ( color char(6) DEFAULT NULL, flags enum('locked','fixed') DEFAULT NULL, PRIMARY KEY (ddid, ddval) -); +) ENGINE=InnoDB; CREATE TABLE vessel ( - vid smallint(10) NOT NULL AUTO_INCREMENT, + vid smallint(6) NOT NULL AUTO_INCREMENT, vtype enum('mono','cat','tri') NOT NULL DEFAULT 'mono', vesselname varchar(40) NOT NULL, model varchar(20) DEFAULT NULL, + shipyard smallint(6) DEFAULT NULL, loa float(4,2) UNSIGNED DEFAULT NULL, lwl float(4,2) UNSIGNED DEFAULT NULL, beam float(4,2) UNSIGNED DEFAULT NULL, @@ -69,10 +76,10 @@ CREATE TABLE vessel ( shapefile varchar(40) DEFAULT NULL, remarks varchar(150) DEFAULT NULL, PRIMARY KEY (vid) -); +) ENGINE=InnoDB; CREATE TABLE storage ( - sid smallint(6) NOT NULL AUTO_INCREMENT, + sid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT, vid smallint(6) NOT NULL DEFAULT 1, sname varchar(40) NOT NULL, stype tinyint(3) NOT NULL DEFAULT 0, @@ -88,34 +95,31 @@ CREATE TABLE storage ( color char(6) DEFAULT NULL, remarks varchar(150) DEFAULT NULL, PRIMARY KEY (sid) -); - -/* TODO define cabins? CREATE TABLE cabin ... */ - +) ENGINE=InnoDB; CREATE TABLE tag ( - tagid smallint(6) NOT NULL AUTO_INCREMENT, + tagid smallint(6) UNSIGNED 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) -); +) ENGINE=InnoDB; CREATE TABLE tagref ( - tagid smallint(6) NOT NULL, - objid smallint(6) NOT NULL, + tagid smallint(6) UNSIGNED NOT NULL, + objid int(10) UNSIGNED NOT NULL, objtype enum('equip','inv','prov','doc', 'proj', 'task', 'maint') NOT NULL, PRIMARY KEY (tagid, objid, objtype) -); +) ENGINE=InnoDB; /* TODO Boxes can be nested via parent TODO boxsize: (LxWxH) in cm? */ CREATE TABLE box ( - boxid smallint(6) NOT NULL AUTO_INCREMENT, - sid smallint(6) NOT NULL, + boxid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT, + sid smallint(6) UNSIGNED NOT NULL, boxtype tinyint(3) DEFAULT NULL, - parent int(10) DEFAULT NULL, + parent smallint(6) UNSIGNED DEFAULT NULL, label varchar(20) DEFAULT NULL, color char(6) DEFAULT NULL, content varchar(60) DEFAULT NULL, @@ -123,33 +127,33 @@ CREATE TABLE box ( remarks varchar(150) DEFAULT NULL, PRIMARY KEY (boxid), INDEX ix_label (label) -); +) ENGINE=InnoDB; CREATE TABLE equipment ( - eid smallint(6) NOT NULL AUTO_INCREMENT, + eid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT, vid smallint(6) NOT NULL DEFAULT 1, ename varchar(80) NOT NULL, shortname varchar(20) DEFAULT NULL, model varchar(40), ecat tinyint(3) DEFAULT NULL, - serial varchar(30), + serial varchar(30) DEFAULT NULL, supplier smallint(6) DEFAULT NULL, - manufacturer smallint(6) DEFAULT NULL, // -3: original; -4: own built + manufacturer smallint(6) DEFAULT NULL, -- -1: unknown; -3: own built purchdate date DEFAULT NULL, price decimal(12,2) DEFAULT NULL, weight float(5,2) UNSIGNED DEFAULT NULL, remarks varchar(150) DEFAULT NULL, flags set('ordered','removed','deleted') DEFAULT NULL, PRIMARY KEY(eid) -); +) ENGINE=InnoDB; CREATE TABLE inventory ( - invid int(10) NOT NULL AUTO_INCREMENT, + invid int(10) UNSIGNED NOT NULL AUTO_INCREMENT, invname varchar(80) NOT NULL, conttype enum('storage','box') NOT NULL DEFAULT 'storage', - sid smallint(6) NOT NULL DEFAULT 1, - boxid smallint(6) NOT NULL DEFAULT 1, - eid smallint(6) DEFAULT NULL, + sid smallint(6) UNSIGNED NOT NULL DEFAULT 1, + boxid smallint(6) UNSIGNED NOT NULL DEFAULT 1, + eid smallint(6) UNSIGNED DEFAULT NULL, number smallint(6) UNSIGNED NOT NULL DEFAULT 1, weight float(5,2) UNSIGNED DEFAULT NULL, price decimal(12,2) DEFAULT NULL, @@ -158,30 +162,64 @@ CREATE TABLE inventory ( remarks varchar(150) DEFAULT NULL, PRIMARY KEY (invid), INDEX ix_invname (invname) -); +) ENGINE=InnoDB; + +CREATE TABLE cable ( + cableid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT, + vid smallint(6) NOT NULL DEFAULT 1, + cablename varchar(80) NOT NULL, + cabletype varchar(40) DEFAULT NULL, -- e.g. H07RN-F + length float(5,2) UNSIGNED NOT NULL DEFAULT 0, -- total length in m + conductors TINYINT(3) UNSIGNED NOT NULL DEFAULT 1, + diameter float(5,2) UNSIGNED DEFAULT NULL, -- outer diameter in mm + xsection float(5,2) UNSIGNED DEFAULT NULL, -- cross section in mm² + weight float(5,2) UNSIGNED DEFAULT NULL, -- kg/meter + color char(6) DEFAULT NULL, + supplier smallint(6) DEFAULT NULL, + manufacturer smallint(6) DEFAULT NULL, + cablecond enum('unknown','new','good','normal','bad','repairable','defect') NOT NULL default 'unknown', + remarks varchar(150) DEFAULT NULL, + PRIMARY KEY (cableid), + INDEX ix_cablename (vid, cablename) +) ENGINE=InnoDB; + +CREATE table fuse ( + fuseid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT, + vid smallint(6) NOT NULL DEFAULT 1, + fnumber smallint(6) NOT NULL, + ftype tinyint(3) DEFAULT 0, -- from dropdown id 7 + current float(5,2) UNSIGNED NOT NULL, -- in A + cableid smallint(6) UNSIGNED DEFAULT NULL, + eid smallint(6) UNSIGNED DEFAULT NULL, + location tinyint(3) DEFAULT 0, -- from dropdown id 10 + description varchar(60) DEFAULT NULL, + remarks varchar(150) DEFAULT NULL, + PRIMARY KEY (fuseid), + UNIQUE INDEX ix_fusenumber (vid, fnumber) +) ENGINE=InnoDB; CREATE TABLE measurement ( mid smallint(6) NOT NULL AUTO_INCREMENT, - mtype enum('generic','cable','fuse') NOT NULL default 'generic', mname varchar(80) NOT NULL, + vid smallint(6) NOT NULL DEFAULT 1, nval tinyint(1) UNSIGNED NOT NULL DEFAULT 1, val1 int(10) NOT NULL, - val2 int(10) NOT NULL, - val3 int(10) NOT NULL, + val2 int(10) DEFAULT NULL, + val3 int(10) DEFAULT NULL, unit tinyint(3) NOT NULL DEFAULT 1, 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, + eid smallint(6) UNSIGNED DEFAULT NULL, PRIMARY KEY (mid) -); +) ENGINE=InnoDB; CREATE TABLE provisions ( provid int(10) NOT NULL AUTO_INCREMENT, provname varchar(40) NOT NULL, provcat tinyint(3) DEFAULT NULL, - sid smallint(6) DEFAULT NULL, - boxid smallint(6) NOT NULL DEFAULT 1, + sid smallint(6) UNSIGNED DEFAULT NULL, + boxid smallint(6) UNSIGNED 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, @@ -189,8 +227,13 @@ CREATE TABLE provisions ( storedate date DEFAULT CURRENT_DATE, shelflife date DEFAULT NULL, PRIMARY KEY (provid) -); +) ENGINE=InnoDB; +/* TODO + - distinction between + docdate - e.g. invoicedate + doctime -> uploadtime +*/ CREATE TABLE document ( docid smallint(6) NOT NULL AUTO_INCREMENT, doctype enum('generic','manual','invoice','drawing','picture') NOT NULL DEFAULT 'generic', @@ -200,6 +243,7 @@ CREATE TABLE document ( hash varchar(32) NOT NULL, docsize int(10) unsigned NOT NULL, doctime datetime DEFAULT NULL, + docdate date DEFAULT NULL, -- e.g. invoice date title varchar(40) DEFAULT NULL, pages smallint(6) unsigned NOT NULL DEFAULT 1, remarks varchar(150) DEFAULT NULL, @@ -224,10 +268,10 @@ CREATE TABLE docref ( CREATE TABLE company ( compid smallint(6) NOT NULL AUTO_INCREMENT, compname varchar(60) NOT NULL, - comptype tinyint(3) NOT NULL DEFAULT 1, - comptype2 tinyint(3) DEFAULT NULL, + comptype tinyint(3) UNSIGNED NOT NULL DEFAULT 1, + comptype2 tinyint(3) UNSIGNED DEFAULT NULL, shortname varchar(20) DEFAULT NULL, - street varchar(30), + street varchar(40), zip varchar(10), city varchar(30), country varchar(30), @@ -240,20 +284,19 @@ CREATE TABLE company ( remarks varchar(150) DEFAULT NULL, PRIMARY KEY (compid), UNIQUE INDEX ix_compname (compname, comptype) -); - +) ENGINE=InnoDB; /* TODO optional field: plan date, target date, completion date */ CREATE TABLE maintenance ( maintid int(10) NOT NULL AUTO_INCREMENT, vid smallint(6) NOT NULL DEFAULT 1, - eid smallint(6) DEFAULT NULL, + eid smallint(6) UNSIGNED DEFAULT NULL, series smallint(6) DEFAULT NULL, activities varchar(40) NOT NULL, remarks varchar(150) DEFAULT NULL, maintstate enum('new','planned','ongoing','done') NOT NULL DEFAULT 'new', PRIMARY KEY (maintid) -); +) ENGINE=InnoDB; /* TODO? time recording */ @@ -269,7 +312,7 @@ CREATE TABLE project ( remarks varchar(150) DEFAULT NULL, projstate enum('new','plan','ongoing','paused','finished') NOT NULL DEFAULT 'new', PRIMARY KEY (projid) -); +) ENGINE=InnoDB; CREATE TABLE task ( taskid int(10) NOT NULL AUTO_INCREMENT, @@ -286,16 +329,16 @@ CREATE TABLE task ( responsible smallint(6) NOT NULL, /* TODO executed_by : company or user? or both? */ PRIMARY KEY (taskid) -); +) ENGINE=InnoDB; -// Notes can be assigned to tasks,maintenances and equipment +/* Notes can be assigned to tasks,maintenances and equipment */ CREATE TABLE note ( noteid int(10) NOT NULL AUTO_INCREMENT, notetype enum('task','maint','equip') NOT NULL DEFAULT 'task', refid smallint(6) NOT NULL, annotation text NOT NULL, PRIMARY KEY (noteid) -); +) ENGINE=InnoDB; CREATE TABLE checklist ( clid smallint(6) NOT NULL AUTO_INCREMENT, @@ -303,7 +346,7 @@ CREATE TABLE checklist ( parent smallint(6) DEFAULT NULL, clstate enum('new','open','closed') NOT NULL DEFAULT 'new', PRIMARY KEY (clid) -); +) ENGINE=InnoDB; CREATE TABLE checkitem ( checkid int(10) NOT NULL AUTO_INCREMENT, @@ -311,17 +354,17 @@ CREATE TABLE checkitem ( groupid tinyint(3) DEFAULT NULL, checkresult enum('unchecked','checked','unused') NOT NULL DEFAULT 'unused', PRIMARY KEY (checkid) -); +) ENGINE=InnoDB; CREATE TABLE checkref ( clid smallint(6) NOT NULL, checkid int(10) NOT NULL, sort smallint(6) DEFAULT NULL, PRIMARY KEY (clid, checkid) -); +) ENGINE=InnoDB; CREATE TABLE checkgroup ( groupid int(10) NOT NULL, title varchar(30) NOT NULL, PRIMARY KEY (groupid) -); +) ENGINE=InnoDB; diff --git a/db/minimal.sql b/db/minimal.sql index 8973133..aa03fda 100644 --- a/db/minimal.sql +++ b/db/minimal.sql @@ -36,6 +36,8 @@ INSERT INTO settings (userid, sno, valstr) VALUES (-1, 108, 'company sorting order'), (-1, 109, 'document sorting order'), (-1, 110, 'tag sorting order'), +(-1, 111, 'cable sorting order'), +(-1, 112, 'fuse sorting order'), (-1, 200, 'equipment filter json'), (-1, 201, 'inventory filter json'), (-1, 202, 'provision filter json'), @@ -46,7 +48,9 @@ INSERT INTO settings (userid, sno, valstr) VALUES (-1, 207, 'measurement filter json'), (-1, 208, 'company filter json'), (-1, 209, 'document filter json'), -(-1, 210, 'tag filter json'); +(-1, 210, 'tag filter json'), +(-1, 211, 'cable filter json'), +(-1, 212, 'fuse filter json'); /* Liste der Listen wird immer benötigt */ INSERT INTO dropdown (ddid, ddval, ddtext) VALUES @@ -59,11 +63,14 @@ INSERT INTO dropdown (ddid, ddval, ddtext) VALUES (0, 6, 'Provianteinheiten'), (0, 7, 'Sicherungstypen'), (0, 8, 'Einheiten'), -(0, 9, 'Kistentypen'); +(0, 9, 'Kistentypen'), +(0, 10, 'Sicherungsblöcke'), -- fuse locations +(0, 11, 'Kabeltypen'); INSERT INTO dropdown (ddid, ddval, ddtext, flags) VALUES (2, 1, 'Lieferant', 'fixed'), (2, 2, 'Hersteller', 'fixed'), +(2, 3, 'Werft', 'fixed'), -- to store yacht manufacturer (2, 9, 'Sonstiges', 'fixed'); INSERT INTO dropdown (ddid, ddval, ddtext, flags) VALUES diff --git a/db/minimal_en.sql b/db/minimal_en.sql index cb81fc4..41ee71f 100644 --- a/db/minimal_en.sql +++ b/db/minimal_en.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), -- Database schema version -(0, 1, 0), -- No vessel for SYSTEM -(1, 1, 0); -- No vessel for 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'), @@ -30,6 +36,8 @@ INSERT INTO settings (userid, sno, valstr) VALUES (-1, 108, 'company sorting order'), (-1, 109, 'document sorting order'), (-1, 110, 'tag sorting order'), +(-1, 111, 'cable sorting order'), +(-1, 112, 'fuse sorting order'), (-1, 200, 'equipment filter json'), (-1, 201, 'inventory filter json'), (-1, 202, 'provision filter json'), @@ -40,9 +48,11 @@ INSERT INTO settings (userid, sno, valstr) VALUES (-1, 207, 'measurement filter json'), (-1, 208, 'company filter json'), (-1, 209, 'document filter json'), -(-1, 210, 'tag filter json'); +(-1, 210, 'tag filter json'), +(-1, 211, 'cable filter json'), +(-1, 212, 'fuse filter json'); -/* list of lists needed */ +/* list of lists always needed */ INSERT INTO dropdown (ddid, ddval, ddtext) VALUES (0, 0, 'list of lists'), (0, 1, 'hull type'), @@ -53,12 +63,16 @@ INSERT INTO dropdown (ddid, ddval, ddtext) VALUES (0, 6, 'provision unit'), (0, 7, 'fuse type'), (0, 8 , 'unit'); +(0, 9, 'box types'), +(0.10, 'fuse blocks'), +(0,11, 'cable types'); INSERT INTO dropdown (ddid, ddval, ddtext, flags) VALUES (2, 1, 'Supplier', 'fixed'), (2, 2, 'Manufacturer', 'fixed'), +(2, 3, 'Shipyard', fixed), (2, 9, 'Generic', 'fixed'); INSERT INTO dropdown (ddid, ddval, ddtext, flags) VALUES -(3, 0, 'Generic', 'fixed'), +(3, 0, 'Generic storage', 'fixed'), (3, 1, 'Tank', 'fixed'); diff --git a/inst_apache.sh b/inst_apache.sh index d67791b..c0edf1b 100755 --- a/inst_apache.sh +++ b/inst_apache.sh @@ -6,4 +6,6 @@ mv /var/www/html/config.inc-sample /var/www/html/config.inc chmod 640 /var/www/html/config.inc chgrp www-data /var/www/html/config.inc rm /var/www/html/index.html +rm /var/www/html/README +rm /var/www/html/TODO rm /var/www/html/locale/de_DE.po diff --git a/webgui/cable.php b/webgui/cable.php new file mode 100644 index 0000000..cc4d3a5 --- /dev/null +++ b/webgui/cable.php @@ -0,0 +1,305 @@ +Add(_('Delete prohibited, invalid security token!')); + $action = ACT_VIEW; + break; + } + // TODO + $action = ACT_DEFAULT; + break; + + default: + $g_error->Add(sprintf(_('Unknown function!'), $submit)); + $valid = FALSE; + +} + +// ========== ACTIONS END ===================================================== + +require 'header.php'; + +// ========== PAGE CONTENT ==================================================== + +if ($action == ACT_DEFAULT): +// ========== VARIANT: default behavior ======================================= + +// load filter from db +$flt = db_get_filter($user->id, 211); + +echo "