More work an webgui

This commit is contained in:
2024-04-10 20:13:37 +02:00
parent 4b5ba85a77
commit aaa452cbb5
20 changed files with 842 additions and 359 deletions
+156 -154
View File
@@ -4,13 +4,13 @@
Version: 1 */ Version: 1 */
CREATE TABLE user ( CREATE TABLE user (
userid SMALLINT(6) NOT NULL AUTO_INCREMENT, userid smallint(6) NOT NULL AUTO_INCREMENT,
login VARCHAR(20) NOT NULL, login varchar(20) NOT NULL,
pass BINARY(60) NOT NULL, pass binary(60) NOT NULL,
displayname VARCHAR(100) NOT NULL, displayname varchar(100) NOT NULL,
role SET('vessel', 'captain','helmsman','sailor') NOT NULL DEFAULT 'sailor', role set('vessel', 'captain','helmsman','sailor') NOT NULL DEFAULT 'sailor',
flags SET('deleted','locked'), flags set('deleted','locked'),
language CHAR(2) NOT NULL DEFAULT 'en', language char(2) NOT NULL DEFAULT 'en',
PRIMARY KEY (userid), PRIMARY KEY (userid),
UNIQUE INDEX ix_login (login) UNIQUE INDEX ix_login (login)
); );
@@ -31,10 +31,10 @@ CREATE TABLE user (
*/ */
CREATE TABLE settings ( CREATE TABLE settings (
userid SMALLINT(6) NOT NULL, userid smallint(6) NOT NULL,
sno SMALLINT(6) NOT NULL, sno smallint(6) NOT NULL,
valstr VARCHAR(200) DEFAULT NULL, valstr varchar(200) DEFAULT NULL,
valint INT(10) DEFAULT NULL, valint int(10) DEFAULT NULL,
PRIMARY KEY (userid, sno) PRIMARY KEY (userid, sno)
); );
@@ -42,43 +42,45 @@ CREATE TABLE settings (
flags: fixed=not deletable, value not changeable flags: fixed=not deletable, value not changeable
locked=not editable */ locked=not editable */
CREATE TABLE dropdown ( CREATE TABLE dropdown (
ddid TINYINT(3) UNSIGNED NOT NULL, ddid tinyint(3) UNSIGNED NOT NULL,
ddval TINYINT(3) NOT NULL, ddval tinyint(3) NOT NULL,
sort TINYINT(3) DEFAULT NULL, sort tinyint(3) DEFAULT NULL,
ddtext VARCHAR(50) NOT NULL, ddtext varchar(50) NOT NULL,
ddshort VARCHAR(4) DEFAULT NULL, ddshort varchar(4) DEFAULT NULL,
color CHAR(6) DEFAULT NULL, color char(6) DEFAULT NULL,
flags ENUM('locked', 'fixed') DEFAULT NULL, flags enum('locked', 'fixed') DEFAULT NULL,
PRIMARY KEY (ddid, ddval) PRIMARY KEY (ddid, ddval)
); );
CREATE TABLE vessel ( CREATE TABLE vessel (
vid SMALLINT(10) NOT NULL AUTO_INCREMENT, vid smallint(10) NOT NULL AUTO_INCREMENT,
vtype ENUM('mono','cat','tri') NOT NULL DEFAULT 'mono', vtype enum('mono','cat','tri') NOT NULL DEFAULT 'mono',
vesselname VARCHAR(40) NOT NULL, vesselname varchar(40) NOT NULL,
model VARCHAR(20) DEFAULT NULL, model varchar(20) DEFAULT NULL,
loa FLOAT(4,2) UNSIGNED DEFAULT NULL, loa float(4,2) UNSIGNED DEFAULT NULL,
lwl FLOAT(4,2) UNSIGNED DEFAULT NULL, lwl float(4,2) UNSIGNED DEFAULT NULL,
beam FLOAT(4,2) UNSIGNED DEFAULT NULL, beam float(4,2) UNSIGNED DEFAULT NULL,
draught FLOAT(3,2) UNSIGNED DEFAULT NULL, draught float(3,2) UNSIGNED DEFAULT NULL,
draught_min FLOAT(3,2) UNSIGNED DEFAULT NULL, draught_min float(3,2) UNSIGNED DEFAULT NULL,
displacement SMALLINT(6) UNSIGNED DEFAULT NULL, displacement smallint(6) UNSIGNED DEFAULT NULL,
ballast SMALLINT(6) UNSIGNED DEFAULT NULL, ballast smallint(6) UNSIGNED DEFAULT NULL,
remarks VARCHAR(150) DEFAULT NULL, beltpos_aft float(4,2) UNSIGNED DEFAULT NULL,
beltpos_bow float(4,2) UNSIGNED DEFAULT NULL,
remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (vid) PRIMARY KEY (vid)
); );
CREATE TABLE storage ( CREATE TABLE storage (
sid SMALLINT(6) NOT NULL AUTO_INCREMENT, sid smallint(6) NOT NULL AUTO_INCREMENT,
vid SMALLINT(6) NOT NULL DEFAULT 1, vid smallint(6) NOT NULL DEFAULT 1,
sname VARCHAR(40) NOT NULL, sname varchar(40) NOT NULL,
stype TINYINT(3) NOT NULL DEFAULT 0, stype tinyint(3) NOT NULL DEFAULT 0,
capacity SMALLINT(6) DEFAULT NULL, capacity smallint(6) DEFAULT NULL,
capaunit ENUM('kg', 'l') DEFAULT NULL, capaunit enum('kg', 'l') DEFAULT NULL,
x SMALLINT(6) NOT NULL DEFAULT 0, x smallint(6) NOT NULL DEFAULT 0,
y SMALLINT(6) NOT NULL DEFAULT 0, y smallint(6) NOT NULL DEFAULT 0,
z SMALLINT(6) NOT NULL DEFAULT 0, z smallint(6) NOT NULL DEFAULT 0,
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (sid) PRIMARY KEY (sid)
); );
@@ -86,132 +88,132 @@ CREATE TABLE storage (
CREATE TABLE tag ( CREATE TABLE tag (
tagid SMALLINT(6) NOT NULL AUTO_INCREMENT, tagid smallint(6) NOT NULL AUTO_INCREMENT,
tagname VARCHAR(20) NOT NULL, tagname varchar(20) NOT NULL,
color CHAR(6) DEFAULT NULL, color char(6) DEFAULT NULL,
PRIMARY KEY (tagid), PRIMARY KEY (tagid),
UNIQUE INDEX ix_tagname (tagname) UNIQUE INDEX ix_tagname (tagname)
); );
CREATE TABLE tagref ( CREATE TABLE tagref (
tagid SMALLINT(6) NOT NULL, tagid smallint(6) NOT NULL,
objid SMALLINT(6) NOT NULL, objid smallint(6) NOT NULL,
objtype ENUM('equip','inv','prov','doc') NOT NULL, objtype enum('equip','inv','prov','doc') NOT NULL,
PRIMARY KEY (tagid, objid, objtype) PRIMARY KEY (tagid, objid, objtype)
); );
/* TODO Boxes can be nested via parent /* TODO Boxes can be nested via parent
TODO boxsize: (LxWxH) in cm? */ TODO boxsize: (LxWxH) in cm? */
CREATE TABLE box ( CREATE TABLE box (
boxid SMALLINT(6) NOT NULL AUTO_INCREMENT, boxid smallint(6) NOT NULL AUTO_INCREMENT,
sid SMALLINT(6) NOT NULL, sid smallint(6) NOT NULL,
parent INT(10) DEFAULT NULL, parent int(10) DEFAULT NULL,
label VARCHAR(20) DEFAULT NULL, label varchar(20) DEFAULT NULL,
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,
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (boxid), PRIMARY KEY (boxid),
INDEX ix_label (label) INDEX ix_label (label)
); );
CREATE TABLE equipment ( CREATE TABLE equipment (
eid SMALLINT(6) NOT NULL AUTO_INCREMENT, eid smallint(6) NOT NULL AUTO_INCREMENT,
vid SMALLINT(6) NOT NULL DEFAULT 1, vid smallint(6) NOT NULL DEFAULT 1,
ename VARCHAR(80) NOT NULL, ename varchar(80) NOT NULL,
make VARCHAR(40), make varchar(40),
model VARCHAR(40), model varchar(40),
ecat TINYINT(3) DEFAULT NULL, ecat tinyint(3) DEFAULT NULL,
serial VARCHAR(30), serial varchar(30),
supplier SMALLINT(6) DEFAULT NULL, supplier smallint(6) DEFAULT NULL,
manufacturer SMALLINT(6) DEFAULT NULL, manufacturer smallint(6) DEFAULT NULL,
purchdate DATE DEFAULT NULL, purchdate date DEFAULT NULL,
price DECIMAL(12,2) DEFAULT NULL, price decimal(12,2) DEFAULT NULL,
weight FLOAT(5,2) UNSIGNED DEFAULT NULL, weight float(5,2) UNSIGNED DEFAULT NULL,
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
PRIMARY KEY(eid) PRIMARY KEY(eid)
); );
CREATE TABLE inventory ( CREATE TABLE inventory (
invid INT(10) NOT NULL AUTO_INCREMENT, invid int(10) NOT NULL AUTO_INCREMENT,
invname VARCHAR(80) NOT NULL, invname varchar(80) NOT NULL,
boxtype ENUM('storage','box') NOT NULL DEFAULT 'storage', boxtype enum('storage','box') NOT NULL DEFAULT 'storage',
sid SMALLINT(6) NOT NULL DEFAULT 1, sid smallint(6) NOT NULL DEFAULT 1,
boxid SMALLINT(6) NOT NULL DEFAULT 1, boxid smallint(6) NOT NULL DEFAULT 1,
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,
purchdate DATE DEFAULT NULL, purchdate date DEFAULT NULL,
invcond ENUM('unknown','good','normal','bad','repairable','defect') NOT NULL default 'unknown', invcond enum('unknown','good','normal','bad','repairable','defect') NOT NULL default 'unknown',
PRIMARY KEY (invid), PRIMARY KEY (invid),
INDEX ix_invname (invname) INDEX ix_invname (invname)
); );
CREATE TABLE measurement ( CREATE TABLE measurement (
mid SMALLINT(6) NOT NULL AUTO_INCREMENT, mid smallint(6) NOT NULL AUTO_INCREMENT,
mname VARCHAR(80) NOT NULL, mname varchar(80) NOT NULL,
nval TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, nval tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
val1 INT(10) NOT NULL, val1 int(10) NOT NULL,
val2 INT(10) NOT NULL, val2 int(10) NOT NULL,
val3 INT(10) NOT NULL, val3 int(10) NOT NULL,
unit TINYINT(3) NOT NULL DEFAULT 1, 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, mdate date DEFAULT NULL,
note VARCHAR(80) DEFAULT NULL, note varchar(80) DEFAULT NULL,
eid SMALLINT(6) DEFAULT NULL, eid smallint(6) DEFAULT NULL,
PRIMARY KEY (mid) PRIMARY KEY (mid)
); );
CREATE TABLE provisions ( CREATE TABLE provisions (
provid INT(10) NOT NULL AUTO_INCREMENT, provid int(10) NOT NULL AUTO_INCREMENT,
provname VARCHAR(40) NOT NULL, provname varchar(40) NOT NULL,
sid SMALLINT(6) DEFAULT NULL, sid smallint(6) DEFAULT NULL,
number SMALLINT(6) UNSIGNED NOT NULL DEFAULT 1, number smallint(6) UNSIGNED NOT NULL DEFAULT 1,
unit TINYINT(3) DEFAULT NULL, unit tinyint(3) DEFAULT NULL,
storedate DATE DEFAULT CURRENT_DATE, storedate date DEFAULT CURRENT_DATE,
shelflife DATE DEFAULT NULL, shelflife date DEFAULT NULL,
PRIMARY KEY (provid) PRIMARY KEY (provid)
); );
CREATE TABLE document ( CREATE TABLE document (
docid SMALLINT(6) NOT NULL AUTO_INCREMENT, 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', mimetype varchar(80) NOT NULL DEFAULT 'application/octet-stream',
filename VARCHAR(200) NOT NULL, filename varchar(200) NOT NULL,
extension CHAR(3) NOT NULL, extension char(3) NOT NULL,
hash VARCHAR(32) NOT NULL, hash varchar(32) NOT NULL,
docsize INT(10) unsigned NOT NULL, docsize int(10) unsigned NOT NULL,
doctime DATETIME DEFAULT NULL, doctime datetime DEFAULT NULL,
title VARCHAR(40) DEFAULT NULL, title varchar(40) DEFAULT NULL,
pages SMALLINT(6) unsigned NOT NULL DEFAULT 1, pages smallint(6) unsigned NOT NULL DEFAULT 1,
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (docid) PRIMARY KEY (docid)
); );
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') NOT NULL DEFAULT 'vessel', reftype enum('vessel', 'box', 'equipment', 'project', 'task') NOT NULL DEFAULT 'vessel',
docid SMALLINT(6) NOT NULL, docid smallint(6) NOT NULL,
refid SMALLINT(6) NOT NULL, refid smallint(6) NOT NULL,
PRIMARY KEY (drid), PRIMARY KEY (drid),
UNIQUE INDEX ix_docref (docid, refid) UNIQUE INDEX ix_docref (docid, refid)
); );
CREATE TABLE company ( CREATE TABLE company (
compid SMALLINT(6) NOT NULL AUTO_INCREMENT, compid smallint(6) NOT NULL AUTO_INCREMENT,
compname VARCHAR(40) NOT NULL, compname varchar(40) NOT NULL,
comptype TINYINT(3) NOT NULL DEFAULT 1, comptype tinyint(3) NOT NULL DEFAULT 1,
street VARCHAR(30), street varchar(30),
zip VARCHAR(10), zip varchar(10),
city VARCHAR(30), city varchar(30),
country VARCHAR(30), country varchar(30),
contact VARCHAR(30), contact varchar(30),
phone VARCHAR(30), phone varchar(30),
email VARCHAR(50), email varchar(50),
web VARCHAR(40), web varchar(40),
customerno VARCHAR(20), customerno varchar(20),
contractno VARCHAR(20), contractno varchar(20),
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (compid), PRIMARY KEY (compid),
UNIQUE INDEX ix_compname (compname) UNIQUE INDEX ix_compname (compname)
); );
@@ -219,57 +221,57 @@ CREATE TABLE company (
/* TODO optional field: plan date, target date, completion date */ /* TODO optional field: plan date, target date, completion date */
CREATE TABLE maintenance ( CREATE TABLE maintenance (
maintid INT(10) NOT NULL AUTO_INCREMENT, maintid int(10) NOT NULL AUTO_INCREMENT,
vid SMALLINT(6) NOT NULL DEFAULT 1, vid smallint(6) NOT NULL DEFAULT 1,
eid SMALLINT(6) DEFAULT NULL, eid smallint(6) DEFAULT NULL,
series SMALLINT(6) DEFAULT NULL, series smallint(6) DEFAULT NULL,
activities VARCHAR(40) NOT NULL, activities varchar(40) NOT NULL,
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
maintstate ENUM('new','planned','ongoing','done') NOT NULL DEFAULT 'new', maintstate enum('new','planned','ongoing','done') NOT NULL DEFAULT 'new',
PRIMARY KEY (maintid) PRIMARY KEY (maintid)
); );
/* 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,
vid SMALLINT(6) NOT NULL DEFAULT 1, vid smallint(6) NOT NULL DEFAULT 1,
responsible SMALLINT(6) NOT NULL, responsible smallint(6) NOT NULL,
startdate date DEFAULT NULL, startdate date DEFAULT NULL,
duration SMALLINT(6) UNSIGNED DEFAULT NULL, duration smallint(6) UNSIGNED DEFAULT NULL,
costs_plan DECIMAL(12,2) DEFAULT NULL, costs_plan decimal(12,2) DEFAULT NULL,
costs_final DECIMAL(12,2) DEFAULT NULL, costs_final decimal(12,2) DEFAULT NULL,
remarks VARCHAR(150) DEFAULT NULL, remarks varchar(150) DEFAULT NULL,
projstate ENUM('new','plan','ongoing','finished') NOT NULL DEFAULT 'new', projstate enum('new','plan','ongoing','finished') NOT NULL DEFAULT 'new',
PRIMARY KEY (projid) PRIMARY KEY (projid)
); );
CREATE TABLE task ( CREATE TABLE task (
taskid INT(10) NOT NULL AUTO_INCREMENT, taskid int(10) NOT NULL AUTO_INCREMENT,
projid SMALLINT(6) DEFAULT NULL, projid smallint(6) DEFAULT NULL,
taskname VARCHAR(60) NOT NULL, taskname varchar(60) NOT NULL,
taskstate ENUM('new','finished') NOT NULL DEFAULT 'new', taskstate enum('new','finished') NOT NULL DEFAULT 'new',
PRIMARY KEY (taskid) PRIMARY KEY (taskid)
); );
CREATE TABLE checklist ( CREATE TABLE checklist (
clid SMALLINT(6) NOT NULL AUTO_INCREMENT, clid smallint(6) NOT NULL AUTO_INCREMENT,
title VARCHAR(30) NOT NULL, title varchar(30) NOT NULL,
clstate ENUM('new','open','closed') NOT NULL DEFAULT 'new', clstate enum('new','open','closed') NOT NULL DEFAULT 'new',
PRIMARY KEY (clid) PRIMARY KEY (clid)
); );
CREATE TABLE checkitem ( CREATE TABLE checkitem (
checkid INT(10) NOT NULL AUTO_INCREMENT, checkid int(10) NOT NULL AUTO_INCREMENT,
checkname VARCHAR(60) NOT NULL, checkname varchar(60) NOT NULL,
groupid TINYINT(3) DEFAULT NULL, groupid tinyint(3) DEFAULT NULL,
PRIMARY KEY (checkid) PRIMARY KEY (checkid)
); );
CREATE TABLE checkref ( CREATE TABLE checkref (
clid SMALLINT(6) NOT NULL, clid smallint(6) NOT NULL,
checkid INT(10) NOT NULL, checkid int(10) NOT NULL,
sort SMALLINT(6) DEFAULT NULL, sort smallint(6) DEFAULT NULL,
PRIMARY KEY (clid, checkid) PRIMARY KEY (clid, checkid)
); );
+1
View File
@@ -13,6 +13,7 @@ INSERT INTO user (userid, login, pass, displayname, role) VALUES
INSERT INTO settings (userid, sno, valint) VALUES INSERT INTO settings (userid, sno, valint) VALUES
(0, 0, 1), -- Databankschema-Version (0, 0, 1), -- Databankschema-Version
(0, 1, 0), -- Keine Bootszuordnung für SYSTEM
(1, 1, 0); -- Keine Bootszuordnung für Benutzer "captain" (1, 1, 0); -- Keine Bootszuordnung für Benutzer "captain"
/* Liste der Listen wird immer benötigt */ /* Liste der Listen wird immer benötigt */
+1
View File
@@ -13,6 +13,7 @@ INSERT INTO user (userid, login, pass, displayname, role) VALUES
INSERT INTO settings (userid, sno, valint) VALUES INSERT INTO settings (userid, sno, valint) VALUES
(0, 0, 1), -- Database schema version (0, 0, 1), -- Database schema version
(0, 1, 0), -- No vessel for SYSTEM
(1, 1, 0); -- No vessel for captain (1, 1, 0); -- No vessel for captain
/* list of lists needed */ /* list of lists needed */
+14 -11
View File
@@ -98,13 +98,9 @@ echo "<td></td>";
echo "</tr>\n"; echo "</tr>\n";
foreach ($res as $row) { foreach ($res as $row) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td>". $row['label'] ."</td>\n"; echo '<td>', $row['label'], "</td>\n";
$style = 'background-color:#' . $row['color']; echo '<td>', format_color(strtoupper($row['color'])), "</td>\n";
if (get_color_brightness($row['color']) < 0.4) { echo '<td>', $row['content'], "</td>\n";
$style .= ';color:white';
}
echo '<td><span style="', $style,'">#'. $row['color'] ."</span></td>\n";
echo "<td>". $row['content'] ."</td>\n";
echo '<td class="text-end">', format_float($row['weight'], 2), "</td>\n"; echo '<td class="text-end">', format_float($row['weight'], 2), "</td>\n";
form_action_buttons($g_scriptname, $row['boxid']); form_action_buttons($g_scriptname, $row['boxid']);
echo "</tr>\n"; echo "</tr>\n";
@@ -123,7 +119,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add Box'), "</h2>\n"; echo '<h2>', _('Add Box'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_Scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="label" class="form-label"><?=_('Label')?></label> <label for="label" class="form-label"><?=_('Label')?></label>
<input type="text" maxlength="20" class="form-control" id="label" name="label" autofocus> <input type="text" maxlength="20" class="form-control" id="label" name="label" autofocus>
@@ -167,7 +163,7 @@ echo '<h2>', $box->label, "</h2>\n";
echo '<table class="table">', "\n"; echo '<table class="table">', "\n";
echo '<tr><th style="width:20%">', _('Content'),"</th><td>", $box->content, "</td></tr>\n"; echo '<tr><th style="width:20%">', _('Content'),"</th><td>", $box->content, "</td></tr>\n";
echo '<tr><th>', _('Color'), '</th><td style="background-color:#', $box->color, '">#', $box->color, "</td></tr>\n"; echo '<tr><th>', _('Color'), '</th><td>', format_color($box->color), "</td></tr>\n";
echo '<tr><th>', _('Weight'), '</th><td>', format_float($box->weight, 2, 'kg'), "</td></tr>\n"; echo '<tr><th>', _('Weight'), '</th><td>', format_float($box->weight, 2, 'kg'), "</td></tr>\n";
echo '<tr><th>', _('Remarks'),"</th><td>", $box->remarks, "</td></tr>\n"; echo '<tr><th>', _('Remarks'),"</th><td>", $box->remarks, "</td></tr>\n";
echo "</table>\n"; echo "</table>\n";
@@ -176,25 +172,32 @@ form_view_buttons($g_scriptname, $id);
// Inventory in box // Inventory in box
// WIP // WIP
$sql = "SELECT invid, invname FROM inventory WHERE boxtype='box' AND boxid=?"; $sql = "SELECT invid, invname, weight FROM inventory WHERE boxtype='box' AND boxid=?";
$sth = $pdo->prepare($sql); $sth = $pdo->prepare($sql);
$sth->execute([$id]); $sth->execute([$id]);
$res = $sth->fetchAll(); $res = $sth->fetchAll();
echo '<h3>', _('Inventory in box'), "</h3>\n"; echo '<h3>', _('Inventory in box'), "</h3>\n";
$weight_total = 0.0;
if ($res) { if ($res) {
echo '<table class="table table-striped">', "\n"; echo '<table class="table table-striped">', "\n";
echo "<thead>\n"; echo "<thead>\n";
echo "<tr>"; echo "<tr>";
echo '<th>', _('Inventory'), "</th>"; echo '<th>', _('Inventory'), "</th>";
echo '<th>', _('Weight'), "</th>";
echo "<td></td>"; echo "<td></td>";
echo "</tr>\n"; echo "</tr>\n";
foreach ($res as $row) { foreach ($res as $row) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td>", $row['invname'], "</td>\n"; echo "<td>", $row['invname'], "</td>\n";
echo "<td>", format_float($row['weight'], 2, 'kg'), "</td>\n";
form_action_buttons('inventory.php', $row['invid']); form_action_buttons('inventory.php', $row['invid']);
echo "</tr>\n"; echo "</tr>\n";
$weight_total += $row['weight'];
} }
echo "<tfoot>";
echo '<tr><td></td><td>', format_float($weight_total, 2, 'kg'), '</td>', "\n";
echo "</tfoot>\n";
echo "</table>\n"; echo "</table>\n";
} else { } else {
echo '<p>', _('Box is empty'), "</p>\n"; echo '<p>', _('Box is empty'), "</p>\n";
@@ -212,7 +215,7 @@ $box = $sth->fetch(PDO::FETCH_OBJ);
echo '<h2>', _('Edit Box'), "</h2>\n"; echo '<h2>', _('Edit Box'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>"> <input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3"> <div class="mb-3">
<label for="label" class="form-label"><?=_('Label')?></label> <label for="label" class="form-label"><?=_('Label')?></label>
+137 -4
View File
@@ -11,13 +11,146 @@ $pagetitle = _('Checklists');
$id = gpc_get_int($_REQUEST, 'id', 0); $id = gpc_get_int($_REQUEST, 'id', 0);
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
case NULL: break;
case 'add': $action = ACT_ADD; break;
case 'view': $action = ACT_VIEW; break;
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
case 'insert':
$p[':title'] = gpc_get_string($_POST, 'title');
$p[':clstate'] = gpc_get_string($_POST, 'clstate');
$id = db_exec_insert('checklist', $p);
$action = ACT_VIEW;
break;
case 'update':
$p[':title'] = gpc_get_string($_POST, 'title');
$p[':clstate'] = gpc_get_string($_POST, 'clstate');
$p[':clid'] = $id;
db_exec_update('checklist', $p, 'clid');
$action = ACT_VIEW;
break;
case 'delete':
$action = ACT_DEFAULT;
break;
default:
$g_error->Add(sprintf(_("Unknown function '%s'!"), $submit));
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
require 'header.php'; require 'header.php';
// ========== PAGE CONTENT ====================================================
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
echo "<h1>$pagetitle</h1>\n"; echo "<h1>$pagetitle</h1>\n";
$sql = "SELECT clid, title, clstate FROM checklist";
$sth = $pdo->query($sql);
$res = $sth->fetchAll();
?> ?>
<table class="table table-striped">
<p>Search will be implemented later. <thead>
This page is currently just a placeholder.</p> <tr>
<th>#</th>
<th><?=_('Title')?></th>
<th><?=_('State')?></th>
<th></th>
</tr>
</thead>
<?php <?php
foreach ($res as $row) {
echo "<tr>\n";
echo '<td>', $row['clid'], "</td>\n";
echo '<td>', $row['title'], "</td>\n";
echo '<td>', $row['clstate'], "</td>\n";
form_action_buttons($g_scriptname, $row['clid']);
echo "</tr>\n";
}
// Table summary
echo "<tfoot>\n";
echo '<tr><td colspan="6">', sprintf(_('%d records'), count($res)), '</td></tr>', "\n";
echo "</tfoot>\n";
echo "</table>\n";
form_add_button($g_scriptname);
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
echo '<h2>', _('Add Checklist'), "</h2>\n";
?>
<form method="post" action="<?=$g_scriptname?>">
<div class="mb-3">
<label for="title" class="form-label"><?=_('Title')?></label>
<input type="text" class="form-control" id="title" name="title">
</div>
<?php
form_new_buttons($g_scriptname);
echo "</form>\n";
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sth = $pdo->prepare("SELECT title, clstate FROM checklist WHERE clid=?");
$sth->execute([$id]);
$checklist = $sth->fetch(PDO::FETCH_OBJ);
?>
<h2><?=_('View Checklist')?></h2>
<table class="table">
<tr><th><?=_('Title')?></th><td><?=$checklist->title ?></td></tr>
<tr><th><?=_('State')?></th><td><?=get_enum($checklist->clstate)?></td></tr>
</table>
<?php
form_view_buttons($g_scriptname, $id);
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sth = $pdo->prepare("SELECT title, clstate FROM checklist WHERE clid=?");
$sth->execute([$id]);
$checklist = $sth->fetch(PDO::FETCH_OBJ);
$opt_clstate = db_load_enum('checklist', 'clstate', true, true);
echo '<h2>', _('Edit checklist'), "</h2>\n";
?>
<form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3">
<label for="provname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="title" name="title" value="<?=$checklist->title ?>">
</div>
<?php
form_create_select('clstate', _('State'), $opt_clstate, $checklist->clstate);
form_edit_buttons($g_scriptname, $id);
echo "</form>\n";
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
echo '<h2>', _('Delete checklist'), "</h2>\n";
else:
// ========== ERROR UNKNOWN VARIANT ===========================================
echo '<p>', _('Unknown function call: Please report to system development!'), "</p>\n";
endif; // $action == ...
// ========== END OF VARIANTS =================================================
include 'footer.php'; include 'footer.php';
+19 -56
View File
@@ -24,65 +24,28 @@ switch ($submit = form_get_action()) {
case 'del': $action = ACT_DELETE; break; case 'del': $action = ACT_DELETE; break;
case 'insert': case 'insert':
$compname = gpc_get_string($_POST, 'compname'); $p[':compname'] = gpc_get_string($_POST, 'compname');
$comptype = gpc_get_int($_POST, 'comptype'); $p[':comptype'] = gpc_get_int($_POST, 'comptype');
$sql = "INSERT INTO company " $id = db_exec_insert('company', $p);
. " (compname, comptype) "
. "VALUES "
. " (:compname, :comptype)";
$sth = $pdo->prepare($sql);
$sth->bindValue(':compname', $compname, PDO::PARAM_STR);
$sth->bindValue(':comptype', $comptype, PDO::PARAM_INT);
$sth->execute();
$id = $pdo->lastInsertId();
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
case 'update': case 'update':
$compname = gpc_get_string($_POST, 'compname'); $p[':compid'] = $id;
$comptype = gpc_get_int($_POST, 'comptype'); $p[':compname'] = gpc_get_string($_POST, 'compname');
$street = gpc_get_string($_POST, 'street', 30); $p[':comptype'] = gpc_get_int($_POST, 'comptype');
$zip = gpc_get_string($_POST, 'zip', 10); $p[':street'] = gpc_get_string($_POST, 'street', 30);
$city = gpc_get_string($_POST, 'city', 30); $p[':zip'] = gpc_get_string($_POST, 'zip', 10);
$country = gpc_get_string($_POST, 'country', 30); $p[':city'] = gpc_get_string($_POST, 'city', 30);
$contact = gpc_get_string($_POST, 'contact', 30); $p[':country'] = gpc_get_string($_POST, 'country', 30);
$phone = gpc_get_string($_POST, 'phone', 30); $p[':contact'] = gpc_get_string($_POST, 'contact', 30);
$email = gpc_get_string($_POST, 'email', 50); $p[':phone'] = gpc_get_string($_POST, 'phone', 30);
$web = gpc_get_string($_POST, 'web', 40); $p[':email'] = gpc_get_string($_POST, 'email', 50);
$customerno = gpc_get_string($_POST, 'customerno', 20); $p[':web'] = gpc_get_string($_POST, 'web', 40);
$contractno = gpc_get_string($_POST, 'contractno', 20); $p[':customerno'] = gpc_get_string($_POST, 'customerno', 20);
$remarks = gpc_get_string($_POST, 'remarks', 150); $p[':contractno'] = gpc_get_string($_POST, 'contractno', 20);
$sql = "UPDATE company " $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
. "SET compname=:compname," db_exec_update('company', $p, 'compid');
. " comptype=:comptype,"
. " street=:street,"
. " zip=:zip,"
. " city=:city,"
. " country=:country,"
. " contact=:contact,"
. " phone=:phone,"
. " email=:email,"
. " web=:web,"
. " customerno=:customerno,"
. " contractno=:contractno,"
. " remarks=:remarks "
. "WHERE compid=:compid";
$sth = $pdo->prepare($sql);
$sth->bindValue(':compid', $id, PDO::PARAM_INT);
$sth->bindValue(':compname', $compname, PDO::PARAM_STR);
$sth->bindValue(':comptype', $comptype, PDO::PARAM_INT);
$sth->bindValue(':street', $street, PDO::PARAM_STR);
$sth->bindValue(':zip', $zip, PDO::PARAM_STR);
$sth->bindValue(':city', $city, PDO::PARAM_STR);
$sth->bindValue(':country', $country, PDO::PARAM_STR);
$sth->bindValue(':contact', $contact, PDO::PARAM_STR);
$sth->bindValue(':phone', $phone, PDO::PARAM_STR);
$sth->bindValue(':email', $email, PDO::PARAM_STR);
$sth->bindValue(':web', $web, PDO::PARAM_STR);
$sth->bindValue(':customerno', $customerno, PDO::PARAM_STR);
$sth->bindValue(':contractno', $contractno, PDO::PARAM_STR);
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
$sth->execute();
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
@@ -157,7 +120,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add Company'), "</h2>\n"; echo '<h2>', _('Add Company'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="compname" class="form-label"><?=_('Name')?></label> <label for="compname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="compname" name="compname"> <input type="text" class="form-control" id="compname" name="compname">
+16 -6
View File
@@ -24,8 +24,8 @@ switch ($submit = form_get_action()) {
case 'insert': case 'insert':
// WIP New standalone document // WIP New standalone document
$title = gpc_get_string($_POST, 'title'); $p[':title'] = gpc_get_string($_POST, 'title');
$remarks = gpc_get_string($_POST, 'remarks'); $p[':remarks'] = gpc_get_string($_POST, 'remarks');
$g_message->Add(print_r($_FILES, true)); $g_message->Add(print_r($_FILES, true));
if (empty($_FILES['files']['tmp_name']) ) { if (empty($_FILES['files']['tmp_name']) ) {
$g_warning->Add(_('No file for upload submitted. Try again by selecting a file first.')); $g_warning->Add(_('No file for upload submitted. Try again by selecting a file first.'));
@@ -77,7 +77,16 @@ switch ($submit = form_get_action()) {
$doctype = 'picture'; $doctype = 'picture';
break; break;
} }
$sql = "INSERT INTO document" $p[':doctype'] = $doctype;
$p[':mimetype'] = $file_mimetype;
$p[':filename'] = $file_name;
$p[':extension'] = $file_ext;
$p[':hash'] = $file_hash;
$p[':doctime'] = $file_timestamp;
$p[':docsize'] = $file_size;
$p[':title'] = gpc_get_string($_POST, 'title');
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
/* $sql = "INSERT INTO document"
. " (doctype, filename, extension, hash, doctime, docsize, mimetype) " . " (doctype, filename, extension, hash, doctime, docsize, mimetype) "
. "VALUES" . "VALUES"
. " (?, ?, ?, ?, ?, ?, ?)"; . " (?, ?, ?, ?, ?, ?, ?)";
@@ -87,7 +96,8 @@ switch ($submit = form_get_action()) {
} catch (PDOException $e) { } catch (PDOException $e) {
$g_error->Add('SQL-Error: '. $e->getMessage()); $g_error->Add('SQL-Error: '. $e->getMessage());
} }
$id = $pdo->lastInsertId(); $id = $pdo->lastInsertId(); */
$id = db_exec_insert('document', $p);
move_uploaded_file($file_tmp, $file_techname); move_uploaded_file($file_tmp, $file_techname);
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
@@ -366,7 +376,7 @@ $sth->execute([$id]);
$document = $sth->fetch(PDO::FETCH_OBJ); $document = $sth->fetch(PDO::FETCH_OBJ);
if ($document->doctype == 'picture') { if ($document->doctype == 'picture') {
echo '<img width="', $g_thumb_size, '" src="doc/pic-', $document->hash, '.', $document->extension, '">'; echo '<img width="', $g_thumb_size, '" src="dl.php?id=', $document->docid, '">';
} }
?> ?>
@@ -382,7 +392,7 @@ if ($document->doctype == 'picture') {
</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"><?=$storage->remarks ?></textarea> <textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$document->remarks ?></textarea>
</div> </div>
<button type="submit" name="submit[update]" class="btn btn-primary"><?=_('Save')?></button> <button type="submit" name="submit[update]" class="btn btn-primary"><?=_('Save')?></button>
<a href="<?=$g_scriptname?>?f=view&id=<?=$id?>" class="btn btn-secondary"><?=_('Back')?></a> <a href="<?=$g_scriptname?>?f=view&id=<?=$id?>" class="btn btn-secondary"><?=_('Back')?></a>
+5 -1
View File
@@ -187,7 +187,11 @@ foreach ($sth->fetchAll() as $row) {
echo '<td>', $row['ddval'],'</td>'; echo '<td>', $row['ddval'],'</td>';
echo '<td>', $row['ddtext'], '</td>'; echo '<td>', $row['ddtext'], '</td>';
echo '<td>', $row['ddshort'], '</td>'; echo '<td>', $row['ddshort'], '</td>';
echo '<td>', $row['color'], '</td>'; if ($row['color']) {
echo '<td>', format_color($row['color']), '</td>';
} else {
echo '<td></td>';
}
echo '<td>', $row['sort'], '</td>'; echo '<td>', $row['sort'], '</td>';
echo "</tr>\n"; echo "</tr>\n";
} }
+17 -4
View File
@@ -208,6 +208,11 @@ require 'header.php';
if ($action == ACT_DEFAULT): if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior ======================================= // ========== VARIANT: default behavior =======================================
$sort = array(
1 => 'ename',
2 => 'ename DESC'
);
$sql = "SELECT eid, ename, manufacturer, model, serial, remarks," $sql = "SELECT eid, ename, manufacturer, model, serial, remarks,"
. " TIMESTAMPDIFF(MONTH, purchdate, NOW()) AS age_mon " . " TIMESTAMPDIFF(MONTH, purchdate, NOW()) AS age_mon "
. "FROM equipment WHERE vid=? " . "FROM equipment WHERE vid=? "
@@ -221,18 +226,26 @@ echo "<h1>$pagetitle</h1>\n";
// Filter // Filter
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div id="filter" class="card"> <div id="filter" class="card">
<div class="card-header">Filter</div> <div class="card-header">Filter</div>
<div class="card-body"> <div class="card-body">
<label>Category</label> <label for="flt_category">Category</label>
<select> <select id="flt_category" name="flt_category">
<?php <?php
foreach ($opt_ecat as $k => $v) { foreach ($opt_ecat as $k => $v) {
echo '<option value="', $k,'">', $v, '</option>'; echo '<option value="', $k,'">', $v, '</option>';
} }
?> ?>
</select> </select>
<label for="flt_manuf">Manufacturer</label>
<select id="flt_category" name="flt_category">
<?php
foreach ($opt_manufacturer as $k => $v) {
echo '<option value="', $k,'">', $v, '</option>';
}
?>
</select>
<button class="btn btn-sm btn-primary" title="<?=_('Apply')?>">Go</button> <button class="btn btn-sm btn-primary" title="<?=_('Apply')?>">Go</button>
</div> </div>
</div> </div>
@@ -292,7 +305,7 @@ elseif ($action == ACT_ADD):
// ========== VARIANT: add record ============================================= // ========== VARIANT: add record =============================================
?> ?>
<h2><?=_('Add Equipment')?></h2> <h2><?=_('Add Equipment')?></h2>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="ename" class="form-label"><?=_('Name')?></label> <label for="ename" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="ename" name="ename"> <input type="text" class="form-control" id="ename" name="ename">
+294
View File
@@ -0,0 +1,294 @@
<?php
/******************************************************************************
* YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge
*
* SPDX-License-Identifier: WTFPL
******************************************************************************/
require 'globals.inc';
$pagetitle=_('Equipment');
$id = gpc_get_int($_REQUEST, 'id', 0);
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
case NULL: break;
case 'add': $action = ACT_ADD; break;
case 'view': $action = ACT_VIEW; break;
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
case 'insert':
break;
case 'update':
$action = ACT_VIEW;
break;
case 'delete':
$action = ACT_DEFAULT;
break;
default:
$g_error->Add("Unbekannte Funktion!");
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
require 'header.php';
// ========== PAGE CONTENT ====================================================
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
echo "<h1>$pagetitle</h1>\n";
$sql = "SELECT eid, ename, make, model, serial, remarks "
. "FROM equipment "
. "ORDER BY eid";
$sth = $pdo->query($sql);
$res = $sth->fetchAll();
echo '<table class="table table-striped">', "\n";
echo "<thead>\n";
echo "<tr>";
echo "<th>" . _('Description') . "</th>";
echo "<th>" . _('Make') . "</th>";
echo "<th>" . _('Model') . "</th>";
echo "<th>" . _('Serial') . "</th>";
echo "<th>" . _('Remarks') . "</th>";
echo "<th>&nbsp;</th>";
echo "</tr>\n";
echo "</thead>\n";
foreach ($res as $row) {
echo "<tr>\n";
echo "<td>". $row['ename'] ."</td>\n";
echo "<td>". $row['make'] ."</td>\n";
echo "<td>". $row['model'] ."</td>\n";
echo "<td>". $row['serial'] ."</td>\n";
echo "<td>". $row['remarks'] ."</td>\n";
// Action buttons
echo "<td>";
echo '<a href="', $g_scriptname, '?f=view&id=', $row['eid'], '">View</a>&nbsp;';
echo '<a href="">Edit</a>';
echo "</td>\n";
echo "</tr>\n";
}
// Table summary
echo "<tfoot>\n";
echo '<tr><td colspan="6">', sprintf(_('%d records'), count($res)), '</td></tr>', "\n";
echo "</tfoot>\n";
echo "</table>\n";
echo '<a href="', $g_scriptname, '?f=add" class="btn btn-info" role="button">', _('Add'), "</a>\n";
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
?>
<h2><?=_('Add Equipment')?></h2>
<form method="post">
<div class="mb-3">
<label for="ename" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="ename" name="ename">
</div>
<div class="mb-3">
<label for="make" class="form-label"><?=_('Make')?></label>
<input type="text" class="form-control" id="make" name="make">
</div>
<div class="mb-3">
<label for="model" class="form-label"><?=_('Model')?></label>
<input type="text" class="form-control" id="model" name="make">
</div>
<div class="mb-3">
<label for="serial" class="form-label"><?=_('Serial')?></label>
<input type="text" class="form-control" id="serial" name="serial">
</div>
<button type="submit" class="btn btn-primary"><?=_('Save')?></button>
<a href="<?=$g_scriptname?>" class="btn btn-secondary"><?=_('Back')?></a>
</form>
<?php
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT eid, ename, make, model, serial, remarks "
. "FROM equipment "
. "WHERE eid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$equipment = $sth->fetch(PDO::FETCH_OBJ);
echo "<h2>", $equipment->ename, "</h2>\n";
// Bootstrap grid
echo '<div class="container">';
echo '<div class="row">';
echo '<div class="col">';
echo "<table>\n";
echo "<tr><td>", _('Make'),"</td><td>", $equipment->make, "</td></tr>\n";
echo "<tr><td>", _('Model'),"</td><td>", $equipment->model, "</td></tr>\n";
echo "<tr><td>", _('Serial'),"</td><td>", $equipment->serial, "</td></tr>\n";
echo "</table>\n";
echo '</div>'; // Column break
echo '<div class="col">';
?>
<p>Images and documents go here</p>
<form id="uploadform" method="post" enctype="multipart/form-data">
<div class="card">
<div class="card-body">
<div id="drop-area" class="border rounded d-flex justify-content-center align-items-center"
style="height: 200px; cursor: pointer;">
<div class="text-center" id="result">
<p>Drag and drop your image here or click to select a file.</p>
</div>
</div>
<input type="file" id="fileElem" multiple accept="image/*" class="d-none" capture="camera">
<input type="submit" name="submit" value="Upload">
</div>
</div>
</form>
<progress id="progress" value="100" max="100" style="display: none;"></progress>
<script>
let dropArea = document.getElementById("drop-area");
["dragenter", "dragover", "dragleave", "drop"].forEach((eventName) => {
dropArea.addEventListener(eventName, preventDefaults, false);
document.body.addEventListener(eventName, preventDefaults, false);
});
["dragenter", "dragover"].forEach((eventName) => {
dropArea.addEventListener(eventName, highlight, false);
});
["dragleave", "drop"].forEach((eventName) => {
dropArea.addEventListener(eventName, unhighlight, false);
});
dropArea.addEventListener("drop", handleDrop, false);
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
function highlight(e) {
dropArea.classList.add("highlight");
}
function unhighlight(e) {
dropArea.classList.remove("highlight");
}
function handleDrop(e) {
let dt = e.dataTransfer;
let files = dt.files;
handleFiles(files);
}
function handleFiles(files) {
[...files].forEach(uploadFile);
}
function uploadFile(file) {
console.log("Uploading", file.name);
const form = document.querySelector("#uploadform");
const formData = new FormData();
formData.append('files[]', file);
fetch("fileupload.php", { method: "POST", body: formData }).then(
(response) => {
console.log(response);
if (response.status === 200) {
document.querySelector("#result").innerHTML = "Dateien wurden geladen";
}
});
}
dropArea.addEventListener("click", () => {
fileElem.click();
});
let fileElem = document.getElementById("fileElem");
fileElem.addEventListener("change", function (e) {
handleFiles(this.files);
});
// Previes
document.querySelector("#files").addEventListener ("change", function (evt) {
let files = event.target.files;
for (let i = 0, f; f = files[i]; i++) {
let reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
let span = document.createElement('span');
span.innerHTML = ['<img class="thumb" src="', e.target.result, '" title="', escape(theFile.name), '"/>'].join('');
document.querySelector ('.filelist').insertBefore(span, null);
};
})(f);
reader.readAsDataURL(f);
}
})
</script>
<?php
echo '</div>'; // col
echo '</div>'; // row
echo '</div>'; // container
// Buttons at bottom of data area
echo '<div class="container">', "\n";
echo '<a href="', $g_scriptname, '?f=edit&id=', $id, '" class="btn btn-info" role="button">', _('Edit'), "</a>\n";
echo '&nbsp;';
echo '<a href="', $g_scriptname, '?f=del&id=', $id, '" class="btn btn-info" role="button">', _('Delete'), "</a>\n";
echo '&nbsp;';
echo '<a href="', $g_scriptname, '" class="btn btn-secondary" role="button">', _('Back'), "</a>\n";
echo "</div>\n";
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT eid, ename, make, model, serial, remarks "
. "FROM equipment "
. "WHERE eid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$equipment = $sth->fetch(PDO::FETCH_OBJ);
?>
<h2><?=_('Edit Equipment')?></h2>
<form method="post">
<div class="mb-3">
<label for="ename" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="ename" name="ename" value="<?=$equipment->ename ?>">
</div>
<div class="mb-3">
<label for="make" class="form-label"><?=_('Make')?></label>
<input type="text" class="form-control" id="make" name="make" value="<?=$equipment->make ?>">
</div>
<div class="mb-3">
<label for="model" class="form-label"><?=_('Model')?></label>
<input type="text" class="form-control" id="model" name="make" value="<?=$equipment->model ?>">
</div>
<div class="mb-3">
<label for="serial" class="form-label"><?=_('Serial')?></label>
<input type="text" class="form-control" id="serial" name="serial" value="<?=$equipment->serial ?>">
</div>
<button type="submit" class="btn btn-primary"><?=_('Save')?></button>
<a href="<?=$g_scriptname?>?f=view&id=<?=$id?>" class="btn btn-secondary"><?=_('Back')?></a>
</form>
<?php
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
else:
// ========== ERROR UNKNOWN VARIANT ===========================================
echo "<p>", _('Unknown function call: Please report to system development!'), "</p>\n";
endif; // $action == ...
// ========== END OF VARIANTS =================================================
include 'footer.php';
+121 -3
View File
@@ -280,8 +280,78 @@ function get_userlist() {
// ========== DATABASE FUNCTIONS ============================================== // ========== DATABASE FUNCTIONS ==============================================
function db_load_enum($table, $column) { function db_exec_insert($table, $params) {
// $params must have keys corresponding to table fields prefixed with ':'
// e.g. $param[':field']
global $pdo;
global $g_error;
$keys = array_keys($params);
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
$pnames = join(',', $keys);
$sth = $pdo->prepare("INSERT INTO $table ($fields) VALUES ($pnames)");
try {
$sth->execute($params);
} catch (PDOexception $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
}
return $pdo->LastInsertId();
}
function db_exec_update($table, $params, $pk) {
global $pdo;
global $g_error;
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($params)));
$sth = $pdo->prepare("UPDATE $table SET $fields WHERE $pk=:$pk");
try {
$sth->execute($params);
} catch (PDOexception $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
return false;
}
return true;
}
function get_enum($enum) {
// Translate and beautify enums
$lookup = array(
'bad' => _('Bad'),
'box' => _('Box'),
'cat' => _('Catamaran'),
'closed' => _('Closed'),
'defect' => _('Defect'),
'done' => _('Done'),
'drawing' => _('Drawng'),
'equipment' => _('Equipment'),
'estimated' => _('Estimated'),
'finished' => _('Finished'),
'fixed' => _('Fixed'),
'generic' => _('Generic'),
'good' => _('Good'),
'invoice' => _('Invoice'),
'locked' => _('Locked'),
'manual' => _('Manual'),
'mono' => _('Monoholl'),
'new' => _('New'),
'normal' => _('Normal'),
'ongoing' => _('Ongoing'),
'open' => _('Open'),
'picture' => _('Picture'),
'planned' => _('Planned'),
'precise' => _('Precise'),
'rough' => _('Rough'),
'storage' => _('Storage'),
'task' => _('Task'),
'tri' => _('Trimaran'),
'unknown' => _('Unknown'),
'vessel' => _('Vessel'),
);
return $lookup[$enum] ?? $enum;
}
function db_load_enum($table, $column, $lookup=false, $as_dict=false) {
// returns array of enum-values as defined in database // returns array of enum-values as defined in database
// if lookup is true the name lookup and translaton is applied
// if as_dict is true the enum value is returned as the array key
global $pdo; global $pdo;
$sql = "SELECT TRIM(TRAILING ')' FROM SUBSTRING(column_type,6)) " $sql = "SELECT TRIM(TRAILING ')' FROM SUBSTRING(column_type,6)) "
. "FROM information_schema.columns " . "FROM information_schema.columns "
@@ -291,7 +361,20 @@ function db_load_enum($table, $column) {
// for PHP < 7.4 // for PHP < 7.4
// return array_map(function($x) { return trim($x, "'"); }, explode(',', $sth->fetchColumn())); // return array_map(function($x) { return trim($x, "'"); }, explode(',', $sth->fetchColumn()));
// for PHP => 7.4 // for PHP => 7.4
return array_map(fn($x) => trim($x, "'"), explode(',', $sth->fetchColumn())); $arr = array_map(fn($x) => trim($x, "'"), explode(',', $sth->fetchColumn()));
if ($lookup) {
if ($as_dict) {
$dict = array();
foreach ($arr as $x) {
$dict[$x] = get_enum($x);
}
return $dict;
} else {
return array_map(fn($x) => get_enum($x), $arr);
}
} else {
return $arr;
}
} }
function db_get_ddtext($ddid, $ddval) { function db_get_ddtext($ddid, $ddval) {
@@ -381,7 +464,25 @@ function db_get_opt_box($vid) {
return $list; return $list;
} }
function db_get_opt_equip($vid) { function db_get_opt_equip($vid, $default=NULL) {
global $pdo;
global $g_error;
if (isset($default)) {
$list = $default;
} else {
$list = array();
}
$sql = "SELECT eid, ename FROM equipment WHERE vid=? ORDER BY ename";
$sth = $pdo->prepare($sql);
try {
$sth->execute([$vid]);
} catch(PDOException $e) {
$g_error->Add($e->getMessage());
}
foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) {
$list[$rec[0]] = $rec[1];
}
return $list;
} }
function db_get_opt_manuf($default=NULL) { function db_get_opt_manuf($default=NULL) {
@@ -504,6 +605,13 @@ function form_view_buttons($script, $id) {
echo "</div>\n"; echo "</div>\n";
} }
function form_new_buttons($script) {
echo '<div class="container-fluid px-0 my-3">', "\n";
echo '<button type="submit" name="submit[insert]" class="btn btn-primary">', _('Save'), "</button>\n";
echo '<a href="', $script, '" class="btn btn-secondary">', _('Back'), "</a>\n";
echo "</div>\n";
}
function form_edit_buttons($script, $id) { function form_edit_buttons($script, $id) {
echo '<div class="container-fluid px-0 my-3">', "\n"; echo '<div class="container-fluid px-0 my-3">', "\n";
echo '<button type="submit" name="submit[update]" class="btn btn-primary">', _('Save'), "</button>\n"; echo '<button type="submit" name="submit[update]" class="btn btn-primary">', _('Save'), "</button>\n";
@@ -660,6 +768,16 @@ function format_currency($val) {
} }
} }
function format_color($color) {
$colstr = '<span style="';
$style = "padding:2px 4px;border-radius:4px;background-color:#".$color;
if (get_color_brightness($color) < 0.4) {
$style .= ';color:white';
}
$colstr .= $style . '">#' . $color . '</span>' ;
return $colstr;
}
function format_filesize($size, $format=2) { function format_filesize($size, $format=2) {
switch ($format) { switch ($format) {
case 1: // short case 1: // short
+18 -5
View File
@@ -78,6 +78,8 @@ switch ($submit = form_get_action()) {
$p[':draught_min'] = gpc_get_float($_POST, 'draught_min'); $p[':draught_min'] = gpc_get_float($_POST, 'draught_min');
$p[':displacement'] = gpc_get_int($_POST, 'displacement'); $p[':displacement'] = gpc_get_int($_POST, 'displacement');
$p[':ballast'] = gpc_get_int($_POST, 'ballast'); $p[':ballast'] = gpc_get_int($_POST, 'ballast');
$p[':beltpos_aft'] = gpc_get_float($_POST, 'beltpos_aft');
$p[':beltpos_bow'] = gpc_get_float($_POST, 'beltpos_bow');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p))); $fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
$sth = $pdo->prepare("UPDATE vessel SET $fields WHERE vid=:vid"); $sth = $pdo->prepare("UPDATE vessel SET $fields WHERE vid=:vid");
@@ -141,7 +143,7 @@ echo "</form>\n";
// Get current vessel data // Get current vessel data
$sql = "SELECT vesselname, model, loa, lwl, beam, draught, draught_min," $sql = "SELECT vesselname, model, loa, lwl, beam, draught, draught_min,"
. " displacement, ballast, remarks " . " displacement, ballast, beltpos_aft, beltpos_bow, remarks "
. "FROM vessel " . "FROM vessel "
. "WHERE vid=?"; . "WHERE vid=?";
$sth = $pdo->prepare($sql); $sth = $pdo->prepare($sql);
@@ -199,11 +201,13 @@ $vessel = $sth->fetch();
<tr><td><?=_('Draught, min.')?></td><td><?=format_float($vessel['draught_min'], 2, 'm')?></td></tr> <tr><td><?=_('Draught, min.')?></td><td><?=format_float($vessel['draught_min'], 2, 'm')?></td></tr>
<tr><td><?=_('Displacement')?></td><td><?=$vessel['displacement']?>&thinsp;kg</td></tr> <tr><td><?=_('Displacement')?></td><td><?=$vessel['displacement']?>&thinsp;kg</td></tr>
<tr><td><?=_('Ballast')?></td><td><?=$vessel['ballast']?>&thinsp;kg</td></tr> <tr><td><?=_('Ballast')?></td><td><?=$vessel['ballast']?>&thinsp;kg</td></tr>
<tr><td><?=_('Belt position aft')?></td><td><?=format_float($vessel['beltpos_aft'], 2, 'm')?></td></tr>
<tr><td><?=_('Belt position bow')?></td><td><?=format_float($vessel['beltpos_bow'], 2, 'm')?></td></tr>
</table> </table>
<?php <?php
// Edit vessel only for captain // Edit vessel only for captain
if ($user->role == 'captain') { if ($user->role == 'captain') {
echo '<a href="', $script, '?f=edit&id=', $user->vid, '" class="btn btn-primary" role="button">', _('Edit'), "</a>\n"; echo '<a href="', $g_scriptname, '?f=edit&id=', $user->vid, '" class="btn btn-primary" role="button">', _('Edit'), "</a>\n";
} }
?> ?>
</div> </div>
@@ -219,7 +223,8 @@ if ($user->role == 'captain') {
// Statistics // Statistics
// Storage: 0 - default, 1 - tank // Storage: 0 - default, 1 - tank
$stype = [ 0 => _('Default'), 1 => _('Tank')]; // $stype = [ 0 => _('Default'), 1 => _('Tank')];
$stype = db_get_options(3);
$sql = "SELECT stype, COUNT(stype) " $sql = "SELECT stype, COUNT(stype) "
. "FROM storage " . "FROM storage "
. "WHERE vid=? " . "WHERE vid=? "
@@ -301,7 +306,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add additional yacht'), "</h2>\n"; echo '<h2>', _('Add additional yacht'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="vesselname" class="form-label"><?=_('Name')?></label> <label for="vesselname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="vesselname" name="vesselname" required autofocus> <input type="text" class="form-control" id="vesselname" name="vesselname" required autofocus>
@@ -326,7 +331,7 @@ elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record ===================================== // ========== VARIANT: edit single record =====================================
$sql = "SELECT vesselname, vtype, model, loa, lwl, beam, draught, draught_min," $sql = "SELECT vesselname, vtype, model, loa, lwl, beam, draught, draught_min,"
. " displacement, ballast, remarks " . " displacement, ballast, beltpos_aft, beltpos_bow, remarks "
. "FROM vessel " . "FROM vessel "
. "WHERE vid=?"; . "WHERE vid=?";
$sth = $pdo->prepare($sql); $sth = $pdo->prepare($sql);
@@ -372,6 +377,14 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
<label for="ballast" class="form-label"><?=_('Ballast')?></label> <label for="ballast" class="form-label"><?=_('Ballast')?></label>
<input type="number" input-mode="decimal" min="0" max="100000" step="1" class="form-control" id="ballast" name="ballast" value="<?=$vessel->ballast ?>"> <input type="number" input-mode="decimal" min="0" max="100000" step="1" class="form-control" id="ballast" name="ballast" value="<?=$vessel->ballast ?>">
</div> </div>
<div class="mb-3">
<label for="beltpos_aft" class="form-label"><?=_('Belt position aft')?></label>
<input type="text" class="form-control" id="beltpos_aft" name="beltpos_aft" value="<?=format_float($vessel->beltpos_aft, 2) ?>">
</div>
<div class="mb-3">
<label for="beltpos_bow" class="form-label"><?=_('Belt position bow')?></label>
<input type="text" class="form-control" id="beltpos_bow" name="beltpos_bow" value="<?=format_float($vessel->beltpos_bow, 2) ?>">
</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"><?=$vessel->remarks ?></textarea> <textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$vessel->remarks ?></textarea>
+20 -59
View File
@@ -26,67 +26,28 @@ switch ($submit = form_get_action()) {
case 'del': $action = ACT_DELETE; break; case 'del': $action = ACT_DELETE; break;
case 'insert': case 'insert':
$invname = gpc_get_string($_POST, 'invname'); $p[':invname'] = gpc_get_string($_POST, 'invname');
$number = gpc_get_int($_POST, 'number'); $p[':number'] = gpc_get_int($_POST, 'number');
$boxtype = gpc_get_string($_POST, 'boxtype'); $p[':boxtype'] = gpc_get_string($_POST, 'boxtype');
$sid = gpc_get_int($_POST, 'sid'); $p[':sid'] = gpc_get_int($_POST, 'sid');
$boxid = gpc_get_int($_POST, 'boxid'); $p[':boxid'] = gpc_get_int($_POST, 'boxid');
$sql = "INSERT INTO inventory " $p[':invcond'] = 'good';
. " (invname, invcond, number, boxtype, sid, boxid) " $id = db_exec_insert('inventory', $p);
. "VALUES "
. " (:invname, 'good', :number, :boxtype, :sid, :boxid)";
$sth = $pdo->prepare($sql);
$sth->bindValue(':invname', $invname, PDO::PARAM_STR);
$sth->bindValue(':number', $number, PDO::PARAM_INT);
$sth->bindValue(':boxtype', $boxtype, PDO::PARAM_STR);
$sth->bindValue(':sid', $sid, PDO::PARAM_INT);
$sth->bindValue(':boxid', $boxid, PDO::PARAM_INT);
try {
$sth->execute();
} catch (PDOException $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
}
$id = $pdo->LastInsertId();
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
case 'update': case 'update':
$invname = gpc_get_string($_POST, 'invname'); $p[':invid'] = $id;
$number = gpc_get_int($_POST, 'number'); $p[':invname'] = gpc_get_string($_POST, 'invname');
$boxtype = gpc_get_string($_POST, 'boxtype'); $p[':number'] = gpc_get_int($_POST, 'number');
$sid = gpc_get_int($_POST, 'sid'); $p[':boxtype'] = gpc_get_string($_POST, 'boxtype');
$boxid = gpc_get_int($_POST, 'boxid'); $p[':sid'] = gpc_get_int($_POST, 'sid');
$weight = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value $p[':boxid'] = gpc_get_int($_POST, 'boxid');
$price = gpc_get_currency($_POST, 'price'); $p[':weight'] = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value
$purchdate = gpc_get_date($_POST, 'purchdate'); $p[':price'] = gpc_get_currency($_POST, 'price');
$invcond = gpc_get_string($_POST, 'invcond'); $p[':purchdate'] = gpc_get_date($_POST, 'purchdate');
$sql = "UPDATE inventory " $p[':invcond'] = gpc_get_string($_POST, 'invcond');
. "SET invname=:invname," db_exec_update('inventory', $p, 'invid');
. " number=:number,"
. " boxtype=:boxtype,"
. " sid=:sid,"
. " boxid=:boxid,"
. " weight=:weight,"
. " price=:price,"
. " purchdate=:purchdate,"
. " invcond=:invcond "
. "WHERE invid=:invid";
$sth = $pdo->prepare($sql);
$sth->bindValue(':invid', $id, PDO::PARAM_INT);
$sth->bindValue(':invname', $invname, PDO::PARAM_STR);
$sth->bindValue(':number', $number, PDO::PARAM_INT);
$sth->bindValue(':boxtype', $boxtype, PDO::PARAM_STR);
$sth->bindValue(':sid', $sid, PDO::PARAM_INT);
$sth->bindValue(':boxid', $boxid, PDO::PARAM_INT);
$sth->bindValue(':weight', $weight);
$sth->bindValue(':price', $price);
$sth->bindValue(':purchdate', $purchdate);
$sth->bindValue(':invcond', $invcond, PDO::PARAM_STR);
try {
$sth->execute();
} catch (PDOException $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
}
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
@@ -287,8 +248,8 @@ $inventory = $sth->fetch(PDO::FETCH_OBJ);
</select> </select>
</div> </div>
<?php <?php
form_create_select('sid', _('Storage'), $opt_storage); form_create_select('sid', _('Storage'), $opt_storage, $inventory->sid);
form_create_select('boxid', _('Box'), $opt_box); form_create_select('boxid', _('Box'), $opt_box, $inventory->boxid);
?> ?>
<div class="mb-3"> <div class="mb-3">
<label for="price" class="form-label"><?=sprintf(_('Price, %s'), $g_lconv['currency_symbol']); ?></label> <label for="price" class="form-label"><?=sprintf(_('Price, %s'), $g_lconv['currency_symbol']); ?></label>
+14 -47
View File
@@ -11,14 +11,7 @@ $pagetitle = _('Maintenance');
$id = gpc_get_int($_REQUEST, 'id', 0); $id = gpc_get_int($_REQUEST, 'id', 0);
// Equipment options $opt_equipment = db_get_opt_equip($user->vid, [0 => _('*** unassigned ***')]);
$opt_equipment = array( 0 => _('*** unassigned ***'));
$sql = "SELECT eid, ename FROM equipment WHERE vid=? ORDER BY ename";
$sth = $pdo->prepare($sql);
$sth->execute([$user->vid]);
foreach ($sth->fetchAll() as $row) {
$opt_equipment[$row['eid']] = $row['ename'];
}
// ========== ACTIONS START =================================================== // ========== ACTIONS START ===================================================
@@ -32,39 +25,25 @@ switch ($submit = form_get_action()) {
case 'del': $action = ACT_DELETE; break; case 'del': $action = ACT_DELETE; break;
case 'insert': case 'insert':
$eid = gpc_get_int($_POST, 'eid'); $p[':vid'] = $user->vid;
$activities = gpc_get_string($_POST, 'activities', 80); $p[':eid'] = gpc_get_int($_POST, 'eid');
$sql = "INSERT INTO maintenance " $p[':activities'] = gpc_get_string($_POST, 'activities', 80);
. " (vid, eid, activities) " $id = db_exec_insert('maintenance', $p);
. "VALUES "
. " (:vid, :eid, :activities)";
$sth = $pdo->prepare($sql);
$sth->bindValue(':vid', $user->vid, PDO::PARAM_INT);
$sth->bindValue(':eid', $eid, PDO::PARAM_INT);
$sth->bindValue(':activities', $activities, PDO::PARAM_STR);
$sth->execute();
$id = $pdo->LastInsertId();
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
case 'update': case 'update':
$eid = gpc_get_int($_POST, 'eid'); $p[':maintid'] = $id;
$activities = gpc_get_string($_POST, 'activities', 80); $p[':eid'] = gpc_get_int($_POST, 'eid');
$remarks = gpc_get_string($_POST, 'remarks', 150); $p[':activities'] = gpc_get_string($_POST, 'activities', 80);
$sql = "UPDATE maintenance " $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
. "SET activities=:activities," db_exec_update('maintenance', $p, 'maintid');
. " eid=:eid,"
. " remarks=:remarks "
. "WHERE maintid=:maintid";
$sth = $pdo->prepare($sql);
$sth->bindValue(':maintid', $id, PDO::PARAM_INT);
$sth->bindValue(':eid', $eid, PDO::PARAM_INT);
$sth->bindValue(':activities', $activities, PDO::PARAM_STR);
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
$sth->execute();
$action = ACT_VIEW; $action = ACT_VIEW;
break; break;
case 'delete':
break;
default: default:
$g_error->Add(sprintf(_("Unknown function '%s'!"), $submit)); $g_error->Add(sprintf(_("Unknown function '%s'!"), $submit));
$valid = FALSE; $valid = FALSE;
@@ -218,19 +197,7 @@ echo '<h2>', _('Edit Maintenance'), "</h2>\n";
<label for="activities" class="form-label"><?=_('Activities')?></label> <label for="activities" class="form-label"><?=_('Activities')?></label>
<input type="text" class="form-control" id="activities" name="activities" value="<?=$maint->activities ?>"> <input type="text" class="form-control" id="activities" name="activities" value="<?=$maint->activities ?>">
</div> </div>
<div class="mb-3"> <?php form_create_select('eid', _('Equipment'), $opt_equipment, $maint->eid); ?>
<label for="eid" class="form-label"><?=_('Equipment')?></label>
<select name="eid" id="eid" class="form-control">
<?php
foreach ($opt_equipment as $k => $v) {
echo '<option value="', $k;
if ($maint->eid == $k) {
echo ' selected';
}
echo '">', $v, "</option>\n";
}
?>
</select>
<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"><?=$maint->remarks ?></textarea> <textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$maint->remarks ?></textarea>
+1 -1
View File
@@ -99,7 +99,7 @@ zu erfassen.</p>
<h3>Stammdaten</h3> <h3>Stammdaten</h3>
<p>Diese Daten ändern sich nicht sehr häufig, sind aber für den Betrieb <p>Diese Daten ändern sich nicht sehr häufig, sind aber für den Betrieb
essentiell. Stanndaten sind beispielsweise Firmen, Auswahllisten oder essentiell. Stammdaten sind beispielsweise Firmen, Auswahllisten oder
auch der Stauraum.</p> auch der Stauraum.</p>
<?php <?php
+2 -2
View File
@@ -186,7 +186,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add measurement'), "</h2>\n"; echo '<h2>', _('Add measurement'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="mname" class="form-label"><?=_('Name')?></label> <label for="mname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="mname" name="mname" required autofocus> <input type="text" class="form-control" id="mname" name="mname" required autofocus>
@@ -237,7 +237,7 @@ $measurement = $sth->fetch(PDO::FETCH_OBJ);
echo '<h2>', _('Edit measurement'), "</h2>\n"; echo '<h2>', _('Edit measurement'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>"> <input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3"> <div class="mb-3">
<label for="mname" class="form-label"><?=_('Name')?></label> <label for="mname" class="form-label"><?=_('Name')?></label>
+2 -2
View File
@@ -136,7 +136,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add provisions'), "</h2>\n"; echo '<h2>', _('Add provisions'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="provname" class="form-label"><?=_('Name')?></label> <label for="provname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="provname" name="provname" required autofocus> <input type="text" class="form-control" id="provname" name="provname" required autofocus>
@@ -196,7 +196,7 @@ $prov = $sth->fetch(PDO::FETCH_OBJ);
echo '<h2>', _('Edit provision'), "</h2>\n"; echo '<h2>', _('Edit provision'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>"> <input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3"> <div class="mb-3">
<label for="provname" class="form-label"><?=_('Name')?></label> <label for="provname" class="form-label"><?=_('Name')?></label>
+1 -1
View File
@@ -19,7 +19,7 @@ echo "<h1>$pagetitle</h1>\n";
<p>Search will be implemented later. <p>Search will be implemented later.
This page is currently just a placeholder.</p> This page is currently just a placeholder.</p>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div> <div>
<label for="needle">Suche nach:</label> <label for="needle">Suche nach:</label>
<input type="text" id="needle" name="needle" value="<?=$needle?>" autofocus> <input type="text" id="needle" name="needle" value="<?=$needle?>" autofocus>
+1 -1
View File
@@ -178,7 +178,7 @@ echo '<h2>', _('Add Storage'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<div class="mb-3"> <div class="mb-3">
<label for="sname" class="form-label"><?=_('Name')?></label> <label for="sname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="sname" name="sname"> <input type="text" class="form-control" id="sname" name="sname">
+2 -2
View File
@@ -117,7 +117,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add Task'), "</h2>\n"; echo '<h2>', _('Add Task'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<?php <?php
// preselect project if parameter is set // preselect project if parameter is set
$projid = gpc_get_int($_REQUEST, 'projid'); $projid = gpc_get_int($_REQUEST, 'projid');
@@ -165,7 +165,7 @@ $task = $sth->fetch(PDO::FETCH_OBJ);
echo '<h2>', _('Edit Task'), "</h2>\n"; echo '<h2>', _('Edit Task'), "</h2>\n";
?> ?>
<form method="post"> <form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>"> <input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3"> <div class="mb-3">
<label for="taskname" class="form-label"><?=_('Name')?></label> <label for="taskname" class="form-label"><?=_('Name')?></label>