not enough sleep to support multiple internal_prefixen, RT#3985
[freeside.git] / FS / FS / part_pkg / voip_cdr.pm
index 979134a..794ae01 100644 (file)
@@ -80,7 +80,7 @@ tie my %temporalities, 'Tie::IxHash',
 #                                    'type' => 'checkbox',
 #                                  },
 
-    'international_prefix' => { 'name'    => 'Destination prefix for international CDR records',
+    'international_prefix' => { 'name'    => 'Destination prefix(es) for international CDR records.  Separate multiple options with commas.',
                                 'default' => '011',
                               },
 
@@ -277,13 +277,23 @@ sub calc_recur {
 #          $dest =~ s/\@(.*)$// and $siphost = $1; # @10.54.32.1, @sip.example.com
 
           my $intl = $self->option('international_prefix') || '011';
+          my @intl = ();
+          if ( $intl =~ /,/ ) {
+            @intl = split(/\s*,\s*/, $intl);
+          } else {
+            @intl = ($intl);
+          }
 
           #determine the country code
+          my $intl_match = 0;
+          foreach my $i (@intl) {
+            if ( $number =~ /^$i(((\d)(\d))(\d))(\d+)$/ ) {
+              $intl_match++;
+              last;
+            }
+          }
           my $countrycode;
-          if (    $number =~ /^$intl(((\d)(\d))(\d))(\d+)$/
-               || $number =~ /^\+(((\d)(\d))(\d))(\d+)$/
-             )
-          {
+          if ( $intl_match || $number =~ /^\+(((\d)(\d))(\d))(\d+)$/ ) {
 
             my( $three, $two, $one, $u1, $u2, $rest ) = ( $1,$2,$3,$4,$5,$6 );
             #first look for 1 digit country code