Settings page finished, filter gui improved
This commit is contained in:
+51
-15
@@ -36,6 +36,8 @@ switch ($submit = form_get_action()) {
|
||||
$flt['manuf'] = gpc_get_int($_POST, 'flt_manuf');
|
||||
$flt['supp'] = gpc_get_int($_POST, 'flt_supp');
|
||||
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
|
||||
$allowed = db_load_enum('equipment', 'flags');
|
||||
$flt['flags'] = gpc_get_set($_POST, 'flt_flags', $allowed);
|
||||
db_save_filter($flt, 200);
|
||||
$action = ACT_DEFAULT;
|
||||
break;
|
||||
@@ -144,10 +146,10 @@ switch ($submit = form_get_action()) {
|
||||
if ($factor < 1) {
|
||||
$width = (int)($width * $factor);
|
||||
$height = (int)($height * $factor);
|
||||
$g_message->add(sprintf(_('Image sacled down to %dx%d'), $width, $height));
|
||||
$g_message->add(sprintf(_('Image scaled down to %dx%d'), $width, $height));
|
||||
if ($file_mimetype == 'image/jpeg') {
|
||||
$orig = imagecreatefromjpeg($file_tmp);
|
||||
$scaled = imagescale($orig, (int)($width * $factor), (int)($height * $factor), IMG_BICUBIC);
|
||||
$scaled = imagescale($orig, $width, $height, IMG_BICUBIC);
|
||||
imagejpeg($scaled, $file_tmp, 85);
|
||||
} else if ($file_mimetype == 'image/png') {
|
||||
$orig = imagecreatefrompng($file_tmp);
|
||||
@@ -155,7 +157,7 @@ switch ($submit = form_get_action()) {
|
||||
$g_error->Add("imagecreatefrompng failed");
|
||||
break;
|
||||
}
|
||||
$scaled = imagescale($orig, (int)($width * $factor), (int)($height * $factor), IMG_BICUBIC);
|
||||
$scaled = imagescale($orig, $width, $height, IMG_BICUBIC);
|
||||
if (!$scaled) {
|
||||
$g_error->Add("imagescale failed");
|
||||
break;
|
||||
@@ -231,7 +233,6 @@ if ($action == ACT_DEFAULT):
|
||||
page_caption_search($pagetitle);
|
||||
|
||||
$flt = db_get_filter($user->id, 200);
|
||||
|
||||
$sort = array(
|
||||
1 => 'ename',
|
||||
2 => 'ename DESC'
|
||||
@@ -261,12 +262,21 @@ if (strlen($flt->txt) > 1) {
|
||||
$w[] = '(ename LIKE :txt OR model LIKE :txt OR remarks LIKE :txt)';
|
||||
$p[':txt'] = '%'.$flt->txt.'%';
|
||||
}
|
||||
// TODO flags (ordered, removed, deleted)
|
||||
// if (strlen($flt->flags) > 0) {
|
||||
// }
|
||||
// condition for multiple flags is OR
|
||||
$parts = ["flags=''", 'flags IS NULL'];
|
||||
foreach ($flt->flags as $f) {
|
||||
$parts[] = "FIND_IN_SET('$f', flags)";
|
||||
}
|
||||
if (!empty($parts)) {
|
||||
if (count($parts) > 1) {
|
||||
$w[] = '(' . join(' OR ', $parts) . ')';
|
||||
} else {
|
||||
$w[] = $parts[0];
|
||||
}
|
||||
}
|
||||
|
||||
$where = join(' AND ', $w);
|
||||
$order = ' ORDER BY ename';
|
||||
|
||||
// get total record count for pagination and limit
|
||||
$sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE " . $where);
|
||||
try {
|
||||
@@ -314,12 +324,13 @@ filter_create_select('flt_supp', _('Supplier'), $g_opt_all + $opt_none_male + $o
|
||||
?>
|
||||
<div class="d-flex flex-nowrap gap-2">
|
||||
<label for="flt_txt"><?=_('Text')?></label>
|
||||
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?>">
|
||||
<input type="text" class="form-control" name="flt_txt" maxlength="30" value="<?=$flt->txt ?>">
|
||||
</div>
|
||||
<div class="d-flex flex-nowrap gap-2">
|
||||
<?php
|
||||
$enum_data = db_load_enum('equipment', 'flags', true, true, false);
|
||||
form_create_checks('flags', _('Flags'), $enum_data, []);
|
||||
$opt_flags = db_load_enum('equipment', 'flags', true, true, false);
|
||||
filter_create_checks('flt_flags', _('Flags'), $opt_flags, $flt->flags ?? []);
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -455,7 +466,7 @@ echo '<div class="col">', "\n";
|
||||
|
||||
echo '<div class="card">', "\n";
|
||||
echo '<div class="card-header">', _('Images and documents'), "</div>\n";
|
||||
echo '<div class="card-body">', "\n";
|
||||
echo '<div class="card-body d-flex flex-wrap gap-3">', "\n";
|
||||
|
||||
$sql = "SELECT d.docid, d.doctype, d.title "
|
||||
. "FROM docref AS r INNER JOIN document AS d using (docid) "
|
||||
@@ -468,13 +479,19 @@ $res = $sth->fetchAll();
|
||||
$doccount = 0;
|
||||
foreach ($res as $row) {
|
||||
$doccount += 1;
|
||||
echo '<div class="border rounded p-2 d-flex flex-column" style="width: 150px;">';
|
||||
if ($row['doctype'] == 'picture') {
|
||||
echo '<a href="dl.php?id=', $row['docid'], '">';
|
||||
// echo '<img width="120" src="doc/pic-', $row['hash'], '.', $row['extension'],'">';
|
||||
echo '<img width="120" src="dl.php?id=', $row['docid'], '" alt="', $row['title'], '">';
|
||||
echo '<img class="img-fluid rounded mb-2" width="120" src="dl.php?id=', $row['docid'], '" alt="', $row['title'], '">';
|
||||
echo "</a>\n";
|
||||
// additionally direct download and go to document details page
|
||||
echo '<div class="d-flex justify-content-between mt-auto">';
|
||||
echo '<a href="documents.php?f=view&id=', $row['docid'], '" title="Download image"> <i class="bi bi-eye"></i></a>';
|
||||
echo '<a href="dl.php?id=', $row['docid'], '" title="View document"><i class="bi bi-download"></i></a>';
|
||||
echo '</div>';
|
||||
} elseif ($row['doctype'] == 'drawing') {
|
||||
echo "<p>Drawing: ", $row['title'], "<br>";
|
||||
echo "<p>Drawing:<br>", $row['title'], "<br>";
|
||||
echo '<a href="dl.php?id=', $row['docid'], '">';
|
||||
echo '<img width="180" src="dl.php?id=', $row['docid'], '">';
|
||||
echo "</a>";
|
||||
@@ -485,7 +502,7 @@ foreach ($res as $row) {
|
||||
// echo $row['title'];
|
||||
echo "</a>\n";
|
||||
} elseif ($row['doctype'] == 'manual') {
|
||||
echo "<p>Manual: ";
|
||||
echo "<p>Manual:<br>";
|
||||
echo '<a href="documents.php?f=view&id=', $row['docid'], '">';
|
||||
echo $row['title'];
|
||||
echo "</a></p>\n";
|
||||
@@ -493,6 +510,7 @@ foreach ($res as $row) {
|
||||
// unknown document type
|
||||
echo "<span>Unknown document type:", $row['doctype'], "</span>\n";
|
||||
}
|
||||
echo "</div>\n";
|
||||
}
|
||||
if ($doccount == 0) {
|
||||
echo _('No referenced documents'), "\n";
|
||||
@@ -581,6 +599,24 @@ if ($sth->rowCount() > 0) {
|
||||
echo '<p>', _('No spare parts found.'), "<p>\n";
|
||||
}
|
||||
|
||||
|
||||
// Document preview
|
||||
?>
|
||||
<div class="modal fade" id="imageModal" tabindex="-1" aria-labelledby="imageModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered custom-image-modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
TITLE
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
IMAGE
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
elseif ($action == ACT_EDIT):
|
||||
// ========== VARIANT: edit single record =====================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user