X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_pkg.cgi;h=bdceb3364baa9969f46b4ab19e4389ce13725f45;hb=27b43d1c9e3af3b8d384d1a30abc2922c1ac6ed7;hp=cc9ab100173f3eae62d6cb1da642110e55f75159;hpb=6199f898a744f2cc2f9f03450d49286866a3f4d0;p=freeside.git
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index cc9ab1001..bdceb3364 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 'cancel_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!N/A!;
+
+ } elsif ( ! exists($href->{$field}{'type'}) ) {
$html .= qq!