More improvements e.g. flags and provision target

This commit is contained in:
2026-08-11 07:48:46 +02:00
parent a3d4825cbd
commit 41556cfe73
22 changed files with 961 additions and 484 deletions
+35 -13
View File
@@ -39,6 +39,11 @@ define ('ACT_UNLINK', 11);
define ('ACT_MAIL', 12);
define ('ACT_VIEW_LIST', 13);
define('ROLE_VESSEL', 'vessel');
define('ROLE_CAPTAIN', 'captain');
define('ROLE_HELMSMAN', 'helmsman');
define('ROLE_SAILOR', 'sailor');
// ========== PAGE START CODE =================================================
// global version string
@@ -396,8 +401,8 @@ function db_exec_insert($table, $params) {
global $pdo;
global $g_error;
$keys = array_keys($params);
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
$pnames = join(',', $keys);
$fields = join(', ', array_map(function($s) { return ltrim($s, ':'); }, $keys));
$pnames = join(', ', $keys);
$sql = "INSERT INTO $table ($fields) VALUES ($pnames)";
// $sth = $pdo->prepare("INSERT INTO $table ($fields) VALUES ($pnames)");
$sth = $pdo->prepare($sql);
@@ -433,7 +438,7 @@ function db_exec_update($table, $params, $pk) {
unset($fields[':'.$pk]);
$where = "$pk=:$pk";
}
$fieldlist = join(',', array_map(fn($s) => ltrim($s, ':') . '=' . $s, array_keys($fields)));
$fieldlist = join(', ', array_map(fn($s) => ltrim($s, ':') . '=' . $s, array_keys($fields)));
$sql = "UPDATE $table SET $fieldlist WHERE $where";
$sth = $pdo->prepare($sql);
try {
@@ -526,12 +531,15 @@ function get_enum($enum) {
'drawing' => _('Drawing'),
'equipment' => _('Equipment'),
'estimated' => _('Estimated'),
'excellent' => _('Excellent'),
'fair' => _('Fair'),
'finished' => _('Finished'),
'fixed' => _('Fixed'),
'fuse' => _('Fuse'),
'generic' => _('Generic'),
'good' => _('Good'),
'high' => _('High'),
'historic' => _('Historic'),
'invoice' => _('Invoice'),
'locked' => _('Locked'),
'low' => _('Low'),
@@ -806,7 +814,7 @@ function db_get_opt_storage($vid) {
return $list;
}
function db_get_opt_box($vid) {
function db_get_opt_box($vid, $exclude=[]) {
global $pdo;
global $g_error;
$list = array();
@@ -821,12 +829,14 @@ function db_get_opt_box($vid) {
$g_error->Add($e->getMessage());
}
foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) {
$list[$rec[0]] = $rec[1] . ' - '. $rec[2];
if (! in_array($rec[0], $exclude)) {
$list[$rec[0]] = $rec[1] . ($rec[2] ? ' - '. $rec[2] : '');
}
}
return $list;
}
function db_get_opt_equip($vid, $default=NULL) {
function db_get_opt_equip($vid, $default=NULL, $exclude=[]) {
global $pdo;
global $g_error;
if (isset($default)) {
@@ -842,7 +852,9 @@ function db_get_opt_equip($vid, $default=NULL) {
$g_error->Add($e->getMessage());
}
foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) {
$list[$rec[0]] = $rec[1];
if (! in_array($rec[0], $exclude)) {
$list[$rec[0]] = $rec[1];
}
}
return $list;
}
@@ -1050,11 +1062,21 @@ function form_create_select($fieldname, $label, $optlist, $selval=NULL, $multipl
echo "</div>\n";
}
function form_create_checks($fieldname, $label, $optlist, $selected) {
echo '<div class="mb-3">', "\n";
echo '<label>', $label, "</label>\n";
print_r($optlist);
echo "</div>\n";
function form_create_checks($fieldname, $label, $optlist, $selected = []) {
echo '<fieldset class="mb-3">';
echo '<legend class="fs-6 mb-1 border-bottom pb-1">', $label, "</legend>\n";
echo '<div class="d-flex flex-wrap gap-3">';
foreach ($optlist as $k => $v) {
echo '<div class="form-check">';
$checked = in_array($k, $selected, true) ? ' checked' : '';
echo '<label class="form-check-label">';
echo '<input type="checkbox" class="form-check-input" name="', $fieldname, '[', $k, ']"', $checked, '>';
echo $v;
echo '</label>';
echo '</div>';
}
echo '</div>';
echo '</fieldset>';
}
// TODO DEPRECATED for touch multiple adjacent buttuns are not well suited.
@@ -1418,7 +1440,7 @@ function make_weblink($dest) {
} elseif (!in_array($scheme, ['http', 'https'], true)) {
return '';
}
return '<a href="' . $dest . '"><i class="bi-globe"></i></a>';
return '<a href="' . $dest . '" target="_blank"><i class="bi-globe"></i></a>';
}
function make_maillink($dest) {