summaryrefslogtreecommitdiff
path: root/httemplate/edit/router.cgi
blob: 70eaa4576e8c2367fde6932f14293047bfb95138 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<% include('elements/edit.html',
     'post_url'    => popurl(1).'process/router.cgi',
     'name'        => 'router',
     'table'       => 'router',
     'viewall_url' => "${p}browse/router.cgi",
     'labels'      => { 'routernum'  => 'Router',
                        'routername' => 'Name',
                        'svc_part'   => 'Service',
                      },
     'fields'      => [
                        { 'field'=>'routername', 'type'=>'text', 'size'=>32 },
                        { 'field'=>'agentnum',   'type'=>'select-agent' },
                        { 'field'=>'svcnum',     'type'=>'hidden' },
                      ],
     'error_callback' => $callback,
     'edit_callback'  => $callback,
     'new_callback'   => $callback,
     'html_table_bottom' => $html_table_bottom,
   )
%>
<%init>

my $curuser = $FS::CurrentUser::CurrentUser;

die "access denied"
  unless $curuser->access_right('Broadband configuration')
    || $curuser->access_right('Broadband global configuration');

my $callback = sub {
  my ($cgi, $object, $fields) = (shift, shift, shift);
  unless ($object->svcnum) {
    push @{$fields},
      { 'type'          => 'tablebreak-tr-title',
        'value'         => 'Select the service types available on this router',
      },
      { 'field'         => 'svc_part',
        'type'          => 'checkboxes-table',
        'target_table'  => 'part_svc',
        'link_table'    => 'part_svc_router',
        'name_col'      => 'svc',
        'hashref'       => { 'svcdb' => 'svc_broadband', 'disabled' => '' },
      };
  }
};

my $html_table_bottom = sub {
  my $router = shift;
  my $html = '';
  foreach my $field ($router->virtual_fields) {
    $html .= $router->pvf($field)->widget('HTML', 'edit', $router->get($field));
  }
  $html;
};
</%init>