summaryrefslogtreecommitdiff
path: root/httemplate/browse/part_fee.html
blob: 482c692d7ee7a2f1a37464e323a55f03e9f708c0 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<& elements/browse.html,
  title           => 'Fee definitions',
  name_singular   => 'fee definition',
  query           => $query,
  count_query     => $count_query,
  header          => [  '#',
                        'Description',
                        'Comment',
                        'Class',
                        'Amount',
                        'Tax status',
                     ],
  fields          => [  'feepart',
                        'itemdesc',
                        'comment',
                        'classname',
                        $sub_amount,
                        $sub_tax,
                     ],
  disableable     => 1,
  disabled_statuspos => 3,
  agent_pos       => 6,
  agent_virt      => 1,
  agent_null_right=> 'Edit global fee definitions',
  links           => [  '',
                        $link,
                        $link,
                     ],
  align           => 'cllccc',
  menubar         => \@menubar,
&>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
my $acl_edit = $curuser->access_right('Edit fee definitions');
my $acl_edit_global = $curuser->access_right('Edit global fee definitions');
die "access denied"
  unless $acl_edit or $acl_edit_global;

my $query = {
  'select'    => 'part_fee.*,'.
                 '(select classname from pkg_class '.
                 'where pkg_class.classnum = part_fee.classnum) AS classname',
  'table'     => 'part_fee',  
};
my $count_query = "SELECT COUNT(*) FROM part_fee";

my $sub_amount = sub {
  my $obj = shift;
  my $string = $obj->explanation;
  $string =~ s/\n/<br>/sg;
  $string;
};

my $sub_tax = sub {
  my $obj = shift;
  if ( $obj->taxable ) {
    return $obj->taxclass || 'taxable';
  } elsif ( $obj->taxproductnum ) {
    return join('<br>', 
      split(/\s*:\s*/, $obj->part_pkg_taxproduct->description)
    );
  } else {
    return 'exempt';
  }
};

my $link = [ $p.'edit/part_fee.html?', 'feepart' ];

my @menubar = ( 'Add a new fee definition',
                $p.'edit/part_fee.html' );
</%init>