X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fphone_device.pm;fp=FS%2FFS%2Fphone_device.pm;h=1bdbc3428ac7033c64b8c10abb67ab9c41c88394;hb=ef49390629d8bd97cc4f607b559c9552aa86b482;hp=a7097a1134124f47d4cfdedb17ccdbfc652e42eb;hpb=55c933db01346b350ad08c03246ca0db0473c056;p=freeside.git diff --git a/FS/FS/phone_device.pm b/FS/FS/phone_device.pm index a7097a113..1bdbc3428 100644 --- a/FS/FS/phone_device.pm +++ b/FS/FS/phone_device.pm @@ -2,7 +2,7 @@ package FS::phone_device; use strict; use base qw( FS::Record ); -use FS::Record qw( qsearchs ); # qsearch ); +use FS::Record qw( dbh qsearchs ); # qsearch ); use FS::part_device; use FS::svc_phone; @@ -76,7 +76,32 @@ otherwise returns false. =cut -# the insert method can be inherited from FS::Record +sub insert { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $error = $self->SUPER::insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $self->svc_phone->export('device_insert', $self); #call device export + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} + =item delete @@ -84,7 +109,31 @@ Delete this record from the database. =cut -# the delete method can be inherited from FS::Record +sub delete { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + $self->svc_phone->export('device_delete', $self); #call device export + + my $error = $self->SUPER::delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} =item replace OLD_RECORD @@ -93,7 +142,35 @@ returns the error, otherwise returns false. =cut -# the replace method can be inherited from FS::Record +sub replace { + my $new = shift; + + my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') ) + ? shift + : $new->replace_old; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $error = $new->SUPER::replace($old); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $new->svc_phone->export('device_replace', $new, $old); #call device export + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} =item check @@ -137,6 +214,18 @@ sub part_device { qsearchs( 'part_device', { 'devicepart' => $self->devicepart } ); } +=item svc_phone + +Returns the phone number (see L) associated with this customer +device. + +=cut + +sub svc_phone { + my $self = shift; + qsearchs( 'svc_phone', { 'svcnum' => $self->svcnum } ); +} + =back =head1 BUGS