Webgui: filter and pagination working
This commit is contained in:
+20
-8
@@ -124,7 +124,7 @@ if ($action == ACT_DEFAULT):
|
||||
page_caption_search($pagetitle);
|
||||
|
||||
// load filter from db
|
||||
$flt = db_get_filter($user->id, 206);
|
||||
$flt = db_get_filter($user->id, 206, ['txt','prio', 'stat']);
|
||||
|
||||
$w = array('(t.vid=:vid OR t.vid IS NULL)');
|
||||
$p = array(':vid' => $user->vid);
|
||||
@@ -170,7 +170,8 @@ $sql = "SELECT t.taskid, t.vid, t.projid, t.taskname, t.priority, t.taskstate,"
|
||||
if ($order) $sql .= $order;
|
||||
|
||||
// if pagination:
|
||||
// $sql .= ' LIMIT ' . ($page - 1) * $g_rows_pp . ',' . $g_rows_pp;
|
||||
$sql .= ' LIMIT ' . ($page - 1) * $rows_pp . ',' . $rows_pp;
|
||||
|
||||
$sth = $pdo->prepare($sql);
|
||||
try {
|
||||
$sth->execute($p);
|
||||
@@ -186,20 +187,28 @@ $res = $sth->fetchAll();
|
||||
<form method="post" action="<?=$g_scriptname?>">
|
||||
<div id="filter" class="card">
|
||||
<div class="card-header"><i class="bi bi-funnel me-2"></i>Filter</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body d-flex flex-wrap gap-3">
|
||||
<?php
|
||||
filter_create_select('flt_prio', _('Priority'), $g_opt_all + $g_opt_none + $opt_priority, $flt->prio);
|
||||
filter_create_select('flt_stat', _('State'), $g_opt_all + $opt_state, $flt->stat);
|
||||
?>
|
||||
<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>
|
||||
<input type="reset" class="btn btn-sm btn-secondary" value="<?=_('Clear')?>">
|
||||
<div class="d-flex flex-nowrap gap-2">
|
||||
<label for="flt_txt">Text</label>
|
||||
<input type="text" class="form-control" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?>">
|
||||
</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
|
||||
|
||||
// Pagination on top
|
||||
$pagination = get_pagination($g_scriptname, '', $page, $lastpage);
|
||||
echo $pagination;
|
||||
|
||||
echo '<table class="table table-striped">', "\n";
|
||||
echo "<thead>\n";
|
||||
echo "<tr>\n";
|
||||
@@ -237,6 +246,9 @@ echo '<tr><td colspan="6">', sprintf(_('%d records'), count($res)), '</td></tr>'
|
||||
echo "</tfoot>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
// additional pagination at bottom
|
||||
echo $pagination;
|
||||
|
||||
form_add_button($g_scriptname);
|
||||
|
||||
elseif ($action == ACT_ADD):
|
||||
@@ -301,7 +313,7 @@ if ($sth->rowCount() > 0) {
|
||||
$n = 0;
|
||||
foreach ($sth->fetchAll() as $row) {
|
||||
$n += 1;
|
||||
echo "<p>($n) {$row['annotation']}";
|
||||
echo "<p>($n) ", nl2br($row['annotation']);
|
||||
echo ' <a title="', _('Edit'), '" href="note.php?f=edit&id=', $row['noteid'], '"><i class="bi-pencil"></i></a>';
|
||||
echo "</p>\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user