Webgui code improvements and fixes

This commit is contained in:
thooge committed 2026-10-30 11:40:59 +01:00
1 parent dacf32b401
commit 5fe9a52f15
14 files changed
+205 -311

No files matched your search

+28 -24
View File
@@ -321,7 +321,7 @@ $page = gpc_get_int($_REQUEST, 'p', 1);
$rows_pp = gpc_get_int($_REQUEST, 'n', $user->rows_pp);
$lastpage = ceil($numrows/$rows_pp);
$sql = "SELECT d.docid, d.doctype, d.filename, d.title, COUNT(r.drid) AS refcount "
$sql = "SELECT d.docid, d.doctype, d.mimetype, d.filename, d.title, COUNT(r.drid) AS refcount "
. "FROM document AS d LEFT OUTER JOIN docref AS r USING (docid)";
if ($where) $sql .= ' WHERE ' . $where;
$sql .= " GROUP BY d.docid, d.doctype, d.filename, d.title";
@@ -379,7 +379,17 @@ foreach ($res as $row) {
echo "<td>", $i;
echo '<a title="', _('View'), '" href="', $g_scriptname, '?f=view&id=', $row['docid'], '"><i class="bi-eye ms-2"></i></a>', "\n";
echo "</td>\n";
echo "<td>", $opt_doctype[$row['doctype']], "</td>\n";
echo "<td>";
if ($row['mimetype'] == 'application/pdf') {
echo '<i class="bi bi-file-earmark-pdf"></i>';
} else if ($row['mimetype'] == 'image/svg+xml') {
echo '<i class="bi bi-file-earmark-easel"></i>';
} else if ($row['mimetype'] == 'image/jpeg' or $row['mimetype'] == 'image/png') {
echo '<i class="bi bi-file-earmark-image"></i>';
} else {
echo '<i class="bi bi-file-earmark"></i>';
}
echo ' ', $opt_doctype[$row['doctype']], "</td>\n";
echo "<td>", $row['filename'], "</td>\n";
echo "<td>", $row['title'], "</td>\n";
echo "<td>", $row['refcount'], "</td>\n";
@@ -403,14 +413,10 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add Document'), "</h2>\n";
?>
<form method="post" enctype="multipart/form-data" 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" value="<?=$title ?? ''?>">
</div>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$remarks ?? ''?></textarea>
</div>
<?php
form_create_text('title', _('Title'), 40);
form_create_textarea('remarks', _('Remarks'), 3, 150, $storage->remarks);
?>
<div class="mb-3">
<label for="files" class="form-label"><?=_('Document')?></label>
<input class="form-control" type="file" id="files" name="files" onchange="preview()">
@@ -519,6 +525,7 @@ echo '<tr><th scope="row">', _('Filename'),"</th><td>", h($document->filename),
echo '<tr><th scope="row">', _('File size'),"</th><td>", format_filesize($document->docsize), "</td></tr>\n";
echo '<tr><th scope="row">', _('Upload date'),"</th><td>", $document->doctime, "</td></tr>\n";
echo '<tr><th scope="row">', _('Title'),"</th><td>", h($document->title), "</td></tr>\n";
echo '<tr><th scope="row">', _('Access'),"</th><td>", get_enum($document->roleaccess), "</td></tr>\n";
echo '<tr><th scope="row">', _('Remarks'),"</th><td>", h($document->remarks, br:true), "</td></tr>\n";
echo "</table>\n";
@@ -722,13 +729,15 @@ elseif ($action == ACT_EDIT):
echo '<h2>', _('Edit Document'), "</h2>\n";
$sql = "SELECT docid, doctype, mimetype, filename, extension, hash, title, remarks "
$sql = "SELECT docid, doctype, mimetype, filename, extension, hash, title, roleaccess, remarks "
. "FROM document "
. "WHERE docid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$document = $sth->fetch(PDO::FETCH_OBJ);
// TODO check roleaccess!
if ($document->doctype == 'picture') {
echo '<img width="', $g_thumb_size, '" src="dl.php?id=', $document->docid, '">';
}
@@ -736,15 +745,10 @@ if ($document->doctype == 'picture') {
?>
<form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3">
<label for="title" class="form-label"><?=_('Filename')?></label>
<input type="text" class="form-control" id="filename" name="filename" value="<?=$document->filename ?>">
</div>
<div class="mb-3">
<label for="title" class="form-label"><?=_('Title')?></label>
<input type="text" class="form-control" id="title" name="title" value="<?=$document->title ?>">
</div>
<?php
form_create_text('filename', _('Filename'), 200, $document->filename);
form_create_text('title', _('Title'), 40, $document->title);
if ($document->mimetype == 'application/pdf') {
echo '<div class="mb-3">', "\n";
$opt_doctype = array(
@@ -757,13 +761,13 @@ if ($document->mimetype == 'application/pdf') {
} else {
echo '<input type="hidden" name="doctype" value="', $document->doctype, '">', "\n";
}
form_create_textarea('remarks', _('Remarks'), 3, 150, $document->remarks);
?>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($document->remarks)?></textarea>
<div class="container-fluid px-0 my-3">
<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>
</div>
<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>
</form>
<?php