More webgui work. Filters e.g.
This commit is contained in:
+54
-11
@@ -24,6 +24,14 @@ switch ($submit = form_get_action()) {
|
||||
case 'edit': $action = ACT_EDIT; break;
|
||||
case 'del': $action = ACT_DELETE; break;
|
||||
|
||||
case 'filter':
|
||||
$flt = array();
|
||||
$flt['equip'] = gpc_get_int($_POST, 'flt_equip');
|
||||
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
|
||||
db_save_filter($flt, 204);
|
||||
$action = ACT_DEFAULT;
|
||||
break;
|
||||
|
||||
case 'insert':
|
||||
$p[':vid'] = $user->vid;
|
||||
$p[':eid'] = gpc_get_int($_POST, 'eid');
|
||||
@@ -58,8 +66,41 @@ require 'header.php';
|
||||
if ($action == ACT_DEFAULT):
|
||||
// ========== VARIANT: default behavior =======================================
|
||||
|
||||
// load filter from db
|
||||
$flt = db_get_filter($user->id, 204);
|
||||
|
||||
echo '<h1>', $pagetitle, "</h1>\n";
|
||||
|
||||
// Filter
|
||||
$opt_special = array(
|
||||
-2 => _('― all ―'),
|
||||
-1 => _('― none ―')
|
||||
);
|
||||
?>
|
||||
<form method="post" action="<?=$g_scriptname?>">
|
||||
<div id="filter" class="card">
|
||||
<div class="card-header">Filter</div>
|
||||
<div class="card-body">
|
||||
<label for="flt_equip">Equipment</label>
|
||||
<select id="flt_equip" name="flt_equip">
|
||||
<?php
|
||||
foreach ($opt_special + $opt_equipment as $k => $v) {
|
||||
echo '<option value="', $k,'"';
|
||||
if (isset($flt->equip) and $k == $flt->equip) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>', $v, '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<label for="flt_txt">Text</label>
|
||||
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?? ''?>">
|
||||
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
$sql = "SELECT m.maintid, m.activities, m.remarks, e.ename "
|
||||
. "FROM maintenance AS m LEFT OUTER JOIN equipment AS e USING (eid)"
|
||||
. "WHERE m.vid=? "
|
||||
@@ -70,9 +111,9 @@ $res = $sth->fetchAll();
|
||||
echo '<table class="table table-striped">', "\n";
|
||||
echo "<thead>\n";
|
||||
echo "<tr>";
|
||||
echo "<th>" . _('Activities') . "</th>";
|
||||
echo "<th>" . _('Equipment') . "</th>";
|
||||
echo "<th>" . _('Remarks') . "</th>";
|
||||
echo "<th>", _('Activities'), "</th>";
|
||||
echo "<th>", _('Equipment'), "</th>";
|
||||
echo "<th>", _('Remarks'), "</th>";
|
||||
echo "</tr>\n";
|
||||
echo "</thead>\n";
|
||||
foreach ($res as $row) {
|
||||
@@ -145,6 +186,7 @@ if (isset($maint->eid)) {
|
||||
$docs = $sth->fetchAll();
|
||||
} else {
|
||||
$maint->ename = _('n/a');
|
||||
unset($docs);
|
||||
}
|
||||
|
||||
// Bootstrap grid
|
||||
@@ -162,15 +204,16 @@ echo '</div>'; // Column break
|
||||
echo '<div class="col">';
|
||||
|
||||
// TODO Show documents for equipment
|
||||
?>
|
||||
<p>Documents</p>
|
||||
<?php
|
||||
echo '<ul>', "\n";
|
||||
foreach ($docs as $d) {
|
||||
echo '<li>', $d['title'] ?? $d['filename'], ' (', $d['docid'], ")</li>\n";
|
||||
echo "<h4>Documents</h4>\n";
|
||||
if (isset($docs)) {
|
||||
echo '<ul>', "\n";
|
||||
foreach ($docs as $d) {
|
||||
echo '<li>', $d['title'] ?? $d['filename'], ' (', $d['docid'], ")</li>\n";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
} else {
|
||||
echo '<p>', _('No documents found.'), "</p>\n";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
|
||||
|
||||
echo '</div>'; // col
|
||||
echo '</div>'; // row
|
||||
|
||||
Reference in New Issue
Block a user