diff options
author | Mark Wells <mark@freeside.biz> | 2016-09-08 10:26:23 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-09-08 10:26:23 -0700 |
commit | 54ef6b82c54b5d4c6336ab9fe96aed56fc92963c (patch) | |
tree | 76ffea32cae26db50739910608f1abe7ad6724a0 /httemplate/browse | |
parent | 2d2662d900652d9b1f242e9affd5a6e67c453f4d (diff) |
add UI to manage saved searches, #72101
Diffstat (limited to 'httemplate/browse')
-rw-r--r-- | httemplate/browse/saved_search.html | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/httemplate/browse/saved_search.html b/httemplate/browse/saved_search.html new file mode 100644 index 000000000..d2efa6ed9 --- /dev/null +++ b/httemplate/browse/saved_search.html @@ -0,0 +1,81 @@ +<& elements/browse.html, + 'title' => 'My saved searches', + 'name' => 'saved searches', + 'query' => { 'table' => 'saved_search', + 'hashref' => { usernum => $curuser->usernum }, + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Name', + 'Subscription', + 'Last sent', + 'Format', + 'Path', + 'Parameters', + ], + 'sort_fields' => [ 'searchnum', + 'searchname', + 'freq', + 'last_sent', + 'format', + "path || '?' || 'params'", + '', + ], + 'fields' => [ 'searchnum', + 'searchname', + 'freq', + sub { my $date = shift->get('last_sent'); + $date ? time2str('%b %o, %Y', $date) : ''; + }, + sub { $format_label{ shift->get('format') } + }, + 'path', + sub { join('<BR>', + sort + map { encode_entities(uri_unescape($_)) } + split(/[;&]/, shift->get('params') ) + ) + }, + ], + 'size' => [ '', + '', + '', + '', + '', + '', + '-1', + ], + 'links' => [ '', '' ], + 'link_onclicks' => [ '', $edit_popup ], +# 'disableable' => 1, # currrently unused +# 'disabled_statuspos' => 2, + 'really_disable_download' => 1 +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +my $query = { + 'table' => 'saved_search', + 'hashref' => { 'usernum' => $curuser->usernum }, +}; +my $count_query = "SELECT COUNT(*) FROM saved_search WHERE usernum = ". + $curuser->usernum; + +my %format_label = ( + 'html' => 'webpage', + 'csv' => 'CSV', + 'xls' => 'spreadsheet', +); + +my $edit_popup = sub { + my $searchnum = shift->searchnum; + include('/elements/popup_link_onclick.html', + 'action' => $fsurl.'/edit/saved_search.html?'.$searchnum, + 'actionlabel' => 'Save this search', + 'width' => 650, + 'height' => 500, + ); +}; + +</%init> |