Webgui: filter and pagination working
This commit is contained in:
+17
-10
@@ -51,7 +51,8 @@ switch ($submit = form_get_action()) {
|
||||
$p[':shortname'] = gpc_get_string($_POST, 'shortname', 20);
|
||||
$p[':comptype'] = gpc_get_int($_POST, 'comptype');
|
||||
$p[':comptype2'] = gpc_get_int($_POST, 'comptype2');
|
||||
$p[':street'] = gpc_get_string($_POST, 'street', 30);
|
||||
if ($p[':comptype2'] <= 0) $p[':comptype2'] = NULL;
|
||||
$p[':street'] = gpc_get_string($_POST, 'street', 40);
|
||||
$p[':zip'] = gpc_get_string($_POST, 'zip', 10);
|
||||
$p[':city'] = gpc_get_string($_POST, 'city', 30);
|
||||
$p[':country'] = gpc_get_string($_POST, 'country', 30);
|
||||
@@ -98,7 +99,7 @@ if ($action == ACT_DEFAULT):
|
||||
page_caption_search($pagetitle);
|
||||
|
||||
// load filter from db
|
||||
$flt = db_get_filter($user->id, 208);
|
||||
$flt = db_get_filter($user->id, 208, ['type','txt']);
|
||||
|
||||
$w = array();
|
||||
$p = array();
|
||||
@@ -132,7 +133,7 @@ try {
|
||||
}
|
||||
$numrows = $sth->fetchColumn();
|
||||
$page = gpc_get_int($_REQUEST, 'p', 1);
|
||||
$rows_pp = gpc_get_int($_REQUEST, 'n', $g_rows_pp);
|
||||
$rows_pp = gpc_get_int($_REQUEST, 'n', $user->rows_pp);
|
||||
$lastpage = ceil($numrows/$rows_pp);
|
||||
|
||||
$sql = "SELECT compid, compname, comptype, remarks "
|
||||
@@ -141,7 +142,7 @@ if ($where) $sql .= ' WHERE ' . $where;
|
||||
$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 {
|
||||
@@ -161,9 +162,10 @@ $opt_special = array(
|
||||
<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">
|
||||
<div class="d-flex flex-nowrap gap-2">
|
||||
<label for="flt_type">Type</label>
|
||||
<select id="flt_type" name="flt_type">
|
||||
<select id="flt_type" class="form-select" name="flt_type">
|
||||
<?php
|
||||
foreach ($opt_special + $opt_comptype as $k => $v) {
|
||||
echo '<option value="', $k,'"';
|
||||
@@ -174,10 +176,15 @@ foreach ($opt_special + $opt_comptype as $k => $v) {
|
||||
}
|
||||
?>
|
||||
</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>
|
||||
<button name="submit[freset]" class="btn btn-sm btn-secondary float-end" title="<?=_('Reset filter to defaults')?>"><?=_('Clear')?></button>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user