Work on webgui and add flags to equipment

This commit is contained in:
2025-07-01 10:48:39 +02:00
parent 1f2af40943
commit d5d754d596
6 changed files with 58 additions and 17 deletions
+1
View File
@@ -137,6 +137,7 @@ CREATE TABLE equipment (
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,
flags set('ordered','deleted') DEFAULT NULL,
PRIMARY KEY(eid) PRIMARY KEY(eid)
); );
+26 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
/****************************************************************************** /******************************************************************************
* YMS - Yacht Management Software * YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge * Copyright (C) 2024-2025 Thomas Hooge
* *
* SPDX-License-Identifier: WTFPL * SPDX-License-Identifier: WTFPL
******************************************************************************/ ******************************************************************************/
@@ -607,7 +607,31 @@ foreach ($opt_company as $k => $v) {
</form> </form>
<?php <?php
// Vessel options
// Do not include vessel that has already been referenced in the list!
$opt_vessel = array();
$sql = "SELECT vid, vesselname FROM vessel ORDER BY vesselname";
$sth = $pdo->query($sql);
foreach ($sth->fetchAll() as $row) {
if (!in_array($row['vid'], $vids)) {
$opt_vessel[$row['vid']] = $row['vesselname'];
}
}
?>
<form class="mb-3" method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>">
<input type="hidden" name="reftype" value="vessel">
<label for="vid"><?=_('Vessel')?></label>
<select name="refid" id="vid">
<?php
foreach ($opt_vessel as $k => $v) {
echo '<option value="', $k, '">', $v, "</option>\n";
}
?>
</select>
<button class="btn btn-sm btn-secondary" name="submit[addref]">Referenzieren</button>
</form>
<?php
elseif ($action == ACT_EDIT): elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record ===================================== // ========== VARIANT: edit single record =====================================
+10 -6
View File
@@ -1,7 +1,7 @@
<?php <?php
/****************************************************************************** /******************************************************************************
* YMS - Yacht Management Software * YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge * Copyright (C) 2024, 2025 Thomas Hooge
* *
* SPDX-License-Identifier: WTFPL * SPDX-License-Identifier: WTFPL
******************************************************************************/ ******************************************************************************/
@@ -195,19 +195,23 @@ $sort = array(
$w = array('vid=:vid'); $w = array('vid=:vid');
$p = array(':vid' => $user->vid); $p = array(':vid' => $user->vid);
if ($flt->cat == -1) { if ($flt->cat > 0) {
$w[] = 'ecat IS NULL';
} elseif ($flt->cat > 0) {
$w[] = 'ecat=:ecat'; $w[] = 'ecat=:ecat';
$p[':ecat'] = $flt->cat; $p[':ecat'] = $flt->cat;
} elseif ($flt->cat == -1) {
$w[] = 'ecat IS NULL';
} }
if ($flt->manuf > 0) { if ($flt->manuf > 0) {
$w[] = 'manufacturer=:manuf'; $w[] = 'manufacturer=:manuf';
$p[':manuf'] = $flt->manuf; $p[':manuf'] = $flt->manuf;
} elseif ($flt->manuf == -1) {
$w[] = 'manufacturer IS NULL';
} }
if ($flt->supp > 0) { if ($flt->supp > 0) {
$w[] = 'supplier=:supp'; $w[] = 'supplier=:supp';
$p[':supp'] = $flt->supp; $p[':supp'] = $flt->supp;
} elseif ($flt->supp == -1) {
$w[] = 'supplier IS NULL';
} }
if (strlen($flt->txt) > 1) { if (strlen($flt->txt) > 1) {
$w[] = '(ename LIKE :txt OR model LIKE :txt OR remarks LIKE :txt)'; $w[] = '(ename LIKE :txt OR model LIKE :txt OR remarks LIKE :txt)';
@@ -216,7 +220,7 @@ if (strlen($flt->txt) > 1) {
$where = join(' AND ', $w); $where = join(' AND ', $w);
$order = ' ORDER BY ename'; $order = ' ORDER BY ename';
// get total recond count for pagination and limit // get total record count for pagination and limit
$sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE " . $where); $sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE " . $where);
try { try {
$sth->execute($p); $sth->execute($p);
@@ -379,7 +383,7 @@ echo '<div class="col">';
<?php <?php
$sql = "SELECT d.docid, d.doctype, d.title " $sql = "SELECT d.docid, d.doctype, d.title "
. "FROM docref AS r INNER JOIN document AS d using (docid) " . "FROM docref AS r INNER JOIN document AS d using (docid) "
. "WHERE r.refid=? " . "WHERE r.reftype='equipment' AND r.refid=? "
. "ORDER BY d.doctype"; . "ORDER BY d.doctype";
$sth = $pdo->prepare($sql); $sth = $pdo->prepare($sql);
$sth->execute([$id]); $sth->execute([$id]);
+13 -7
View File
@@ -310,21 +310,21 @@ $sth = $pdo->prepare($sql);
$sth->execute([$vid]); $sth->execute([$vid]);
$res = $sth->fetchAll(PDO::FETCH_NUM); $res = $sth->fetchAll(PDO::FETCH_NUM);
echo '<table class="table table-sm">', "\n"; echo '<table class="table table-sm">', "\n";
echo '<tr><td colspan="2">', _('Storage type') , "</td>"; echo '<tr><td colspan="3">', _('Storage type') , "</td>";
foreach ($res as $row) { foreach ($res as $row) {
echo "<tr><td>", $stype[$row[0]], "</td><td>", $row[1], "</td></tr>\n"; echo "<tr><td>&nbsp;</td><td>", $stype[$row[0]], "</td><td>", $row[1], "</td></tr>\n";
} }
// Boxes // Boxes
$sth = $pdo->prepare("SELECT COUNT(*) FROM box INNER JOIN storage USING (sid) WHERE vid=?"); $sth = $pdo->prepare("SELECT COUNT(*) FROM box INNER JOIN storage USING (sid) WHERE vid=?");
$sth->execute([$user->vid]); $sth->execute([$user->vid]);
echo '<tr><td>', _('Boxes'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n"; echo '<tr><td>&nbsp;</td><td>', _('Boxes'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n";
// Equipment // Equipment
$sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE vid=?"); $sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE vid=?");
$sth->execute([$user->vid]); $sth->execute([$user->vid]);
echo '<tr><td colspan="2">', _('Equipment') , "</td>"; echo '<tr><td colspan="3">', _('Equipment') , "</td>";
echo '<tr><td>', _('Count'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n"; echo '<tr><td>&nbsp;</td><td>', _('Count'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n";
// Inventory // Inventory
// All items from vessel storage and all items from boxes in vessel storage // All items from vessel storage and all items from boxes in vessel storage
@@ -337,8 +337,14 @@ $sth = $pdo->prepare($sql);
$sth->bindValue(':vid', $user->vid, PDO::PARAM_INT); $sth->bindValue(':vid', $user->vid, PDO::PARAM_INT);
$sth->execute(); $sth->execute();
echo '<tr><td colspan="2">', _('Inventory') , "</td>"; echo '<tr><td colspan="3">', _('Inventory') , "</td>";
echo '<tr><td>', _('Count'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n"; echo '<tr><td>&nbsp;</td><td>', _('Count'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n";
// Documents
$sth = $pdo->query("SELECT COUNT(*) FROM document");
echo '<tr><td colspan="3">', _('Documents') , "</td>";
echo '<tr><td>&nbsp;</td><td>', _('Count'), '</td><td>', $sth->fetchColumn(), "</td></tr>\n";
echo "</table>\n"; echo "</table>\n";
+6 -2
View File
@@ -85,7 +85,7 @@ if ($action == ACT_DEFAULT):
page_caption_search($pagetitle); page_caption_search($pagetitle);
$sql = "SELECT projid, projname, startdate, duration, remarks " $sql = "SELECT projid, projname, startdate, duration, projstate, remarks "
. "FROM project " . "FROM project "
. "WHERE vid=? " . "WHERE vid=? "
. "ORDER BY projid"; . "ORDER BY projid";
@@ -98,6 +98,7 @@ echo "<tr>";
echo "<th>" . _('Name') . "</th>"; echo "<th>" . _('Name') . "</th>";
echo "<th>" . _('Start date') . "</th>"; echo "<th>" . _('Start date') . "</th>";
echo "<th>" . _('Duration') . "</th>"; echo "<th>" . _('Duration') . "</th>";
echo "<th>" . _('State') . "</th>";
echo "<th>" . _('Remarks') . "</th>"; echo "<th>" . _('Remarks') . "</th>";
echo "<th>&nbsp;</th>"; echo "<th>&nbsp;</th>";
echo "</tr>\n"; echo "</tr>\n";
@@ -107,6 +108,7 @@ foreach ($res as $row) {
echo "<td>". $row['projname'] ."</td>\n"; echo "<td>". $row['projname'] ."</td>\n";
echo "<td>". $row['startdate'] ."</td>\n"; echo "<td>". $row['startdate'] ."</td>\n";
echo "<td>". $row['duration'] ."</td>\n"; echo "<td>". $row['duration'] ."</td>\n";
echo "<td>". $row['projstate'] ."</td>\n";
echo "<td>". $row['remarks'] ."</td>\n"; echo "<td>". $row['remarks'] ."</td>\n";
// Action buttons // Action buttons
form_action_buttons($g_scriptname, $row['projid']); form_action_buttons($g_scriptname, $row['projid']);
@@ -121,7 +123,7 @@ form_add_button($g_scriptname);
echo "<h1>", _('Generic Tasks'), "</h1>\n"; echo "<h1>", _('Generic Tasks'), "</h1>\n";
echo "<p>", _('Tasks not assigned to any project'), "</p>\n"; echo "<p>", _('Tasks not assigned to any project'), "</p>\n";
$sql = "SELECT taskid, taskname " $sql = "SELECT taskid, taskname, taskstate "
. "FROM task " . "FROM task "
. "WHERE vid=? AND projid IS NULL " . "WHERE vid=? AND projid IS NULL "
. "ORDER BY taskid"; . "ORDER BY taskid";
@@ -132,11 +134,13 @@ echo '<table class="table table-striped">', "\n";
echo "<thead>\n"; echo "<thead>\n";
echo "<tr>"; echo "<tr>";
echo "<th>" . _('Name') . "</th>"; echo "<th>" . _('Name') . "</th>";
echo "<th>" . _('State') . "</th>";
echo "</tr>\n"; echo "</tr>\n";
echo "</thead>\n"; echo "</thead>\n";
foreach ($res as $row) { foreach ($res as $row) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td>". $row['taskname'] ."</td>\n"; echo "<td>". $row['taskname'] ."</td>\n";
echo "<td>". $row['taskstate'] ."</td>\n";
form_action_buttons('task.php', $row['taskid']); form_action_buttons('task.php', $row['taskid']);
echo "</tr>\n"; echo "</tr>\n";
} }
+2
View File
@@ -14,6 +14,8 @@ $needle = gpc_get_string($_REQUEST, 'needle', 40);
require 'header.php'; require 'header.php';
echo "<h1>$pagetitle</h1>\n"; echo "<h1>$pagetitle</h1>\n";
?> ?>
<form method="post" action="<?=$g_scriptname?>"> <form method="post" action="<?=$g_scriptname?>">