non-package fees, phase 1, #25899
[freeside.git] / httemplate / browse / part_fee.html
1 <& elements/browse.html,
2   'title'         => 'Fee definitions',
3   'name_singular' => 'fee definition',
4   'query'         => $query,
5   'count_query'   => $count_query,
6   'header'        => [  '#',
7                         'Description',
8                         'Comment',
9                         'Class',
10                         'Amount',
11                         'Tax status',
12                      ],
13   'fields'        => [  'feepart',
14                         'itemdesc',
15                         'comment',
16                         'classname',
17                         $sub_amount,
18                         $sub_tax,
19                      ],
20   disableable     => 1,
21   disabled_statuspos => 3,
22   agent_pos       => 6,
23   agent_virt      => 1,
24   agent_null_right=> 'Edit global fee definitions',
25   links           => [  '',
26                         $link,
27                         $link,
28                      ],
29   align           => 'cllccc',
30 &>
31 <%init>
32 my $curuser = $FS::CurrentUser::CurrentUser;
33 my $acl_edit = $curuser->access_right('Edit fee definitions');
34 my $acl_edit_global = $curuser->access_right('Edit global fee definitions');
35 die "access denied"
36   unless $acl_edit or $acl_edit_global;
37
38 my $query = {
39   'select'    => 'part_fee.*,'.
40                  '(select classname from pkg_class '.
41                  'where pkg_class.classnum = part_fee.classnum) AS classname',
42   'table'     => 'part_fee',  
43 };
44 my $count_query = "SELECT COUNT(*) FROM part_fee";
45
46 my $sub_amount = sub {
47   my $obj = shift;
48   my $string = $obj->explanation;
49   $string =~ s/\n/<br>/sg;
50   $string;
51 };
52
53 my $sub_tax = sub {
54   my $obj = shift;
55   if ( $obj->taxable ) {
56     return $obj->taxclass || 'taxable';
57   } elsif ( $obj->taxproductnum ) {
58     return join('<br>', 
59       split(/\s*:\s*/, $obj->part_pkg_taxproduct->description)
60     );
61   } else {
62     return 'exempt';
63   }
64 };
65
66 my $link = [ $p.'edit/part_fee.html?', 'feepart' ];
67 </%init>