fix FK upgrade for pkg_referral: remove records referencing non-existant customer...
[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   menubar         => \@menubar,
31 &>
32 <%init>
33 my $curuser = $FS::CurrentUser::CurrentUser;
34 my $acl_edit = $curuser->access_right('Edit fee definitions');
35 my $acl_edit_global = $curuser->access_right('Edit global fee definitions');
36 die "access denied"
37   unless $acl_edit or $acl_edit_global;
38
39 my $query = {
40   'select'    => 'part_fee.*,'.
41                  '(select classname from pkg_class '.
42                  'where pkg_class.classnum = part_fee.classnum) AS classname',
43   'table'     => 'part_fee',  
44 };
45 my $count_query = "SELECT COUNT(*) FROM part_fee";
46
47 my $sub_amount = sub {
48   my $obj = shift;
49   my $string = $obj->explanation;
50   $string =~ s/\n/<br>/sg;
51   $string;
52 };
53
54 my $sub_tax = sub {
55   my $obj = shift;
56   if ( $obj->taxable ) {
57     return $obj->taxclass || 'taxable';
58   } elsif ( $obj->taxproductnum ) {
59     return join('<br>', 
60       split(/\s*:\s*/, $obj->part_pkg_taxproduct->description)
61     );
62   } else {
63     return 'exempt';
64   }
65 };
66
67 my $link = [ $p.'edit/part_fee.html?', 'feepart' ];
68
69 my @menubar = ( 'Add a new fee definition',
70                 $p.'edit/part_fee.html' );
71 </%init>