Webgui: More mobile friendly touch and much more improvements

This commit is contained in:
2026-06-14 10:56:17 +02:00
parent a59f02e21b
commit f109e2621f
25 changed files with 1624 additions and 583 deletions
+94 -26
View File
@@ -19,6 +19,18 @@ foreach ($sth->fetchAll() as $row) {
}
$opt_state = db_load_enum('project', 'projstate', true, true);
/* Nur für choices benötigt
$local_script = "
document.addEventListener('DOMContentLoaded', function () {
const element = document.getElementById('flt_state[]');
const choices = new Choices(element, {
removeItemButton: true,
duplicateItemsAllowed: false,
searchEnabled: false
});
});
"; */
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
@@ -33,7 +45,7 @@ switch ($submit = form_get_action()) {
case 'filter':
$flt = array();
$flt['name'] = gpc_get_string($_POST, 'flt_name');
$flt['state'] = gpc_get_string($_POST, 'flt_state');
$flt['state'] = $_POST['flt_state']; // Array! gpc_get_string($_POST, 'flt_state');
$flt['remarks'] = gpc_get_string($_POST, 'flt_remarks');
db_save_filter($flt, 205);
$action = ACT_DEFAULT;
@@ -95,45 +107,79 @@ page_caption_search($pagetitle);
// load filter from db
$flt = db_get_filter($user->id, 205);
$w = array();
$p = array();
// name, status, text
$w = array('vid=:vid');
$p = array(':vid' => $user->vid);
if (strlen($flt->txt) > 1) {
$w[] = '(projname LIKE :txt OR remarks LIKE :txt)';
$p[':txt'] = '%'.$flt->txt.'%';
}
$where = join(' AND ', $w);
$order = ' ORDER BY comptype, compname';
$order = ' ORDER BY projname';
// grand total of records for current vessel
$grandtotal = $pdo->query("SELECT COUNT(*) FROM project")->fetchColumn();
$sth = $pdo->prepare("SELECT COUNT(*) FROM project WHERE " . $where);
try {
$sth->execute($p);
} catch(PDOException $e) {
$g_error->Add($e->getMessage());
$g_error->Add($sql);
$g_error->Add(print_r($p, true));
$g_error->PrintOut();
}
$numrows = $sth->fetchColumn();
$page = gpc_get_int($_REQUEST, 'p', 1);
$rows_pp = gpc_get_int($_REQUEST, 'n', $g_rows_pp);
$lastpage = ceil($numrows/$rows_pp);
// $grandtotal = $pdo->query("SELECT COUNT(*) FROM project WHERE " . $where)->fetchColumn();
$sql = "SELECT projid, projname, startdate, duration, projstate, remarks "
. "FROM project";
$sql .= " WHERE " . $where;
$sql .= $order;
// if pagination:
$sql .= ' LIMIT ' . ($page - 1) * $g_rows_pp . ',' . $g_rows_pp;
$sth = $pdo->prepare($sql);
$sth->execute($p);
$res = $sth->fetchAll();
// Filter
?>
<form method="post" action="<?=$g_scriptname?>">
<form id="filterform" method="post" action="<?=$g_scriptname?>">
<div id="filter" class="card">
<div class="card-header">Filter</div>
<div class="card-body">
<label for="flt_name">Name</label>
<input type="text" name="flt_name" size="15" maxlength="30" value="<?=$flt->name;?>">
<div class="card-header"><i class="bi bi-funnel me-2"></i>Filter</div>
<div class="card-body d-flex flex-wrap gap-3">
<div class="d-flex flex-nowrap gap-2">
<label for="flt_name">Name</label>
<input type="text" name="flt_name" size="15" maxlength="30" value="<?=$flt->name;?>">
</div>
<?php
filter_create_select('flt_state', _('State'), $g_opt_all + $opt_state, $flt->state);
filter_create_select('flt_state[]', _('State'), $g_opt_all + $opt_state, $flt->state, FALSE);
?>
<label for="flt_remarks">Text</label>
<input type="text" name="flt_remarks" size="15" maxlength="30" value="<?=$flt->remarks?>">
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
<button name="submit[freset]" class="btn btn-sm btn-secondary float-end" title="<?=_('Reset filter to defaults')?>"><?=_('Clear')?></button>
<div class="d-flex flex-nowrap gap-2">
<label for="flt_remarks">Text</label>
<input type="text" name="flt_remarks" size="15" maxlength="30" value="<?=$flt->remarks ?>">
</div>
</div>
<div class="card-footer">
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
<button name="submit[freset]" class="btn btn-sm btn-secondary float-end" title="<?=_('Reset filter to defaults')?>"><?=_('Clear')?></button>
</div>
</div>
</form>
<?php
$sql = "SELECT projid, projname, startdate, duration, projstate, remarks "
. "FROM project "
. "WHERE vid=? "
. "ORDER BY projid";
$sth = $pdo->prepare($sql);
$sth->execute([$user->vid]);
$res = $sth->fetchAll();
echo '<table class="table table-striped">'. "\n";
echo "<thead>\n";
echo "<tr>";
echo '<th>#</th>';
echo "<th>" . _('Name') . "</th>";
echo "<th>" . _('Start date') . "</th>";
echo "<th>" . _('Duration') . "</th>";
@@ -142,15 +188,24 @@ echo "<th>" . _('Remarks') . "</th>";
echo "<th>&nbsp;</th>";
echo "</tr>\n";
echo "</thead>\n";
$i = ($page - 1) * $rows_pp;
$i0 = $i + 1;
foreach ($res as $row) {
$i++; // record number
echo "<tr>\n";
echo '<td>', $i;
echo '<a class="text-nowrap" title="', _('View'), '" href="', $g_scriptname, '?f=view&id=', $row['projid'], '"><i class="bi bi-eye ms-2"></i></a>', "\n";
echo "</td>\n";
echo "<td>". $row['projname'] ."</td>\n";
echo "<td>". $row['startdate'] ."</td>\n";
echo "<td>". $row['duration'] ."</td>\n";
echo "<td>". $row['projstate'] ."</td>\n";
echo "<td>". $row['remarks'] ."</td>\n";
// Action buttons
form_action_buttons($g_scriptname, $row['projid']);
// Edit current record button
echo "<td>";
echo '<a title="', _('Edit'), '" href="', $g_scriptname, '?f=edit&id=', $row['projid'], '"><i class="bi-pencil"></i></a>', "\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tfoot>\n";
@@ -172,15 +227,28 @@ $res = $sth->fetchAll();
echo '<table class="table table-striped">', "\n";
echo "<thead>\n";
echo "<tr>";
echo '<th>#</th>';
echo "<th>" . _('Name') . "</th>";
echo "<th>" . _('State') . "</th>";
echo "</tr>\n";
echo "</thead>\n";
// TODO own pagination
// $i = ($page - 1) * $rows_pp;
$i = 0;
$i0 = $i + 1;
foreach ($res as $row) {
$i++; // record number
echo "<tr>\n";
echo '<td>', $i;
echo '<a class="text-nowrap" title="', _('View'), '" href="task.php?f=view&id=', $row['taskid'], '"><i class="bi bi-eye ms-2"></i></a>', "\n";
echo "</td>\n";
echo "<td>". $row['taskname'] ."</td>\n";
echo "<td>". $row['taskstate'] ."</td>\n";
form_action_buttons('task.php', $row['taskid']);
// Edit current record button
echo "<td>";
echo '<a title="', _('Edit'), '" href="task.php?f=edit&id=', $row['taskid'], '"><i class="bi-pencil"></i></a>', "\n";
echo "</td>\n";
echo "</tr>\n";
}
// Table summary
@@ -230,7 +298,7 @@ echo '<tr><th scope="row">', _('Responsible'),"</th><td>", $opt_user[$project->r
echo '<tr><th scope="row">', _('Start date'),"</th><td>", $project->startdate, "</td></tr>\n";
echo '<tr><th scope="row">', _('Duration'),"</th><td>", $project->duration, "</td></tr>\n";
echo '<tr><th scope="row">', _('State'),"</th><td>", $project->projstate, "</td></tr>\n";
echo '<tr><th scope="row">', _('Remarks'),"</th><td>", $project->remarks, "</td></tr>\n";
echo '<tr><th scope="row">', _('Remarks'),"</th><td>", nl2br($project->remarks), "</td></tr>\n";
echo "</table>\n";
form_view_buttons($g_scriptname, $id);