X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fphone_device.pm;h=914f735b68196dbc0b0410a85a5785f5baad7a44;hb=1bfbab83c338f6a11ae26c4d197ad775c568ebde;hp=a7097a1134124f47d4cfdedb17ccdbfc652e42eb;hpb=665067cef48a5516e0bfb2dd79d99b8495e25ee5;p=freeside.git diff --git a/FS/FS/phone_device.pm b/FS/FS/phone_device.pm index a7097a113..914f735b6 100644 --- a/FS/FS/phone_device.pm +++ b/FS/FS/phone_device.pm @@ -2,7 +2,8 @@ package FS::phone_device; use strict; use base qw( FS::Record ); -use FS::Record qw( qsearchs ); # qsearch ); +use Scalar::Util qw( blessed ); +use FS::Record qw( dbh qsearchs ); # qsearch ); use FS::part_device; use FS::svc_phone; @@ -76,7 +77,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 +110,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 +143,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 +215,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