[freeside-commits] branch FREESIDE_3_BRANCH updated. 44a6a51f69db394925134ade34a7a948885034c5

Alex Brelsfoard alex at 420.am
Tue Jan 27 18:35:02 PST 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  44a6a51f69db394925134ade34a7a948885034c5 (commit)
      from  d8fdbc2678c40a418b0a33cb0bfc6d18850ca4b1 (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 44a6a51f69db394925134ade34a7a948885034c5
Author: Alex Brelsfoard <alex at freeside.biz>
Date:   Tue Jan 27 21:34:33 2015 -0500

    RT #28256: disable unused_credit_suspend and unused_credit_cancel packaging options when appropriate config setting not set.

diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index cc9ab10..48f5e55 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -869,7 +869,30 @@ my $html_bottom = sub {
     my @fields = exists($plans{$layer}->{'fieldorder'})
                    ? @{$plans{$layer}->{'fieldorder'}}
                    : keys %{ $href };
-  
+    
+    # hash of dependencies for each of the Pricing Plan fields.
+    # make sure NOT to use double-quotes inside the 'msg' value.
+    my $dependencies = {
+        'unused_credit_suspend' => {
+            'msg'       => q|You must set the 'suspend_credit_type' option in Configuration->Settings to gain access to this option.|,
+            'are_met'   => sub{
+                my $conf = new FS::conf;
+                my @conf_info = qsearch('conf', { 'name' => 'suspend_credit_type' } );
+                return 1 if (exists($conf_info[0]) && $conf_info[0]->{Hash}{value});
+                return 0;
+            }
+        },
+        'unused_credit_cancel' => {
+            'msg'       => q|You must set the 'suspend_credit_type' option in Configuration->Settings to gain access to this option.|,
+            'are_met'   => sub{
+                my $conf = new FS::conf;
+                my @conf_info = qsearch('conf', { 'name' => 'cancel_credit_type' } );
+                return 1 if (exists($conf_info[0]) && $conf_info[0]->{Hash}{value});
+                return 0;
+            }
+        }
+    };
+
     foreach my $field ( grep $_ !~ /^(setup|recur)_fee$/, @fields ) {
   
       if(!exists($href->{$field})) {
@@ -891,7 +914,10 @@ my $html_bottom = sub {
       #XXX these should use elements/ fields... (or this whole thing should
       #just use layer_fields instead of layer_callback)
   
-      if ( ! exists($href->{$field}{'type'}) ) {
+      if (exists($dependencies->{$field}) && !$dependencies->{$field}{'are_met'}()) {
+          $html .= q!<span title="!.$dependencies->{$field}{'msg'}.q!">N/A</span>!;
+          
+      } elsif ( ! exists($href->{$field}{'type'}) ) {
   
         $html .= qq!<INPUT TYPE="text" NAME="${layer}__$field" VALUE="!.
                  ( exists($options{$field})


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

Summary of changes:
 httemplate/edit/part_pkg.cgi |   30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list