X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_phone.pm;h=071b8073cddda48854a6b3d8cc93c1e5b3bfc76d;hb=9ad4f8407cc106ef5815e65bce2ee873cd0896c2;hp=11a5a0ee0d1dec024a831635f45f87452dc2e231;hpb=833feb1713594b0146c230f8957d91e14ba0e436;p=freeside.git diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 11a5a0ee0..071b8073c 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -8,6 +8,7 @@ use FS::Msgcat qw(gettext); use FS::svc_Common; use FS::part_svc; use FS::phone_device; +use FS::svc_pbx; @ISA = qw( FS::svc_Common ); @@ -67,6 +68,10 @@ Voicemail PIN =item phone_name +=item pbxsvc + +Optional svcnum from svc_pbx + =back =head1 METHODS @@ -104,6 +109,11 @@ sub table_info { }, 'sip_password' => 'SIP password', 'phone_name' => 'Name', + 'pbxsvc' => { label => 'PBX', + type => 'select-svc_pbx.html', + disable_inventory => 1, + disable_select => 1, #UI wonky, pry works otherwise + }, }, }; } @@ -120,6 +130,22 @@ Class method which returns an SQL fragment to search for the given string. sub search_sql { my( $class, $string ) = @_; + + if ( $conf->exists('svc_phone-allow_alpha_phonenum') ) { + $string =~ s/\W//g; + } else { + $string =~ s/\D//g; + } + + my $conf = new FS::Conf; + my $ccode = ( $conf->exists('default_phone_countrycode') + && $conf->config('default_phone_countrycode') + ) + ? $conf->config('default_phone_countrycode') + : '1'; + + $string =~ s/^$ccode//; + $class->search_sql_field('phonenum', $string ); } @@ -242,6 +268,7 @@ sub check { || $self->ut_anything('sip_password') || $self->ut_numbern('pin') || $self->ut_textn('phone_name') + || $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' ) ; return $error if $error;