DMA Radius Manager export, #18456
[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     'speed_down'  => 'Download speed',
11     'speed_up'    => 'Upload speed',
12   },
13   'menubar' => \@menubar,
14   'edit_callback' => $edit_callback,
15   'error_callback' => $edit_callback,
16   'fields' => [
17     { 'field'     => 'groupname',
18       'type'      => 'text',
19       'size'      => 20,
20       'colspan'   => 6, # just to not interfere with radius_attr columns
21     },
22     { 'field'     => 'description',
23       'type'      => 'text',
24       'size'      => 40,
25       'colspan'   => 6,
26     },
27     { 'field'     => 'priority',
28       'type'      => 'text',
29       'size'      => 2,
30       'colspan'   => 6, # just to not interfere with radius_attr columns
31     },
32     { 'field'     => 'speed_down',
33       'type'      => 'text',
34       'size'      => 8,
35       'colspan'   => 6,
36     },
37     { 'field'     => 'speed_up',
38       'type'      => 'text',
39       'size'      => 8,
40       'colspan'   => 6,
41     },
42     {
43       'field'     => 'attrnum',
44       'type'      => 'radius_attr',
45       'o2m_table' => 'radius_attr',
46       'm2_label'  => 'Attribute',
47       'm2_error_callback' => $m2_error_callback,
48     },
49   ],
50   #debug => 1
51 &>
52 <%init>
53
54 die "access denied"
55   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
56
57 my @menubar = ('View all RADIUS Groups' => $p.'browse/radius_group.html');
58
59 my $edit_callback = sub {
60   my ($cgi, $object) = @_;
61   if ( $object->groupnum ) {
62     my $link = $p.'misc/delete-radius_group.html?'.$object->groupnum;
63     push @menubar, 'Delete this Group', $link;
64   }
65 };
66
67 my $m2_error_callback = sub { # reconstruct the list
68   my ($cgi, $object) = @_;
69
70   my @fields = qw(attrname attrtype op value);
71   map {
72     my $k = $_;
73     next if !length($cgi->param($k.'_attrname'));
74     new FS::radius_attr {
75       'groupnum' => $object->groupnum,
76       'attrnum'  => scalar( $cgi->param($k) ),
77       map {  $_  => scalar( $cgi->param($k.'_'.$_) ) } @fields,
78     };
79   } grep /^attrnum\d+$/, ($cgi->param);
80 };
81 </%init>