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