Will things ever be the same again?
[freeside.git] / httemplate / browse / inventory_class.html
1 %
2 %
3 %tie my %labels, 'Tie::IxHash',
4 %  'num_avail' => 'Available', #  <FONT SIZE="-1"><A HREF="eventually">(upload batch)</A></FONT>',
5 %  'num_used'  => 'In use', #'Used', #'Allocated',
6 %  'num_total' => 'Total',
7 %;
8 %
9 %my %link = (
10 %  'num_avail' => ';avail=1',
11 %  'num_used'  => ';used=1',
12 %  'num_total' => '',
13 %);
14 %
15 %my %inv_action_link = (
16 %  'num_avail' => [ 'upload batch',
17 %                   $p.'misc/inventory_item-import.html?classnum=',
18 %                   'classnum'
19 %                 ],
20 %);
21 %
22 %my $link = [ "${p}edit/inventory_class.html?", 'classnum' ];
23 %
24 %
25 <% include( 'elements/browse.html',
26                  'title'       => 'Inventory Classes',
27                  'name'        => 'inventory classes',
28                  'menubar'     => [ 'Add a new inventory class' =>
29                                       $p.'edit/inventory_class.html',
30                                   ],
31                  'query'       => { 'table' => 'inventory_class', },
32                  'count_query' => 'SELECT COUNT(*) FROM inventory_class',
33                  'header'      => [ '#', 'Inventory class', 'Inventory' ],
34                  'fields'      => [ 'classnum',
35                                     'classname',
36                                     sub {
37                                           #my $inventory_class = shift;
38                                           my $i_c = shift;
39
40                                           my $link =
41                                             $p. 'search/inventory_item.html?'.
42                                             'classnum='. $i_c->classnum;
43
44                                           my %actioncol = ();
45                                           foreach ( keys %inv_action_link ) {
46                                             my($label, $baseurl, $method) =
47                                               @{ $inv_action_link{$_} };
48                                             my $url = $baseurl. $i_c->$method();
49                                             $actioncol{$_} =
50                                               '<FONT SIZE="-1">'.
51                                               '('.
52                                               '<A HREF="'.$url.'">'.
53                                               $label.
54                                               '</A>'.
55                                               ')'.
56                                               '</FONT>';
57                                           }
58
59                                           my %num = map { 
60                                             $_ => $i_c->$_();
61                                           } keys %labels;
62
63                                           [ map {
64                                                   [
65                                                     {
66                                                       'data'  => '<B>'. $num{$_}. '</B>',
67                                                       'align' => 'right',
68                                                     },
69                                                     {
70                                                       'data'  => $labels{$_},
71                                                       'align' => 'left',
72                                                       'link'  => ( $num{$_}
73                                                                      ? $link.$link{$_}
74                                                                      : ''
75                                                                  ),
76                                                     },
77                                                     { 'data'  => $actioncol{$_},
78                                                       'align'  => 'left',
79                                                     },
80                                                   ]
81                                                 } keys %labels
82                                           ];
83                                         },
84                                   ],
85                  'links'       => [ $link,
86                                     $link,
87                                     '',
88                                   ],
89              )
90 %>