summaryrefslogtreecommitdiff
path: root/httemplate/browse/saved_search.html
blob: d2efa6ed9432d8653c60d921a250bd16610115c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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>