b79aba986b7fbef8cc746511a7bff1696dfe117e
[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' => 'context_height',
12                               'type' => 'checkbox',
13                               'postfix' => 'Only match most specific context',
14                               'value' => 1,
15                               'curr_value' => scalar($cgi->param('context_height')),
16                             },
17                             { 'field' => 'min_level',
18                               'type'  => 'select',
19                               'options' => [ &FS::Log::levelnums ],
20                               'labels' => { &FS::Log::levelmap },
21                               'curr_value' => scalar($cgi->param('min_level')),
22                             },
23                             'to_addr',
24                             { 'field' => 'msgnum',
25                               'type' => 'select-msg_template',
26                               'empty_label' => 'Select template',
27                               'value' => $msgnum,
28                               'required' => 1,
29                             },
30                           ],
31               'labels' => { 
32                             'context' => 'Context',
33                             'context_height' => '',
34                             'min_level' => 'Min. Level',
35                             'to_addr' => 'To',
36                             'msgnum' => 'Message',
37                           },
38               'viewall_dir' => 'browse',
39               'popup' => $opts{'popup'},
40               'form_init' => $opts{'popup'} ? q(<INPUT TYPE="hidden" NAME="popup" VALUE="1">) : '',
41            )
42 %>
43 <%once>
44 my @contexts = sort FS::log_context->contexts;
45 </%once>
46 <%init>
47
48 my %opts = @_;
49
50 die "access denied"
51   unless $FS::CurrentUser::CurrentUser->access_right([ 'View system logs', 'Configuration' ]);
52
53 my $msgnum = $cgi->param('msgnum');
54
55 # XXX This attempt to set a default message isn't working, not sure why
56 #     $msgnum gets set correctly, but isn't selected in the popup window...fix later
57
58 unless ($msgnum) {
59   my ($msg_template) = qsearch('msg_template',{ msgname => 'System log' });
60   # doesn't seem worth having a config just for the default selected template
61   # if they've deleted the system-generated one, just default to empty "Select template"
62   if ($msg_template) {
63     $msgnum = $msg_template->msgnum;
64   }
65 }
66
67 </%init>