[freeside-commits] freeside/FS/FS phone_device.pm,1.1,1.2
Ivan,,,
ivan at wavetail.420.am
Tue Jun 30 02:38:43 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv22797
Modified Files:
phone_device.pm
Log Message:
more steps to netsapiens export, RT#5226
Index: phone_device.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/phone_device.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- phone_device.pm 30 Jun 2009 01:42:55 -0000 1.1
+++ phone_device.pm 30 Jun 2009 09:38:41 -0000 1.2
@@ -2,7 +2,7 @@
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 @@
=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 @@
=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 @@
=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 @@
qsearchs( 'part_device', { 'devicepart' => $self->devicepart } );
}
+=item svc_phone
+
+Returns the phone number (see L<FS::svc_phone>) associated with this customer
+device.
+
+=cut
+
+sub svc_phone {
+ my $self = shift;
+ qsearchs( 'svc_phone', { 'svcnum' => $self->svcnum } );
+}
+
=back
=head1 BUGS
More information about the freeside-commits
mailing list