summaryrefslogtreecommitdiff
path: root/httemplate/browse/hardware_class.html
blob: 0bf314e3f688bc1c1a573d10f32a88140351aecb (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/browse.html',
                 'title'       => 'Hardware Classes and Types',
                 'name'        => 'hardware classes',
                 'menubar'     => $menubar,
                 'query'       => { 'table' => 'hardware_class' },
                 'count_query' => 'SELECT COUNT(*) FROM hardware_class',
                 'header'      => [ '#', 'Hardware class', '', 'Device types' ],
                 'fields'      => [ 'classnum',
                                    'classname',
                                    '',
                                    $types_sub,
                                  ],
                 'links'       => [ $class_link,
                                    $class_link,
                                    '',
                                    '',
                                  ],
             )
%>
<%init>

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

die "access denied"
  unless $curuser->access_right('Configuration');

my $menubar = 
  [ 'Hardware statuses'    => $p.'browse/hardware_status.html',
    'Add a hardware class' => $p.'edit/hardware_class.html',
    'Add a device type',   => $p.'edit/hardware_type.html', ];

my $types_sub = sub {
  my $hardware_class = shift;
  my @rows = map { 
      my $type_link = $p.'edit/hardware_type.html?'.$_->typenum;
      my $num_svcs = FS::svc_hardware->count("typenum = ".$_->typenum);
      $num_svcs = $num_svcs > 0 ? 
        mt('<B>[_1]</B> [numerate,_1,service]',$num_svcs) : '';
      my $search_link = $p.'search/svc_hardware.cgi?typenum='.$_->typenum;

      [ 
        { 'data' => $_->model, 'link' => $type_link },
        { 'data' => $_->revision, 'link' => $type_link },
        { 'data' => $num_svcs, 'link' => $search_link, 'size' => -1 }
      ]

    } $hardware_class->hardware_type;

  \@rows;
};

my $class_link = [ "${p}edit/hardware_class.html?", 'classnum' ];

</%init>