[freeside-commits] freeside/FS/FS/part_export internal_diddb.pm, 1.2, 1.3

Ivan,,, ivan at wavetail.420.am
Mon Nov 24 02:59:51 PST 2008


Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail.420.am:/tmp/cvs-serv18937

Modified Files:
	internal_diddb.pm 
Log Message:
add countrycode option to internal_diddb; throw a warning instead of an error if a number couldn't be returned to inventory

Index: internal_diddb.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/internal_diddb.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- internal_diddb.pm	29 Oct 2008 07:50:09 -0000	1.2
+++ internal_diddb.pm	24 Nov 2008 10:59:49 -0000	1.3
@@ -1,17 +1,22 @@
 package FS::part_export::internal_diddb;
 
 use vars qw(@ISA %info);
-#use Tie::IxHash;
+use Tie::IxHash;
 use FS::Record qw(qsearch qsearchs);
 use FS::part_export;
 use FS::phone_avail;
 
 @ISA = qw(FS::part_export);
 
+tie my %options, 'Tie::IxHash',
+  'countrycode' => { label => 'Country code', 'default' => '1', },
+;
+
 %info = (
-  'svc'   => 'svc_phone',
-  'desc'  => 'Provision phone numbers from the internal DID database',
-  'notes' => 'After adding the export, DIDs may be imported under Tools -> Importing -> Import phone numbers (DIDs)',
+  'svc'     => 'svc_phone',
+  'desc'    => 'Provision phone numbers from the internal DID database',
+  'notes'   => 'After adding the export, DIDs may be imported under Tools -> Importing -> Import phone numbers (DIDs)',
+  'options' => \%options,
 );
 
 sub rebless { shift; }
@@ -20,7 +25,7 @@
   my $self = shift;
   my %opt = ref($_[0]) ? %{$_[0]} : @_;
 
-  my %hash = ( 'countrycode' => 1, #XXX make an option or something
+  my %hash = ( 'countrycode' => $self->option('countrycode'),
                'exportnum'   => $self->exportnum,
                'svcnum'      => '',
              );
@@ -75,7 +80,7 @@
   my( $npa, $nxx, $station ) = ($1, $2, $3);
 
   my $phone_avail = qsearchs('phone_avail', {
-    'countrycode' => 1, #XXX make an option or something
+    'countrycode' => $self->option('countrycode'),
     'exportnum'   => $self->exportnum,
     'svcnum'      => '',
     'npa'         => $npa,
@@ -100,7 +105,7 @@
   my( $npa, $nxx, $station ) = ($1, $2, $3);
 
   my $phone_avail = qsearchs('phone_avail', {
-    'countrycode' => 1, #XXX make an option or something
+    'countrycode' => $self->option('countrycode'),
     'exportnum'   => $self->exportnum,
     'svcnum'      => $svc_phone->svcnum,
     #these too?
@@ -109,8 +114,11 @@
     'station'     => $station,
   });
 
-  return "can't find number to return to availability: ". $svc_phone->phonenum
-    unless $phone_avail;
+  unless ( $phone_avail ) {
+    warn "WARNING: can't find number to return to availability: ".
+         $svc_phone->phonenum;
+    return;
+  }
 
   $phone_avail->svcnum('');
 



More information about the freeside-commits mailing list