[freeside-commits] branch FREESIDE_4_BRANCH updated. fd068873ca79b92bed2b8bdca68d52f4342faeac

Ivan ivan at 420.am
Thu Apr 27 15:31:09 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  fd068873ca79b92bed2b8bdca68d52f4342faeac (commit)
      from  bcec9544f1786221b1c87c3f7df21ba87b1d9ab2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fd068873ca79b92bed2b8bdca68d52f4342faeac
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Apr 27 15:31:08 2017 -0700

    discount action UI improvements: don't show 'Custom discount' which we can't add on the fly, RT#75536

diff --git a/FS/FS/part_event/Action/pkg_discount.pm b/FS/FS/part_event/Action/pkg_discount.pm
index bae3c34..a10822e 100644
--- a/FS/FS/part_event/Action/pkg_discount.pm
+++ b/FS/FS/part_event/Action/pkg_discount.pm
@@ -26,12 +26,15 @@ sub option_fields {
     'discountnum' => { 'label'    => 'Discount',
                        'type'     => 'select-table', #we don't handle the select-discount create a discount case
                        'table'    => 'discount',
-                       'name_col' => 'description', #well, method
-                       'order_by' => 'ORDER BY discountnum', #requied because name_col is a method
+                       #(well, since 2013 it winds up calling select-discount
+                       # anyway (but not tr-select-discount)
+                       #'name_col' => 'description', #well, method
+                       #'order_by' => 'ORDER BY discountnum', #requied because name_col is a method
+                       'disable_empty' => 1,
                        'hashref'  => { 'disabled' => '',
                                        'months'   => { op=>'!=', value=>'0' },
                                      },
-                       'disable_empty' => 1,
+                       'disable_custom_discount' => 1,
                      },
   );
 }
diff --git a/httemplate/elements/select-discount.html b/httemplate/elements/select-discount.html
index b7f1fa5..3a267ed 100644
--- a/httemplate/elements/select-discount.html
+++ b/httemplate/elements/select-discount.html
@@ -4,7 +4,7 @@
                  'order_by'     => 'ORDER BY discountnum', #XXX weight
                  'value'        => $discountnum,
                  'empty_label'  => '(none)',
-                 'hashref'      => { 'disabled' => '' },
+                 'hashref'      => $hashref,
                  'post_options' => $post_options,
                  %opt,
              )
@@ -19,10 +19,12 @@ $opt{'records'} = delete $opt{'discount'}
 
 my $curuser = $FS::CurrentUser::CurrentUser;
 
-#make an opt if we need to turn this off
-my $post_options = $curuser->access_right('Custom discount customer package')
-  ? [ -1 => 'Custom discount' ]
-  : [];
+my $hashref = $opt{hashref} || { 'disabled' => '' };
+
+my $post_options = [];
+push @$post_options,  -1 => 'Custom discount'
+  if $curuser->access_right('Custom discount customer package')
+  && ! $opt{disable_custom_discount};
 
 </%init>
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_event/Action/pkg_discount.pm  |    9 ++++++---
 httemplate/elements/select-discount.html |   12 +++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)




More information about the freeside-commits mailing list