2 'name' => 'saved search',
3 'table' => 'saved_search',
6 { field => 'searchname',
12 options => [ '', 'daily', 'weekly', 'monthly' ],
13 labels => { '' => 'no' },
15 { field => 'emailaddress',
17 curr_value_callback => sub {
18 $curuser->option('email_address')
19 || 'no email address configured'
22 { field => 'last_sent',
26 type => 'hidden', # revisit this later
28 # options => [ 'html', 'xls', 'csv' ],
30 # 'html' => 'webpage',
31 # 'xls' => 'spreadsheet',
35 { field => 'disabled', # currently unused
38 { type => 'tablebreak-tr-title' },
41 cell_style => 'font-size: small',
45 cell_style => 'font-size: small',
49 'searchnum' => 'Saved search',
50 'searchname' => 'Name this search',
51 'path' => 'Search page',
52 'params' => 'Parameters',
53 'freq' => 'Subscribe by email',
54 'last_sent' => 'Last sent on',
55 'emailaddress' => 'Will be sent to',
56 'format' => 'Report format',
58 'new_object_callback' => $new_object,
59 'delete_url' => $fsurl.'misc/delete-saved_search.html',
63 my $curuser = $FS::CurrentUser::CurrentUser;
65 # prefix to the freeside document root (usually '/freeside/')
66 my $root = URI->new($fsurl)->path;
68 # alternatively, could do all this on the client using window.top.location
69 my $new_object = sub {
73 for (grep { $_->{field} eq 'last_sent' } @$fields) {
74 $_->{type} = 'hidden';
76 my $url = $r->header_in('Referer')
77 or die "no referring page found";
78 $url = URI->new($url);
79 my $path = $url->path;
80 $path =~ s/^$root//; # path should not have a leading slash
81 my $title = $cgi->param('title');
82 return FS::saved_search->new({
83 'usernum' => $curuser->usernum,
85 'params' => $url->query,
87 'searchname' => $title,