[freeside-commits] branch master updated. 315ffb86414145b95f2541db8f9d89c1f7e71e3f

Alex Brelsfoard alex at 420.am
Tue Jan 27 13:38:29 PST 2015


The branch, master has been updated
       via  315ffb86414145b95f2541db8f9d89c1f7e71e3f (commit)
      from  ffa2c69b3170181065cfe3f249d6f0508c06b48e (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 315ffb86414145b95f2541db8f9d89c1f7e71e3f
Author: Alex Brelsfoard <alex at freeside.biz>
Date:   Tue Jan 27 16:36:47 2015 -0500

    rt #28256

diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index c4db83a..778a026 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -959,7 +959,21 @@ 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 @suspend_credit_type_conf = qsearch('conf', { 'name' => 'suspend_credit_type' } );
+                return 1 if (exists($suspend_credit_type_conf[0]) && $suspend_credit_type_conf[0]->{Hash}{value});
+                return 0;
+            }
+        }
+    };
+    
     foreach my $field ( grep $_ !~ /^(setup|recur)_fee$/, @fields ) {
   
       if(!exists($href->{$field})) {
@@ -981,7 +995,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 |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list