X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_phone.pm;h=56104ba619459d3793cb3395c81dede7cf071270;hb=10614457fd7db63cbcc0bf9bfeebbbb99258eaa3;hp=067768809cae72f805ee61f59dfbc0c78471cb7c;hpb=8a20eb962b913cbe9e23fca078a4d9c6696db594;p=freeside.git diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 067768809..56104ba61 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -8,6 +8,7 @@ use vars qw( $DEBUG $me @pw_set $conf $phone_name_max use Data::Dumper; use Scalar::Util qw( blessed ); use List::Util qw( min ); +use Tie::IxHash; use FS::Conf; use FS::Record qw( qsearch qsearchs dbh ); use FS::PagedSearch qw( psearch ); @@ -125,6 +126,14 @@ Account number of other provider. See lnp_other_provider. See lnp_status. If lnp_status is portin-reject or portout-reject, this is an optional reject reason. +=item e911_class + +Class of Service for E911 service (per the NENA 2.1 standard). + +=item e911_type + +Type of Service for E911 service. + =back =head1 METHODS @@ -178,6 +187,14 @@ sub table_info { select_label => 'domain', disable_inventory => 1, }, + 'circuit_svcnum' => { label => 'Circuit', + type => 'select', + select_table => 'svc_domain', + select_key => 'svcnum', + select_label => 'circuit_label', + disable_inventory => 1, + }, + 'sms_carrierid' => { label => 'SMS Carrier', type => 'select', select_table => 'cdr_carrier', @@ -222,6 +239,18 @@ sub table_info { { label => 'LNP Other Provider Account #', %dis2 }, + 'e911_class' => { + label => 'E911 Service Class', + type => 'select-e911_class', + disable_inventory => 1, + multiple => 1, + }, + 'e911_type' => { + label => 'E911 Service Type', + type => 'select-e911_type', + disable_inventory => 1, + multiple => 1, + }, }, }; } @@ -431,11 +460,20 @@ sub replace { ); my $error = $new->SUPER::replace($old, %options); + + # if this changed the e911 location, notify exports + if ($new->locationnum ne $old->locationnum) { + my $new_location = $new->cust_location_or_main; + my $old_location = $new->cust_location_or_main; + $error ||= $new->export('relocate', $new_location, $old_location); + } + if ( $error ) { $dbh->rollback if $oldAutoCommit; return $error if $error; } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; #no error } @@ -561,6 +599,13 @@ sub check { } + if ($self->e911_class and !exists(e911_classes()->{$self->e911_class})) { + return "undefined e911 class '".$self->e911_class."'"; + } + if ($self->e911_type and !exists(e911_types()->{$self->e911_type})) { + return "undefined e911 type '".$self->e911_type."'"; + } + $self->SUPER::check; } @@ -674,6 +719,8 @@ sub radius_groups { =item sms_cdr_carrier +Returns the L assigned as the SMS carrier for this phone. + =cut sub sms_cdr_carrier { @@ -684,6 +731,8 @@ sub sms_cdr_carrier { =item sms_carriername +Returns the name of the SMS carrier, or an empty string if there isn't one. + =cut sub sms_carriername { @@ -692,6 +741,29 @@ sub sms_carriername { $cdr_carrier->carriername; } +=item svc_circuit + +Returns the L assigned as the trunk for this phone line. + +=item circuit_label + +Returns the label of the circuit (the part_svc label followed by the +circuit ID), or an empty string if there isn't one. + +=cut + +sub svc_circuit { + my $self = shift; + my $svcnum = $self->get('circuit_svcnum') or return ''; + return FS::svc_circuit->by_key($svcnum); +} + +sub circuit_label { + my $self = shift; + my $svc_circuit = $self->svc_circuit or return ''; + return join(' ', $svc_circuit->part_svc->svc, $svc_circuit->circuit_id); +} + =item phone_device Returns any FS::phone_device records associated with this service. @@ -714,6 +786,26 @@ sub cust_location_or_main { $cust_pkg ? $cust_pkg->cust_location_or_main : ''; } +=item phone_name_or_cust + +Returns the C field if it has a value, or the package contact +name if there is one, or the customer contact name. + +=cut + +sub phone_name_or_cust { + my $self = shift; + if ( $self->phone_name ) { + return $self->phone_name; + } + my $cust_pkg = $self->cust_svc->cust_pkg or return ''; + if ( $cust_pkg->contactnum ) { + return $cust_pkg->contact->firstlast; + } else { + return $cust_pkg->cust_main->name_short; + } +} + =item psearch_cdrs OPTIONS Returns a paged search (L) for Call Detail Records @@ -874,6 +966,67 @@ sub sum_cdrs { =back +=head1 CLASS METHODS + +=over 4 + +=item e911_classes + +Returns a hashref of allowed values and descriptions for the C +field. + +=item e911_types + +Returns a hashref of allowed values and descriptions for the C +field. + +=cut + +sub e911_classes { + tie my %x, 'Tie::IxHash', ( + 1 => 'Residence', + 2 => 'Business', + 3 => 'Residence PBX', + 4 => 'Business PBX', + 5 => 'Centrex', + 6 => 'Coin 1 Way out', + 7 => 'Coin 2 Way', + 8 => 'Mobile', + 9 => 'Residence OPX', + 0 => 'Business OPX', + A => 'Customer Operated Coin Telephone', + #B => not available + G => 'Wireless Phase I', + H => 'Wireless Phase II', + I => 'Wireless Phase II with Phase I information', + V => 'VoIP Services Default', + C => 'VoIP Residence', + D => 'VoIP Business', + E => 'VoIP Coin/Pay Phone', + F => 'VoIP Wireless', + J => 'VoIP Nomadic', + K => 'VoIP Enterprise Services', + T => 'Telematics', + ); + \%x; +} + +sub e911_types { + tie my %x, 'Tie::IxHash', ( + 0 => 'Not FX nor Non-Published', + 1 => 'FX in 911 serving area', + 2 => 'FX outside 911 serving area', + 3 => 'Non-Published', + 4 => 'Non-Published FX in serving area', + 5 => 'Non-Published FX outside serving area', + 6 => 'Local Ported Number', + 7 => 'Interim Ported Number', + ); + \%x; +} + +=back + =head1 BUGS =head1 SEE ALSO