optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / edit / radius_group.html
1 <& elements/edit.html,
2   'name'   => 'RADIUS Group',
3   'table'  => 'radius_group',
4   'labels' => { 
5     'groupnum'  => 'Group',
6     'groupname' => 'RADIUS Group',
7     'description' => 'Description',
8     'attrnum'   => 'Attribute',
9     'priority'  => 'Priority',
10   },
11   'viewall_dir' => 'browse',
12   'fields' => [
13     { 'field'     => 'groupname',
14       'type'      => 'text',
15       'size'      => 20,
16       'colspan'   => 6, # just to not interfere with radius_attr columns
17     },
18     { 'field'     => 'description',
19       'type'      => 'text',
20       'size'      => 40,
21       'colspan'   => 6,
22     },
23     { 'field'     => 'priority',
24       'type'      => 'text',
25       'size'      => 2,
26       'colspan'   => 6, # just to not interfere with radius_attr columns
27     },
28     {
29       'field'     => 'attrnum',
30       'type'      => 'radius_attr',
31       'o2m_table' => 'radius_attr',
32       'm2_label'  => 'Attribute',
33       'm2_error_callback' => $m2_error_callback,
34     },
35   ],
36   #debug => 1
37 &>
38 <%init>
39
40 die "access denied"
41   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
42
43 my $m2_error_callback = sub { # reconstruct the list
44   my ($cgi, $object) = @_;
45
46   my @fields = qw(attrname attrtype op value);
47   map {
48     my $k = $_;
49     next if !length($cgi->param($k.'_attrname'));
50     new FS::radius_attr {
51       'groupnum' => $object->groupnum,
52       'attrnum'  => scalar( $cgi->param($k) ),
53       map {  $_  => scalar( $cgi->param($k.'_'.$_) ) } @fields,
54     };
55   } grep /^attrnum\d+$/, ($cgi->param);
56 };
57 </%init>