4a15bf7d40a58bf74bf008e96501fedafd9e3336
[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 %><%= include( 'elements/browse.html',
25                  'title'       => 'Inventory Classes',
26                  'name'        => 'inventory classes',
27                  'menubar'     => [ 'Add a new inventory class' =>
28                                       $p.'edit/inventory_class.html',
29                                   ],
30                  'query'       => { 'table' => 'inventory_class', },
31                  'count_query' => 'SELECT COUNT(*) FROM inventory_class',
32                  'header'      => [ '#', 'Inventory class', 'Inventory' ],
33                  'fields'      => [ 'classnum',
34                                     'classname',
35                                     sub {
36                                           #my $inventory_class = shift;
37                                           my $i_c = shift;
38
39                                           my $link =
40                                             $p. 'search/inventory_item.html?'.
41                                             'classnum='. $i_c->classnum;
42
43                                           my %actioncol = ();
44                                           foreach ( keys %inv_action_link ) {
45                                             my($label, $baseurl, $method) =
46                                               @{ $inv_action_link{$_} };
47                                             my $url = $baseurl. $i_c->$method();
48                                             $actioncol{$_} =
49                                               '<FONT SIZE="-1">'.
50                                               '('.
51                                               '<A HREF="'.$url.'">'.
52                                               $label.
53                                               '</A>'.
54                                               ')'.
55                                               '</FONT>';
56                                           }
57
58                                           my %num = map { 
59                                             $_ => $i_c->$_();
60                                           } keys %labels;
61
62                                           [ map {
63                                                   [
64                                                     {
65                                                       'data'  => '<B>'. $num{$_}. '</B>',
66                                                       'align' => 'right',
67                                                     },
68                                                     {
69                                                       'data'  => $labels{$_},
70                                                       'align' => 'left',
71                                                       'link'  => ( $num{$_}
72                                                                      ? $link.$link{$_}
73                                                                      : ''
74                                                                  ),
75                                                     },
76                                                     { 'data'  => $actioncol{$_},
77                                                       'align'  => 'left',
78                                                     },
79                                                   ]
80                                                 } keys %labels
81                                           ];
82                                         },
83                                   ],
84                  'links'       => [ $link,
85                                     $link,
86                                     '',
87                                   ],
88              )
89 %>