diff options
author | Ivan Kohler <ivan@freeside.biz> | 2016-03-02 15:05:49 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2016-03-02 15:05:49 -0800 |
commit | ff9aba5784969ab5a40963686f071728ac89949f (patch) | |
tree | bf9a59c002d0e369517947100ff63911ae5b7444 /httemplate/view/cust_main/packages | |
parent | 4b2b65e322f09922513d6d23fc50bfe3b69af36d (diff) |
optimize customer package lists, RT#39822
Diffstat (limited to 'httemplate/view/cust_main/packages')
-rw-r--r-- | httemplate/view/cust_main/packages/package.html | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/httemplate/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html index dec1c6f40..e167e2625 100644 --- a/httemplate/view/cust_main/packages/package.html +++ b/httemplate/view/cust_main/packages/package.html @@ -429,19 +429,25 @@ sub pkg_event_link { # figure out if this user will be able to edit either the setup or recurring # discounts for this package -my $can_discount_pkg = ( - $part_pkg->can_discount - and - ( ( $curuser->access_right(['Discount customer package', 'Waive setup fee']) - and $cust_pkg->base_setup > 0 - and !$cust_pkg->setup - ) - or - ( $curuser->access_right('Discount customer package') - and $cust_pkg->base_recur > 0 - and $cust_pkg->freq ne '0' - ) - ) -); +my $can_discount_pkg = 0; + +if ( $part_pkg->can_discount ) { + #looking these up individually uses the ACL cache and is a big win for lots + # of packages + my $discount = $curuser->access_right('Discount customer package'); + my $waive = $curuser->access_right('Waive setup fee'); + + $can_discount_pkg = + ( ($discount || $waive) + && $cust_pkg->base_setup > 0 + && !$cust_pkg->setup + or + ( $discount + && $cust_pkg->base_recur > 0 + && $cust_pkg->freq ne '0' + ) + ); + +} </%init> |