Some database improvements and associated changes in webgui
This commit is contained in:
+71
-26
@@ -3,9 +3,11 @@
|
|||||||
/* MariaDB Scheme
|
/* MariaDB Scheme
|
||||||
Version: 1 */
|
Version: 1 */
|
||||||
|
|
||||||
/* TODO
|
/* REMARKS
|
||||||
|
- there are by design no created_at, updated_at, updates_by or similar fields
|
||||||
|
|
||||||
|
TODO
|
||||||
- check all values if unsigned can be used or not
|
- check all values if unsigned can be used or not
|
||||||
- implement foreign keys where missing and possible
|
|
||||||
- add referential actions where appropriate
|
- add referential actions where appropriate
|
||||||
- rename provisions to provision(?)
|
- rename provisions to provision(?)
|
||||||
- review defaults
|
- review defaults
|
||||||
@@ -66,6 +68,7 @@ CREATE TABLE dropdown (
|
|||||||
PRIMARY KEY (ddid, ddval)
|
PRIMARY KEY (ddid, ddval)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
/* compid is signed because negative values needed for special purpose */
|
||||||
CREATE TABLE company (
|
CREATE TABLE company (
|
||||||
compid smallint(6) NOT NULL AUTO_INCREMENT,
|
compid smallint(6) NOT NULL AUTO_INCREMENT,
|
||||||
compname varchar(60) NOT NULL,
|
compname varchar(60) NOT NULL,
|
||||||
@@ -110,6 +113,7 @@ CREATE TABLE vessel (
|
|||||||
PRIMARY KEY (vid),
|
PRIMARY KEY (vid),
|
||||||
FOREIGN KEY fk_vessel_shipyard (shipyard)
|
FOREIGN KEY fk_vessel_shipyard (shipyard)
|
||||||
REFERENCES company(compid)
|
REFERENCES company(compid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE storage (
|
CREATE TABLE storage (
|
||||||
@@ -131,13 +135,15 @@ CREATE TABLE storage (
|
|||||||
PRIMARY KEY (sid),
|
PRIMARY KEY (sid),
|
||||||
FOREIGN KEY fk_storage_vessel (vid)
|
FOREIGN KEY fk_storage_vessel (vid)
|
||||||
REFERENCES vessel(vid)
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* intentionally after storage creation */
|
/* intentionally after storage creation */
|
||||||
ALTER TABLE vessel
|
ALTER TABLE vessel
|
||||||
ADD CONSTRAINT fk_vessel_storage
|
ADD CONSTRAINT fk_vessel_storage
|
||||||
FOREIGN KEY (sid_default)
|
FOREIGN KEY (sid_default)
|
||||||
REFERENCES storage(sid);
|
REFERENCES storage(sid)
|
||||||
|
ON DELETE RESTRICT;
|
||||||
|
|
||||||
CREATE TABLE tag (
|
CREATE TABLE tag (
|
||||||
tagid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
|
tagid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
@@ -153,13 +159,14 @@ CREATE TABLE tagref (
|
|||||||
objid int(10) UNSIGNED NOT NULL,
|
objid int(10) UNSIGNED NOT NULL,
|
||||||
objtype enum('equip','inv','prov','doc', 'proj', 'task', 'maint') NOT NULL,
|
objtype enum('equip','inv','prov','doc', 'proj', 'task', 'maint') NOT NULL,
|
||||||
PRIMARY KEY (tagid, objid, objtype),
|
PRIMARY KEY (tagid, objid, objtype),
|
||||||
|
INDEX ix_tagref_obj (objid, objtype),
|
||||||
FOREIGN KEY fk_tagref_tag (tagid)
|
FOREIGN KEY fk_tagref_tag (tagid)
|
||||||
REFERENCES tag(tagid)
|
REFERENCES tag(tagid)
|
||||||
ON DELETE CASCADE
|
ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* TODO Boxes can be nested via parent
|
/* TODO Boxes can be nested via parent,
|
||||||
TODO boxsize: (LxWxH) in cm? */
|
very low priority because perhaps rarely used */
|
||||||
CREATE TABLE box (
|
CREATE TABLE box (
|
||||||
boxid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
|
boxid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
sid smallint(6) UNSIGNED NOT NULL,
|
sid smallint(6) UNSIGNED NOT NULL,
|
||||||
@@ -169,11 +176,18 @@ CREATE TABLE box (
|
|||||||
color char(6) DEFAULT NULL,
|
color char(6) DEFAULT NULL,
|
||||||
content varchar(60) DEFAULT NULL,
|
content varchar(60) DEFAULT NULL,
|
||||||
weight float(5,2) UNSIGNED DEFAULT NULL,
|
weight float(5,2) UNSIGNED DEFAULT NULL,
|
||||||
|
wx smallint(6) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
wy smallint(6) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
wz smallint(6) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
remarks varchar(150) DEFAULT NULL,
|
remarks varchar(150) DEFAULT NULL,
|
||||||
PRIMARY KEY (boxid),
|
PRIMARY KEY (boxid),
|
||||||
INDEX ix_label (label),
|
INDEX ix_label (label),
|
||||||
FOREIGN KEY fk_box_storage (sid)
|
FOREIGN KEY fk_box_storage (sid)
|
||||||
REFERENCES storage(sid)
|
REFERENCES storage(sid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
|
FOREIGN KEY fk_box_parent (parent)
|
||||||
|
REFERENCES box(boxid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE equipment (
|
CREATE TABLE equipment (
|
||||||
@@ -196,6 +210,9 @@ CREATE TABLE equipment (
|
|||||||
REFERENCES vessel(vid)
|
REFERENCES vessel(vid)
|
||||||
ON DELETE RESTRICT,
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_equipment_supplier (supplier)
|
FOREIGN KEY fk_equipment_supplier (supplier)
|
||||||
|
REFERENCES company(compid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
|
FOREIGN KEY fk_equipment_manufacturer (manufacturer)
|
||||||
REFERENCES company(compid)
|
REFERENCES company(compid)
|
||||||
ON DELETE RESTRICT
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
@@ -206,7 +223,7 @@ CREATE TABLE inventory (
|
|||||||
conttype enum('storage','box') NOT NULL DEFAULT 'storage',
|
conttype enum('storage','box') NOT NULL DEFAULT 'storage',
|
||||||
sid smallint(6) UNSIGNED DEFAULT NULL,
|
sid smallint(6) UNSIGNED DEFAULT NULL,
|
||||||
boxid smallint(6) UNSIGNED DEFAULT NULL,
|
boxid smallint(6) UNSIGNED DEFAULT NULL,
|
||||||
eid smallint(6) UNSIGNED DEFAULT NULL,
|
eid smallint(6) UNSIGNED DEFAULT NULL, -- spare part reference to equipment
|
||||||
number smallint(6) UNSIGNED NOT NULL DEFAULT 1,
|
number smallint(6) UNSIGNED NOT NULL DEFAULT 1,
|
||||||
weight float(5,2) UNSIGNED DEFAULT NULL,
|
weight float(5,2) UNSIGNED DEFAULT NULL,
|
||||||
price decimal(12,2) DEFAULT NULL,
|
price decimal(12,2) DEFAULT NULL,
|
||||||
@@ -217,11 +234,14 @@ CREATE TABLE inventory (
|
|||||||
PRIMARY KEY (invid),
|
PRIMARY KEY (invid),
|
||||||
INDEX ix_invname (invname),
|
INDEX ix_invname (invname),
|
||||||
FOREIGN KEY fk_inventory_storage (sid)
|
FOREIGN KEY fk_inventory_storage (sid)
|
||||||
REFERENCES storage(sid),
|
REFERENCES storage(sid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_inventory_box (boxid)
|
FOREIGN KEY fk_inventory_box (boxid)
|
||||||
REFERENCES box(boxid),
|
REFERENCES box(boxid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_inventory_equipment (eid)
|
FOREIGN KEY fk_inventory_equipment (eid)
|
||||||
REFERENCES equipment(eid),
|
REFERENCES equipment(eid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
CHECK (
|
CHECK (
|
||||||
(sid IS NOT NULL AND boxid IS NULL)
|
(sid IS NOT NULL AND boxid IS NULL)
|
||||||
OR
|
OR
|
||||||
@@ -248,11 +268,14 @@ CREATE TABLE cable (
|
|||||||
PRIMARY KEY (cableid),
|
PRIMARY KEY (cableid),
|
||||||
INDEX ix_cablename (vid, cablename),
|
INDEX ix_cablename (vid, cablename),
|
||||||
FOREIGN KEY fk_cable_vessel (vid)
|
FOREIGN KEY fk_cable_vessel (vid)
|
||||||
REFERENCES vessel(vid),
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_cable_supplier (supplier)
|
FOREIGN KEY fk_cable_supplier (supplier)
|
||||||
REFERENCES company(compid),
|
REFERENCES company(compid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_cable_manufacturer (manufacturer)
|
FOREIGN KEY fk_cable_manufacturer (manufacturer)
|
||||||
REFERENCES company(compid)
|
REFERENCES company(compid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE table fuse (
|
CREATE table fuse (
|
||||||
@@ -269,11 +292,14 @@ CREATE table fuse (
|
|||||||
PRIMARY KEY (fuseid),
|
PRIMARY KEY (fuseid),
|
||||||
UNIQUE INDEX ix_fusenumber (vid, fnumber),
|
UNIQUE INDEX ix_fusenumber (vid, fnumber),
|
||||||
FOREIGN KEY fk_fuse_vessel (vid)
|
FOREIGN KEY fk_fuse_vessel (vid)
|
||||||
REFERENCES vessel(vid),
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_fuse_cable (cableid)
|
FOREIGN KEY fk_fuse_cable (cableid)
|
||||||
REFERENCES cable(cableid),
|
REFERENCES cable(cableid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_fuse_equipment (eid)
|
FOREIGN KEY fk_fuse_equipment (eid)
|
||||||
REFERENCES equipment(eid)
|
REFERENCES equipment(eid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
-- change vals to decimal(12,4)?
|
-- change vals to decimal(12,4)?
|
||||||
@@ -292,9 +318,11 @@ CREATE TABLE measurement (
|
|||||||
note varchar(80) DEFAULT NULL,
|
note varchar(80) DEFAULT NULL,
|
||||||
PRIMARY KEY (mid),
|
PRIMARY KEY (mid),
|
||||||
FOREIGN KEY fk_measurement_vessel (vid)
|
FOREIGN KEY fk_measurement_vessel (vid)
|
||||||
REFERENCES vessel(vid),
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_measurement_equipment (eid)
|
FOREIGN KEY fk_measurement_equipment (eid)
|
||||||
REFERENCES equipment(eid)
|
REFERENCES equipment(eid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE provisions (
|
CREATE TABLE provisions (
|
||||||
@@ -315,9 +343,11 @@ CREATE TABLE provisions (
|
|||||||
remarks varchar(150) DEFAULT NULL,
|
remarks varchar(150) DEFAULT NULL,
|
||||||
PRIMARY KEY (provid),
|
PRIMARY KEY (provid),
|
||||||
FOREIGN KEY fk_provisions_storage (sid)
|
FOREIGN KEY fk_provisions_storage (sid)
|
||||||
REFERENCES storage(sid),
|
REFERENCES storage(sid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_provisions_box (boxid)
|
FOREIGN KEY fk_provisions_box (boxid)
|
||||||
REFERENCES box(boxid)
|
REFERENCES box(boxid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
@@ -345,19 +375,19 @@ CREATE TABLE document (
|
|||||||
|
|
||||||
CREATE TABLE docref (
|
CREATE TABLE docref (
|
||||||
drid int(10) NOT NULL AUTO_INCREMENT,
|
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','maint', 'task','user','company') NOT NULL DEFAULT 'vessel',
|
||||||
docid smallint(6) NOT NULL,
|
docid smallint(6) NOT NULL,
|
||||||
refid int(10) NOT NULL,
|
refid int(10) NOT NULL,
|
||||||
PRIMARY KEY (drid),
|
PRIMARY KEY (drid),
|
||||||
UNIQUE INDEX ix_docref (docid, refid, reftype),
|
UNIQUE INDEX ix_docref (docid, refid, reftype),
|
||||||
|
INDEX ix_docref_ref (refid, reftype),
|
||||||
FOREIGN KEY fk_docref_doc (docid)
|
FOREIGN KEY fk_docref_doc (docid)
|
||||||
REFERENCES document (docid)
|
REFERENCES document (docid)
|
||||||
ON DELETE RESTRICT
|
ON DELETE CASCADE
|
||||||
ON UPDATE CASCADE
|
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* TODO optional fields: plan date, target date, completion date
|
/* TODO optional fields: target date?
|
||||||
interval_hours, last_hours
|
responsible?
|
||||||
signalk: operating hours current vs maint every n operating hours in separate
|
signalk: operating hours current vs maint every n operating hours in separate
|
||||||
*/
|
*/
|
||||||
CREATE TABLE maintenance (
|
CREATE TABLE maintenance (
|
||||||
@@ -374,13 +404,14 @@ CREATE TABLE maintenance (
|
|||||||
maintstate enum('new','plan','ongoing','done') NOT NULL DEFAULT 'new',
|
maintstate enum('new','plan','ongoing','done') NOT NULL DEFAULT 'new',
|
||||||
PRIMARY KEY (maintid),
|
PRIMARY KEY (maintid),
|
||||||
FOREIGN KEY fk_maintenance_vessel (vid)
|
FOREIGN KEY fk_maintenance_vessel (vid)
|
||||||
REFERENCES vessel(vid),
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_maintenance_equipment (eid)
|
FOREIGN KEY fk_maintenance_equipment (eid)
|
||||||
REFERENCES equipment(eid)
|
REFERENCES equipment(eid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* TODO? time recording */
|
/* TODO time recording? */
|
||||||
|
|
||||||
CREATE TABLE project (
|
CREATE TABLE project (
|
||||||
projid smallint(6) NOT NULL AUTO_INCREMENT,
|
projid smallint(6) NOT NULL AUTO_INCREMENT,
|
||||||
projname varchar(40) NOT NULL,
|
projname varchar(40) NOT NULL,
|
||||||
@@ -394,9 +425,11 @@ CREATE TABLE project (
|
|||||||
projstate enum('new','plan','ongoing','paused','finished') NOT NULL DEFAULT 'new',
|
projstate enum('new','plan','ongoing','paused','finished') NOT NULL DEFAULT 'new',
|
||||||
PRIMARY KEY (projid),
|
PRIMARY KEY (projid),
|
||||||
FOREIGN KEY fk_project_vessel (vid)
|
FOREIGN KEY fk_project_vessel (vid)
|
||||||
REFERENCES vessel(vid),
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_project_user (responsible)
|
FOREIGN KEY fk_project_user (responsible)
|
||||||
REFERENCES user(userid)
|
REFERENCES user(userid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* TODO executed_by : company or user? or both? */
|
/* TODO executed_by : company or user? or both? */
|
||||||
@@ -413,13 +446,17 @@ CREATE TABLE task (
|
|||||||
started datetime DEFAULT NULL,
|
started datetime DEFAULT NULL,
|
||||||
finished datetime DEFAULT NULL,
|
finished datetime DEFAULT NULL,
|
||||||
responsible smallint(6) NOT NULL,
|
responsible smallint(6) NOT NULL,
|
||||||
|
remarks varchar(150) DEFAULT NULL,
|
||||||
PRIMARY KEY (taskid),
|
PRIMARY KEY (taskid),
|
||||||
FOREIGN KEY fk_task_user (responsible)
|
FOREIGN KEY fk_task_user (responsible)
|
||||||
REFERENCES user(userid),
|
REFERENCES user(userid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_task_vessel (vid)
|
FOREIGN KEY fk_task_vessel (vid)
|
||||||
REFERENCES vessel(vid),
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT,
|
||||||
FOREIGN KEY fk_task_project (projid)
|
FOREIGN KEY fk_task_project (projid)
|
||||||
REFERENCES project(projid)
|
REFERENCES project(projid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* Notes can be assigned to tasks, maintenances and equipment */
|
/* Notes can be assigned to tasks, maintenances and equipment */
|
||||||
@@ -428,7 +465,12 @@ CREATE TABLE note (
|
|||||||
notetype enum('task','maint','equip') NOT NULL DEFAULT 'task',
|
notetype enum('task','maint','equip') NOT NULL DEFAULT 'task',
|
||||||
refid int(10) NOT NULL,
|
refid int(10) NOT NULL,
|
||||||
annotation text NOT NULL,
|
annotation text NOT NULL,
|
||||||
|
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
created_by smallint(6) DEFAULT NULL,
|
||||||
PRIMARY KEY (noteid)
|
PRIMARY KEY (noteid)
|
||||||
|
FOREIGN KEY fk_note_user (created_by)
|
||||||
|
REFERENCES user(userid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE checklist (
|
CREATE TABLE checklist (
|
||||||
@@ -439,6 +481,7 @@ CREATE TABLE checklist (
|
|||||||
PRIMARY KEY (clid),
|
PRIMARY KEY (clid),
|
||||||
FOREIGN KEY fk_checklist_parent (parent)
|
FOREIGN KEY fk_checklist_parent (parent)
|
||||||
REFERENCES checklist(clid)
|
REFERENCES checklist(clid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE checkgroup (
|
CREATE TABLE checkgroup (
|
||||||
@@ -455,6 +498,7 @@ CREATE TABLE checkitem (
|
|||||||
PRIMARY KEY (checkid),
|
PRIMARY KEY (checkid),
|
||||||
FOREIGN KEY fk_checkitem_group (groupid)
|
FOREIGN KEY fk_checkitem_group (groupid)
|
||||||
REFERENCES checkgroup(groupid)
|
REFERENCES checkgroup(groupid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE checkref (
|
CREATE TABLE checkref (
|
||||||
@@ -483,6 +527,7 @@ CREATE TABLE signalk (
|
|||||||
(vid, objtype, objid, datatype),
|
(vid, objtype, objid, datatype),
|
||||||
FOREIGN KEY fk_signalk_vessel (vid)
|
FOREIGN KEY fk_signalk_vessel (vid)
|
||||||
REFERENCES vessel(vid)
|
REFERENCES vessel(vid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
/* Token
|
/* Token
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ SOURCEDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|||||||
if [ "$1" = "uninstall" ]; then
|
if [ "$1" = "uninstall" ]; then
|
||||||
echo "Uninstalling YMS..."
|
echo "Uninstalling YMS..."
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "Error: this script must be run as root."
|
||||||
|
echo "Please use:"
|
||||||
|
echo " sudo $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f "${BINDIR}/yms"
|
rm -f "${BINDIR}/yms"
|
||||||
rm -rf "${LIBDIR}"
|
rm -rf "${LIBDIR}"
|
||||||
rm -rf "${SHAREDIR}"
|
rm -rf "${SHAREDIR}"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ There can be a difference because not all items have a weight entered
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Boxes');
|
$pagetitle = _('Boxes');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Cables');
|
$pagetitle = _('Cables');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Checklists');
|
$pagetitle = _('Checklists');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle=_('Company');
|
$pagetitle=_('Company');
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
require 'lib/fileutils.inc';
|
require 'lib/fileutils.inc';
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Lists');
|
$pagetitle = _('Lists');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Fuses');
|
$pagetitle = _('Fuses');
|
||||||
|
|||||||
+29
-4
@@ -114,14 +114,25 @@ try {
|
|||||||
$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=0");
|
$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=0");
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
if ($e->getCode() == 1146) {
|
if ($e->getCode() == 1146) {
|
||||||
echo '<pre>';
|
echo "<pre>\n";
|
||||||
echo 'Settings table not found! Perhaps database is not initialized';
|
echo "Settings table not found! Perhaps database is not initialized?\n";
|
||||||
echo '</pre>';
|
echo "</pre>\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$g_db_scheme_version = $sth->fetchColumn();
|
$g_db_scheme_version = $sth->fetchColumn();
|
||||||
// TODO Check version
|
$g_db_scheme_required = 1;
|
||||||
|
// Schema version check
|
||||||
|
if ($g_db_scheme_version !== $g_db_scheme_required) {
|
||||||
|
echo "<pre>\n";
|
||||||
|
echo "Database schema is wrong: detected version $g_db_scheme_version, but required version $g_db_scheme_required!\n";
|
||||||
|
echo "</pre>\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// currency symbol is global
|
||||||
|
$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=4");
|
||||||
|
$g_currsym = $sth->fetchColumn();
|
||||||
|
|
||||||
$user = User::GetInstance(); // There can be only one
|
$user = User::GetInstance(); // There can be only one
|
||||||
if ($g_scriptname != 'login.php') {
|
if ($g_scriptname != 'login.php') {
|
||||||
@@ -1269,6 +1280,20 @@ function format_date($date) {
|
|||||||
return date($user->datefmt, $timestamp);
|
return date($user->datefmt, $timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function format_datetime($datetime, $seconds=false) {
|
||||||
|
// datetime is string in ISO format
|
||||||
|
global $user;
|
||||||
|
if (empty($datetime)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$timestamp = strtotime($datetime);
|
||||||
|
if ($timestamp === false) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$timefmt = $seconds ? 'H:i:s' : 'H:i';
|
||||||
|
return date($user->datefmt. ' ' . $timefmt, $timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
function format_color($color) {
|
function format_color($color) {
|
||||||
$colstr = '<span style="';
|
$colstr = '<span style="';
|
||||||
$style = "padding:2px 4px;border-radius:4px;background-color:#".$color;
|
$style = "padding:2px 4px;border-radius:4px;background-color:#".$color;
|
||||||
|
|||||||
+3
-2
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
require 'lib/svg.inc';
|
require 'lib/svg.inc';
|
||||||
|
|
||||||
@@ -488,7 +489,7 @@ echo '<h2>', _('Add additional yacht'), "</h2>\n";
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||||
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$project->remarks ?></textarea>
|
<textarea class="form-control" id="remarks" name="remarks" rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="container-fluid px-0 my-3">
|
<div class="container-fluid px-0 my-3">
|
||||||
<button type="submit" name="submit[insert]" class="btn btn-primary"><?=_('Save')?></button>
|
<button type="submit" name="submit[insert]" class="btn btn-primary"><?=_('Save')?></button>
|
||||||
@@ -602,7 +603,7 @@ form_create_select('sid', _('Default Storage'), $g_opt_none + $opt_storage, $ves
|
|||||||
?>
|
?>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||||
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$vessel->remarks ?></textarea>
|
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($vessel->remarks, br:true)?></textarea>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle=_('Inventory');
|
$pagetitle=_('Inventory');
|
||||||
|
|||||||
@@ -8,3 +8,50 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function db_lock_acquire($table, $key, $userid) {
|
||||||
|
global $pdo;
|
||||||
|
$token = bin2hex(random_bytes(8));
|
||||||
|
// first try new lock
|
||||||
|
$sql = "INSERT INTO recordlock (lock_table, lock_key, token, userid) "
|
||||||
|
. "VALUES (?, ?, ?, ?)";
|
||||||
|
try {
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute([$table, $key, $token, $userid]);
|
||||||
|
return $token;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
if ($e->errorInfo[1] != 1062) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// lazy locking: lock exists but is old, so we use it
|
||||||
|
$sql = "UPDATE recordlock "
|
||||||
|
. "SET token=?, userid=?, "
|
||||||
|
. "created_at=CURRENT_TIMESTAMP, last_seen=CURRENT_TIMESTAMP "
|
||||||
|
. "WHERE lock_table=? AND lock_key=? "
|
||||||
|
. "AND last_seen<CURRENT_TIMESTAMP-INTERVAL 5 MINUTE";
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute([$token, $userid, $table, $key]);
|
||||||
|
if ($stmt->rowCount() === 1) {
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_lock_refresh($token) {
|
||||||
|
global $pdo;
|
||||||
|
$sql = "UPDATE recordlock "
|
||||||
|
. "SET last_seen=CURRENT_TIMESTAMP "
|
||||||
|
. "WHERE token=?";
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute([$token]);
|
||||||
|
return $sth->rowCount() === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function db_lock_release($token) {
|
||||||
|
global $pdo;
|
||||||
|
$sql = "DELETE FROM recordlock WHERE token=?";
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute([$token]);
|
||||||
|
return $sth->rowCount() === 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Maintenance');
|
$pagetitle = _('Maintenance');
|
||||||
@@ -288,7 +289,7 @@ echo '</div>'; // Column break
|
|||||||
echo '<div class="col">';
|
echo '<div class="col">';
|
||||||
|
|
||||||
// TODO Show documents for equipment
|
// TODO Show documents for equipment
|
||||||
echo "<h4>Documents</h4>\n";
|
echo '<h4>Documents for ', h($maint->ename), "</h4>\n";
|
||||||
if (isset($docs)) {
|
if (isset($docs)) {
|
||||||
echo '<ul>', "\n";
|
echo '<ul>', "\n";
|
||||||
foreach ($docs as $d) {
|
foreach ($docs as $d) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
// TODO move to somewhere else
|
// TODO move to somewhere else
|
||||||
|
|||||||
+8
-3
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Note');
|
$pagetitle = _('Note');
|
||||||
@@ -30,6 +31,7 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':notetype'] = gpc_get_enum($_POST, 'notetype', $opt_notetype, 'task');
|
$p[':notetype'] = gpc_get_enum($_POST, 'notetype', $opt_notetype, 'task');
|
||||||
$p[':refid'] = gpc_get_int($_POST, 'refid');
|
$p[':refid'] = gpc_get_int($_POST, 'refid');
|
||||||
$p[':annotation'] = gpc_get_string($_POST, 'annotation');
|
$p[':annotation'] = gpc_get_string($_POST, 'annotation');
|
||||||
|
$p[':created_by'] = $user->id;
|
||||||
$id = db_exec_insert('note', $p);
|
$id = db_exec_insert('note', $p);
|
||||||
$caller = gpc_get_string($_POST, 'caller');
|
$caller = gpc_get_string($_POST, 'caller');
|
||||||
$callid = $p[':refid'];
|
$callid = $p[':refid'];
|
||||||
@@ -171,7 +173,9 @@ elseif ($action == ACT_VIEW):
|
|||||||
|
|
||||||
echo '<h2>', _('View Note'), "</h2>\n";
|
echo '<h2>', _('View Note'), "</h2>\n";
|
||||||
|
|
||||||
$sql = "SELECT refid, notetype, annotation FROM note WHERE noteid=?";
|
$sql = "SELECT n.refid, n.notetype, n.annotation, n.created_at, u.displayname "
|
||||||
|
. "FROM note AS n LEFT OUTER JOIN user AS u ON (n.created_by=u.userid) "
|
||||||
|
. "WHERE noteid=?";
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute([$id]);
|
$sth->execute([$id]);
|
||||||
$note = $sth->fetch(PDO::FETCH_OBJ);
|
$note = $sth->fetch(PDO::FETCH_OBJ);
|
||||||
@@ -184,9 +188,10 @@ echo '<table class="table">', "\n";
|
|||||||
echo '<tr><th>', _('Reference'),"</th><td>", $note->refid, "</td></tr>\n";
|
echo '<tr><th>', _('Reference'),"</th><td>", $note->refid, "</td></tr>\n";
|
||||||
echo '<tr><th>', _('Type'),"</th><td>", $note->notetype, "</td></tr>\n";
|
echo '<tr><th>', _('Type'),"</th><td>", $note->notetype, "</td></tr>\n";
|
||||||
echo '<tr><th>', _('Annotation'),"</th><td>", nl2br($note->annotation), "</td></tr>\n";
|
echo '<tr><th>', _('Annotation'),"</th><td>", nl2br($note->annotation), "</td></tr>\n";
|
||||||
|
echo '<tr><th>', _('Created at'),"</th><td>", format_datetime($note->created_at), "</td></tr>\n";
|
||||||
|
echo '<tr><th>', _('Created by'),"</th><td>", h($note->displayname), "</td></tr>\n";
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
|
||||||
|
|
||||||
$link = $note->notetype == 'task' ? 'task.php' : 'maintenance.php';
|
$link = $note->notetype == 'task' ? 'task.php' : 'maintenance.php';
|
||||||
// echo '<p><a href="', $link, '?f=view&id=', $note->refid, '">', _('Parent'), "</a></p>\n";
|
// echo '<p><a href="', $link, '?f=view&id=', $note->refid, '">', _('Parent'), "</a></p>\n";
|
||||||
form_view_buttons($g_scriptname, $id, $link.'?f=view&id='.$note->refid);
|
form_view_buttons($g_scriptname, $id, $link.'?f=view&id='.$note->refid);
|
||||||
@@ -205,7 +210,7 @@ echo '<h2>', _('Edit Note'), "</h2>\n";
|
|||||||
<input type="hidden" name="id" value="<?=$id?>">
|
<input type="hidden" name="id" value="<?=$id?>">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="annotation" class="form-label"><?=_('Annotation')?></label>
|
<label for="annotation" class="form-label"><?=_('Annotation')?></label>
|
||||||
<textarea class="form-control" id="annotation" name="annotation" rows="5" autofocus><?=$note->annotation;?></textarea>
|
<textarea class="form-control" id="annotation" name="annotation" rows="5" autofocus><?=h($note->annotation, br:true);?></textarea>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
form_edit_buttons($g_scriptname, $id);
|
form_edit_buttons($g_scriptname, $id);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Projects');
|
$pagetitle = _('Projects');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle=_('Provisions');
|
$pagetitle=_('Provisions');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Search');
|
$pagetitle = _('Search');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Settings');
|
$pagetitle = _('Settings');
|
||||||
@@ -22,6 +23,11 @@ switch ($submit = form_get_action()) {
|
|||||||
// global settings
|
// global settings
|
||||||
if ($user->role == 'captain') {
|
if ($user->role == 'captain') {
|
||||||
$p[':userid'] = 0;
|
$p[':userid'] = 0;
|
||||||
|
$p[':sno'] = 4;
|
||||||
|
$p[':valstr'] = gpc_get_string($_POST, 'currsym', 3, '€');
|
||||||
|
db_exec_update('settings', $p, $pk);
|
||||||
|
$p[':valstr'] = NULL;
|
||||||
|
// image dimensions
|
||||||
$p[':sno'] = 20;
|
$p[':sno'] = 20;
|
||||||
$p[':valint'] = gpc_get_int($_POST, 'maximgx');
|
$p[':valint'] = gpc_get_int($_POST, 'maximgx');
|
||||||
db_exec_update('settings', $p, $pk);
|
db_exec_update('settings', $p, $pk);
|
||||||
@@ -101,6 +107,7 @@ if ($res = $sth->fetch(PDO::FETCH_NUM)) {
|
|||||||
$sth->execute([$user->id, $rowspp]);
|
$sth->execute([$user->id, $rowspp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$currsym = $pdo->query("SELECT valstr FROM settings WHERE userid=0 AND sno=4")->fetchColumn();
|
||||||
$maximgx = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=20")->fetchColumn();
|
$maximgx = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=20")->fetchColumn();
|
||||||
$maximgy = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=21")->fetchColumn();
|
$maximgy = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=21")->fetchColumn();
|
||||||
|
|
||||||
@@ -131,6 +138,10 @@ form_create_select('datefmt', _('Date format'), $opt_datefmt, $datefmt);
|
|||||||
if ($user->role == 'captain'):
|
if ($user->role == 'captain'):
|
||||||
?>
|
?>
|
||||||
<h2><?=_('global for all users')?></h2>
|
<h2><?=_('global for all users')?></h2>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="currsym" class="form-label"><?=_('Currency symbol')?></label>
|
||||||
|
<input type="text" class="form-control" id="currsym" name="currsym" maxlength="3" value=<?=$currsym?>>
|
||||||
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="maximgx" class="form-label"><?=_('Maximal image width')?></label>
|
<label for="maximgx" class="form-label"><?=_('Maximal image width')?></label>
|
||||||
<input type="text" class="form-control" id="maximgx" name="maximgx" maxlength="4" value=<?=$maximgx?>>
|
<input type="text" class="form-control" id="maximgx" name="maximgx" maxlength="4" value=<?=$maximgx?>>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Storage');
|
$pagetitle = _('Storage');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Tags');
|
$pagetitle = _('Tags');
|
||||||
|
|||||||
+10
-2
@@ -7,6 +7,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
require 'globals.inc';
|
require 'globals.inc';
|
||||||
|
require 'lib/db.inc';
|
||||||
require 'lib/gpc.inc';
|
require 'lib/gpc.inc';
|
||||||
|
|
||||||
$pagetitle = _('Task');
|
$pagetitle = _('Task');
|
||||||
@@ -73,6 +74,7 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':finished'] = gpc_get_datetime($_POST, 'finished');
|
$p[':finished'] = gpc_get_datetime($_POST, 'finished');
|
||||||
$p[':taskstate'] = gpc_get_enum($_POST, 'taskstate', array_keys($opt_state));
|
$p[':taskstate'] = gpc_get_enum($_POST, 'taskstate', array_keys($opt_state));
|
||||||
$p[':responsible'] = gpc_get_int($_POST, 'responsible');
|
$p[':responsible'] = gpc_get_int($_POST, 'responsible');
|
||||||
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
db_exec_update('task', $p, 'taskid');
|
db_exec_update('task', $p, 'taskid');
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
@@ -297,7 +299,7 @@ elseif ($action == ACT_VIEW):
|
|||||||
|
|
||||||
$sql = "SELECT t.taskname, t.priority, t.plandate, t.duedate,"
|
$sql = "SELECT t.taskname, t.priority, t.plandate, t.duedate,"
|
||||||
. " t.started, t.finished, t.taskstate, t.responsible,"
|
. " t.started, t.finished, t.taskstate, t.responsible,"
|
||||||
. " u.displayname, p.projname "
|
. " t.remarks, u.displayname, p.projname "
|
||||||
. "FROM task AS t LEFT JOIN project AS p USING (projid) "
|
. "FROM task AS t LEFT JOIN project AS p USING (projid) "
|
||||||
. " LEFT JOIN user AS u ON (t.responsible=u.userid) "
|
. " LEFT JOIN user AS u ON (t.responsible=u.userid) "
|
||||||
. "WHERE taskid=?";
|
. "WHERE taskid=?";
|
||||||
@@ -316,6 +318,7 @@ echo '<tr><th>', _('Started at'),"</th><td>", $task->started, "</td></tr>\n";
|
|||||||
echo '<tr><th>', _('Finished at'),"</th><td>", $task->finished, "</td></tr>\n";
|
echo '<tr><th>', _('Finished at'),"</th><td>", $task->finished, "</td></tr>\n";
|
||||||
echo '<tr><th>', _('Status'),"</th><td>", $opt_state[$task->taskstate], "</td></tr>\n";
|
echo '<tr><th>', _('Status'),"</th><td>", $opt_state[$task->taskstate], "</td></tr>\n";
|
||||||
echo '<tr><th>', _('Responsible'),"</th><td>", $task->displayname, "</td></tr>\n";
|
echo '<tr><th>', _('Responsible'),"</th><td>", $task->displayname, "</td></tr>\n";
|
||||||
|
echo '<tr><th>', _('Remarks'),"</th><td>", h($task->remarks, br:true), "</td></tr>\n";
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
|
||||||
form_view_buttons($g_scriptname, $id);
|
form_view_buttons($g_scriptname, $id);
|
||||||
@@ -392,7 +395,12 @@ form_create_select('priority', _('Priority'), $opt_none + $opt_priority, $task->
|
|||||||
<?php
|
<?php
|
||||||
form_create_select('taskstate', _('Status'), $opt_state, $task->taskstate);
|
form_create_select('taskstate', _('Status'), $opt_state, $task->taskstate);
|
||||||
form_create_select('responsible', _('Responsible'), $opt_user, $user->id);
|
form_create_select('responsible', _('Responsible'), $opt_user, $user->id);
|
||||||
|
?>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||||
|
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($task->remarks, br:true)?></textarea>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
form_edit_buttons($g_scriptname, $id);
|
form_edit_buttons($g_scriptname, $id);
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user