[freeside-commits] branch FREESIDE_3_BRANCH updated. e13403cc8e687d852f6986985877eaf584bb257a

Christopher Burger burgerc at freeside.biz
Thu Jan 10 06:15:45 PST 2019


The branch, FREESIDE_3_BRANCH has been updated
       via  e13403cc8e687d852f6986985877eaf584bb257a (commit)
       via  8e554db2f70c1f06cde68c138b549061514e5fdb (commit)
      from  30776e35f2b4bd50affc82bd0c3277e5b7dcad83 (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 e13403cc8e687d852f6986985877eaf584bb257a
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Jan 9 20:19:26 2019 -0500

    RT# 81249 - Fixed error where empty field becomes 0.

diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 78f5dc097..9b1652a6b 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -585,12 +585,23 @@ sub replace {
 
 sub validate_number {
   my ($option, $valref) = @_;
+
   $$valref = 0 unless $$valref;
   return "Invalid $option"
     unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/);
   return '';
 }
 
+sub validate_number_blank {
+  my ($option, $valref) = @_;
+
+  if ($$valref) {
+    return "Invalid $option"
+      unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/);
+  }
+  return '';
+}
+
 =item check
 
 Checks all fields to make sure this is a valid package definition.  If
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 3a6315910..b5da530ce 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -173,13 +173,13 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash',
                          },
 
     'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                          'validate' => \&FS::part_pkg::validate_number,
-                          'js_validate' => 'digits',
+                          'validate' => \&FS::part_pkg::validate_number_blank,
+                          'js_validate' => 'digits: true',
                          },
     
     'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                             'validate' => \&FS::part_pkg::validate_number,
-                             'js_validate' => 'digits',
+                             'validate' => \&FS::part_pkg::validate_number_blank,
+                             'js_validate' => 'digits: true',
                          },
 
     'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this calltypenum: ',
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index 22ca79694..7e8b8f052 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -64,13 +64,13 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                          },
 
     'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                          'validate' => \&FS::part_pkg::validate_number,
-                          'js_validate' => 'digits',
+                          'validate' => \&FS::part_pkg::validate_number_blank,
+                          'js_validate' => 'digits: true',
                          },
     
     'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                             'validate' => \&FS::part_pkg::validate_number,
-                             'js_validate' => 'digits',
+                             'validate' => \&FS::part_pkg::validate_number_blank,
+                             'js_validate' => 'digits: true',
                          },
 
     'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this cdrtypenum: ',
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 1755a6509..09f7655d0 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -787,13 +787,13 @@ Example:
 %     ## set extra field values for validation.  ie price plan fields
 %     my $extra_fields_to_validate = $opt{'extra_fields_validate'};
 %     my %validate_error_messages = (
-%       'digits' => 'Please only enter numbers here.',
-%       'email'  => 'Please enter a valid email here.',
+%       'digits: true' => 'Please only enter numbers here.',
+%       'email: true'  => 'Please enter a valid email here.',
 %     );
 %     foreach my $extra_fields (keys %$extra_fields_to_validate) {
 %       my $validate_type = $extra_fields_to_validate->{$extra_fields};
-%       $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type.': true';
-%       $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type};
+%       $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type;
+%      $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type};
 %     }
 
 % unless ($opt{'embed'}) {

commit 8e554db2f70c1f06cde68c138b549061514e5fdb
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Jan 9 12:28:19 2019 -0500

    RT# 81249 - added ability to validate price plan option fields
    
    Conflicts:
            httemplate/edit/part_pkg.cgi

diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index cad761498..78f5dc097 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -583,6 +583,14 @@ sub replace {
   '';
 }
 
+sub validate_number {
+  my ($option, $valref) = @_;
+  $$valref = 0 unless $$valref;
+  return "Invalid $option"
+    unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/);
+  return '';
+}
+
 =item check
 
 Checks all fields to make sure this is a valid package definition.  If
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 342f27255..3a6315910 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -173,9 +173,13 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash',
                          },
 
     'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
+                          'validate' => \&FS::part_pkg::validate_number,
+                          'js_validate' => 'digits',
                          },
     
     'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
+                             'validate' => \&FS::part_pkg::validate_number,
+                             'js_validate' => 'digits',
                          },
 
     'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this calltypenum: ',
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index 6af6dc375..22ca79694 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -64,9 +64,13 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                          },
 
     'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
+                          'validate' => \&FS::part_pkg::validate_number,
+                          'js_validate' => 'digits',
                          },
     
     'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
+                             'validate' => \&FS::part_pkg::validate_number,
+                             'js_validate' => 'digits',
                          },
 
     'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this cdrtypenum: ',
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index a919c0376..1755a6509 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -784,6 +784,18 @@ Example:
       : $opt{'html_bottom'}
 %>
 
+%     ## set extra field values for validation.  ie price plan fields
+%     my $extra_fields_to_validate = $opt{'extra_fields_validate'};
+%     my %validate_error_messages = (
+%       'digits' => 'Please only enter numbers here.',
+%       'email'  => 'Please enter a valid email here.',
+%     );
+%     foreach my $extra_fields (keys %$extra_fields_to_validate) {
+%       my $validate_type = $extra_fields_to_validate->{$extra_fields};
+%       $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type.': true';
+%       $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type};
+%     }
+
 % unless ($opt{'embed'}) {
 
   <BR>
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index c6a442b15..aa3d5acb0 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -12,6 +12,7 @@
                                          include('/elements/init_calendar.html').
                                          $javascript,
               'html_bottom'           => $html_bottom,
+              'extra_fields_validate' => $validate_priceplan_fields,
               'body_etc'              =>
                 'onLoad="agent_changed(document.edit_topform.agentnum);
                          hide_supp_pkgs()"',
@@ -352,6 +353,7 @@
 
            )
 %>
+
 <%init>
 
 my $curuser = $FS::CurrentUser::CurrentUser;
@@ -773,6 +775,15 @@ tie my %plan_labels, 'Tie::IxHash',
   map {  $_ => ( $plans{$_}->{'shortname'} || $plans{$_}->{'name'} ) }
       keys %plans;
 
+my $validate_priceplan_fields = {};
+foreach my $priceplan (keys %plans) {
+  my $plan_fields = $plans{$priceplan}->{fields};
+  foreach my $price_plan_field (keys %$plan_fields) {
+    $validate_priceplan_fields->{$priceplan."__".$price_plan_field} = $plan_fields->{$price_plan_field}->{"js_validate"}
+      if exists $plan_fields->{$price_plan_field}->{"js_validate"};
+  }
+}
+
 my $html_bottom = sub {
   my( $object ) = @_;
 
diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css
index 1e5d1e87f..dde2b0667 100644
--- a/httemplate/elements/freeside.css
+++ b/httemplate/elements/freeside.css
@@ -317,3 +317,7 @@ td.label {
   color: #ff0000;
 }
 
+.error {
+  font-size: large;
+  color: #ff0000;
+}

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

Summary of changes:
 FS/FS/part_pkg.pm                  | 19 +++++++++++++++++++
 FS/FS/part_pkg/voip_cdr.pm         |  4 ++++
 FS/FS/part_pkg/voip_inbound.pm     |  4 ++++
 httemplate/edit/elements/edit.html | 12 ++++++++++++
 httemplate/edit/part_pkg.cgi       | 11 +++++++++++
 httemplate/elements/freeside.css   |  4 ++++
 6 files changed, 54 insertions(+)




More information about the freeside-commits mailing list