709a24069b683f7a158d0fa9cc731706cf430a49
[freeside.git] / httemplate / edit / log_email.html
1 <% include( 'elements/edit.html',
2               'name_singular' => 'log email condition',
3               'table'  => 'log_email',
4               'fields' => [
5                             { 'field' => 'context',
6                               'type' => 'select',
7                               'options' => [ '', @contexts ],
8                               'labels' => { '' => '(all)', map { $_ => $_ } @contexts },
9                               'curr_value' => scalar($cgi->param('context')),
10                             },
11                             { 'field' => 'min_level',
12                               'type'  => 'select',
13                               'options' => [ 0..7 ],
14                               'labels' => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 },
15                               'curr_value' => scalar($cgi->param('min_level')),
16                             },
17                             'to_addr',
18                             { 'field' => 'msgnum',
19                               'type' => 'select-msg_template',
20                               'empty_label' => 'Select template',
21                               'value' => $msgnum,
22                               'required' => 1,
23                             },
24                           ],
25               'labels' => { 
26                             'context' => 'Context',
27                             'min_level' => 'Min. Level',
28                             'to_addr' => 'To',
29                             'msgnum' => 'Message',
30                           },
31               'viewall_dir' => 'browse',
32               'popup' => $opts{'popup'},
33               'form_init' => $opts{'popup'} ? q(<INPUT TYPE="hidden" NAME="popup" VALUE="1">) : '',
34            )
35 %>
36 <%once>
37 my @contexts = sort FS::log_context->contexts;
38 </%once>
39 <%init>
40
41 my %opts = @_;
42
43 die "access denied"
44   unless $FS::CurrentUser::CurrentUser->access_right([ 'View system logs', 'Configuration' ]);
45
46 my $msgnum = $cgi->param('msgnum');
47 unless ($msgnum) {
48   my ($msg_template) = qsearch('msg_template',{ msgname => 'System log' });
49   # doesn't seem worth having a config just for the default selected template
50   # if they've deleted the system-generated one, just default to empty "Select template"
51   if ($msg_template) {
52     $msgnum = $msg_template->msgnum;
53   }
54 }
55
56 </%init>