Webgui: Add clear filter function

This commit is contained in:
2025-11-08 08:05:10 +01:00
parent a3793df629
commit e99a053594
8 changed files with 85 additions and 4 deletions
+7 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
/****************************************************************************** /******************************************************************************
* YMS - Yacht Management Software * YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge * Copyright (C) 2024-2025 Thomas Hooge
* *
* SPDX-License-Identifier: WTFPL * SPDX-License-Identifier: WTFPL
******************************************************************************/ ******************************************************************************/
@@ -31,6 +31,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(208);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':compname'] = gpc_get_string($_POST, 'compname'); $p[':compname'] = gpc_get_string($_POST, 'compname');
$p[':comptype'] = gpc_get_int($_POST, 'comptype'); $p[':comptype'] = gpc_get_int($_POST, 'comptype');
@@ -168,6 +173,7 @@ foreach ($opt_special + $opt_comptype as $k => $v) {
<label for="flt_txt">Text</label> <label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>"> <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[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>
</div> </div>
</form> </form>
+6
View File
@@ -39,6 +39,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(209);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
// WIP New standalone document // WIP New standalone document
// debug $g_message->Add(print_r($_FILES, true)); // debug $g_message->Add(print_r($_FILES, true));
@@ -304,6 +309,7 @@ foreach ($opt_special + $opt_reftype as $k => $v) {
<label for="flt_txt">Text</label> <label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>"> <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[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>
</div> </div>
</form> </form>
+6
View File
@@ -39,6 +39,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(200);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':vid'] = $user->vid; $p[':vid'] = $user->vid;
$p[':ename'] = gpc_get_string($_POST, 'ename'); $p[':ename'] = gpc_get_string($_POST, 'ename');
@@ -265,6 +270,7 @@ filter_create_select('flt_supp', _('Supplier'), $g_opt_all + $opt_none_male + $o
<label for="flt_txt"><?=_('Text')?></label> <label for="flt_txt"><?=_('Text')?></label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>"> <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[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>
</div> </div>
</form> </form>
+7 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
/****************************************************************************** /******************************************************************************
* YMS - Yacht Management Software * YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge * Copyright (C) 2024-2025 Thomas Hooge
* *
* SPDX-License-Identifier: WTFPL * SPDX-License-Identifier: WTFPL
******************************************************************************/ ******************************************************************************/
@@ -37,6 +37,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(201);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':invname'] = gpc_get_string($_POST, 'invname'); $p[':invname'] = gpc_get_string($_POST, 'invname');
$p[':number'] = gpc_get_int($_POST, 'number'); $p[':number'] = gpc_get_int($_POST, 'number');
@@ -206,6 +211,7 @@ foreach ($opt_special + $opt_invcond as $k => $v) {
<label for="flt_txt">Text</label> <label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>"> <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[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>
</div> </div>
</form> </form>
+6
View File
@@ -32,6 +32,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(204);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':vid'] = $user->vid; $p[':vid'] = $user->vid;
$p[':eid'] = gpc_get_int($_POST, 'eid'); $p[':eid'] = gpc_get_int($_POST, 'eid');
@@ -96,6 +101,7 @@ foreach ($opt_special + $opt_equipment as $k => $v) {
<label for="flt_txt">Text</label> <label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?? ''?>"> <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[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>
</div> </div>
</form> </form>
+40 -1
View File
@@ -32,11 +32,18 @@ switch ($submit = form_get_action()) {
case 'filter': case 'filter':
$flt = array(); $flt = array();
$flt['txt'] = gpc_get_string($_POST, 'flt_txt'); $flt['name'] = gpc_get_string($_POST, 'flt_name');
$flt['state'] = gpc_get_string($_POST, 'flt_state');
$flt['remarks'] = gpc_get_string($_POST, 'flt_remarks');
db_save_filter($flt, 205); db_save_filter($flt, 205);
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(205);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':vid'] = $user->vid; $p[':vid'] = $user->vid;
$p[':projname'] = gpc_get_string($_POST, 'projname'); $p[':projname'] = gpc_get_string($_POST, 'projname');
@@ -85,6 +92,38 @@ if ($action == ACT_DEFAULT):
page_caption_search($pagetitle); page_caption_search($pagetitle);
// load filter from db
$flt = db_get_filter($user->id, 205);
$w = array();
$p = array();
$where = join(' AND ', $w);
$order = ' ORDER BY comptype, compname';
// grand total of records for current vessel
$grandtotal = $pdo->query("SELECT COUNT(*) FROM project")->fetchColumn();
// Filter
?>
<form method="post" action="<?=$g_scriptname?>">
<div id="filter" class="card">
<div class="card-header">Filter</div>
<div class="card-body">
<label for="flt_name">Name</label>
<input type="text" name="flt_name" size="15" maxlength="30" value="<?=$flt->name;?>">
<?php
filter_create_select('flt_state', _('State'), $g_opt_all + $opt_state, $flt->state);
?>
<label for="flt_remarks">Text</label>
<input type="text" name="flt_remarks" size="15" maxlength="30" value="<?=$flt->remarks?>">
<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
$sql = "SELECT projid, projname, startdate, duration, projstate, remarks " $sql = "SELECT projid, projname, startdate, duration, projstate, remarks "
. "FROM project " . "FROM project "
. "WHERE vid=? " . "WHERE vid=? "
+6
View File
@@ -34,6 +34,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(202);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':provname'] = gpc_get_string($_POST, 'provname'); $p[':provname'] = gpc_get_string($_POST, 'provname');
$p[':number'] = gpc_get_int($_POST, 'number'); $p[':number'] = gpc_get_int($_POST, 'number');
@@ -118,6 +123,7 @@ filter_create_select('flt_cat', _('Category'), $g_opt_all + $g_opt_none + $opt_c
<label for="flt_txt">Text</label> <label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>"> <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[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>
</div> </div>
</form> </form>
+7 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
/****************************************************************************** /******************************************************************************
* YMS - Yacht Management Software * YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge * Copyright (C) 2024-2025 Thomas Hooge
* *
* SPDX-License-Identifier: WTFPL * SPDX-License-Identifier: WTFPL
******************************************************************************/ ******************************************************************************/
@@ -29,6 +29,11 @@ switch ($submit = form_get_action()) {
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
break; break;
case 'freset':
db_clear_filter(210);
$action = ACT_DEFAULT;
break;
case 'insert': case 'insert':
$p[':tagname'] = gpc_get_string($_POST, 'tagname');; $p[':tagname'] = gpc_get_string($_POST, 'tagname');;
$id = db_exec_insert('tag', $p); $id = db_exec_insert('tag', $p);
@@ -89,6 +94,7 @@ echo "<h1>$pagetitle</h1>\n";
<label for="flt_txt">Text</label> <label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?? ''?>"> <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[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>
</div> </div>
</form> </form>