diff options
author | ivan <ivan> | 2010-03-12 03:36:36 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-03-12 03:36:36 +0000 |
commit | 9e570867c27b5336f4fa701c84b70fd65791f87c (patch) | |
tree | d1d495861d3dcd54457604e09eecacc813fcbcf1 /FS | |
parent | 1cc9a75a47a548fc8a200371c88647f34c71db14 (diff) |
add location to svc_phone, RT#7047
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 30 | ||||
-rw-r--r-- | FS/FS/location_Mixin.pm | 43 | ||||
-rw-r--r-- | FS/FS/svc_phone.pm | 9 | ||||
-rw-r--r-- | FS/t/location_Mixin.t | 5 |
5 files changed, 66 insertions, 26 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 3754f2254..2cfe4b4be 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2595,10 +2595,13 @@ sub tables_hashref { 'phone_name', 'varchar', 'NULL', $char_d, '', '', 'pbxsvc', 'int', 'NULL', '', '', '', 'domsvc', 'int', 'NULL', '', '', '', + 'locationnum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'svcnum', 'unique' => [], - 'index' => [ [ 'countrycode', 'phonenum' ], ['pbxsvc'], ['domsvc'] ], + 'index' => [ ['countrycode', 'phonenum'], ['pbxsvc'], ['domsvc'], + ['locationnum'], + ], }, 'phone_device' => { diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 4d4f1fa4b..bbcfeb122 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -1,6 +1,9 @@ package FS::cust_pkg; use strict; +use base qw( FS::cust_main_Mixin FS::location_Mixin + FS::m2m_Common FS::option_Common FS::Record + ); use vars qw(@ISA $disable_agentcheck $DEBUG $me); use Carp qw(cluck); use Scalar::Util qw( blessed ); @@ -11,8 +14,6 @@ use MIME::Entity; use FS::UID qw( getotaker dbh ); use FS::Misc qw( send_email ); use FS::Record qw( qsearch qsearchs ); -use FS::m2m_Common; -use FS::cust_main_Mixin; use FS::cust_svc; use FS::part_pkg; use FS::cust_main; @@ -41,8 +42,6 @@ use FS::svc_forward; # for sending cancel emails in sub cancel use FS::Conf; -@ISA = qw( FS::m2m_Common FS::cust_main_Mixin FS::option_Common FS::Record ); - $DEBUG = 0; $me = '[FS::cust_pkg]'; @@ -1960,41 +1959,24 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } +#these subs are in location_Mixin.pm now... unfortunately the POD doesn't mixin + =item cust_location Returns the location object, if any (see L<FS::cust_location>). -=cut - -sub cust_location { - my $self = shift; - return '' unless $self->locationnum; - qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } ); -} - =item cust_location_or_main If this package is associated with a location, returns the locaiton (see L<FS::cust_location>), otherwise returns the customer (see L<FS::cust_main>). -=cut - -sub cust_location_or_main { - my $self = shift; - $self->cust_location || $self->cust_main; -} - =item location_label [ OPTION => VALUE ... ] Returns the label of the location object (see L<FS::cust_location>). =cut -sub location_label { - my $self = shift; - my $object = $self->cust_location_or_main; - $object->location_label(@_); -} +#end of subs in location_Mixin.pm now... unfortunately the POD doesn't mixin =item seconds_since TIMESTAMP diff --git a/FS/FS/location_Mixin.pm b/FS/FS/location_Mixin.pm new file mode 100644 index 000000000..675e00255 --- /dev/null +++ b/FS/FS/location_Mixin.pm @@ -0,0 +1,43 @@ +package FS::location_Mixin; + +use strict; +use FS::Record qw( qsearchs ); +use FS::cust_location; + +=item cust_location + +Returns the location object, if any (see L<FS::cust_location>). + +=cut + +sub cust_location { + my $self = shift; + return '' unless $self->locationnum; + qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } ); +} + +=item cust_location_or_main + +If this package is associated with a location, returns the locaiton (see +L<FS::cust_location>), otherwise returns the customer (see L<FS::cust_main>). + +=cut + +sub cust_location_or_main { + my $self = shift; + $self->cust_location || $self->cust_main; +} + +=item location_label [ OPTION => VALUE ... ] + +Returns the label of the location object (see L<FS::cust_location>). + +=cut + +sub location_label { + my $self = shift; + my $object = $self->cust_location_or_main; + $object->location_label(@_); +} + +1; diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 0ed01ad36..7405a71fd 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -1,7 +1,7 @@ package FS::svc_phone; use strict; -use base qw( FS::svc_Domain_Mixin FS::svc_Common ); +use base qw( FS::svc_Domain_Mixin FS::location_Mixin FS::svc_Common ); use vars qw( @pw_set $conf ); use FS::Conf; use FS::Record qw( qsearch qsearchs dbh ); @@ -10,6 +10,7 @@ use FS::part_svc; use FS::phone_device; use FS::svc_pbx; use FS::svc_domain; +use FS::cust_location; #avoid l 1 and o O 0 @pw_set = ( 'a'..'k', 'm','n', 'p-z', 'A'..'N', 'P'..'Z' , '2'..'9' ); @@ -121,6 +122,11 @@ sub table_info { select_label => 'domain', disable_inventory => 1, }, + 'locationnum' => { + label => 'E911 location', + disable_inventory => 1, + disable_select => 1, + }, }, }; } @@ -278,6 +284,7 @@ sub check { || $self->ut_textn('phone_name') || $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' ) || $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' ) + || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum') ; return $error if $error; diff --git a/FS/t/location_Mixin.t b/FS/t/location_Mixin.t new file mode 100644 index 000000000..b6a9bf23f --- /dev/null +++ b/FS/t/location_Mixin.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::location_Mixin; +$loaded=1; +print "ok 1\n"; |