=over 4
-=item insert [ JOBNUM_ARRAYREF ]
+=item insert [ JOBNUM_ARRAYREF [ OBJECTS_ARRAYREF ] ]
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
If an arrayref is passed as parameter, the B<jobnum>s of any export jobs will
be added to the array.
+If an arrayref of FS::tablename objects (for example, FS::acct_snarf objects)
+is passed as the optional second parameter, they will have their svcnum fields
+set and will be inserted after this record, but before any exports are run.
+
=cut
sub insert {
my $self = shift;
local $FS::queue::jobnums = shift if @_;
+ my $objects = scalar(@_) ? shift : [];
my $error;
local $SIG{HUP} = 'IGNORE';
return $error if $error;
my $svcnum = $self->svcnum;
- my $cust_svc;
- unless ( $svcnum ) {
+ my $cust_svc = $svcnum ? qsearchs('cust_svc',{'svcnum'=>$self->svcnum}) : '';
+ #unless ( $svcnum ) {
+ if ( !$svcnum or !$cust_svc ) {
$cust_svc = new FS::cust_svc ( {
#hua?# 'svcnum' => $svcnum,
+ 'svcnum' => $self->svcnum,
'pkgnum' => $self->pkgnum,
'svcpart' => $self->svcpart,
} );
}
$svcnum = $self->svcnum($cust_svc->svcnum);
} else {
- $cust_svc = qsearchs('cust_svc',{'svcnum'=>$self->svcnum});
+ #$cust_svc = qsearchs('cust_svc',{'svcnum'=>$self->svcnum});
unless ( $cust_svc ) {
$dbh->rollback if $oldAutoCommit;
return "no cust_svc record found for svcnum ". $self->svcnum;
return $error;
}
+ foreach my $object ( @$objects ) {
+ $object->svcnum($self->svcnum);
+ $error = $object->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
#new-style exports!
unless ( $noexport_hack ) {
foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
#get part_svc
my $svcpart;
- if ( $self->svcnum ) {
+ if ( $self->svcnum && qsearchs('cust_svc', {'svcnum'=>$self->svcnum}) ) {
my $cust_svc = $self->cust_svc;
return "Unknown svcnum" unless $cust_svc;
$svcpart = $cust_svc->svcpart;
sub cancel { ''; }
+=item clone_suspended
+
+Constructor used by FS::part_export::_export_suspend fallback. Stub returning
+same object for svc_ classes which don't implement a suspension fallback
+(everything except svc_acct at the moment). Document better.
+
+=cut
+
+sub clone_suspended {
+ shift;
+}
+
+=item clone_kludge_unsuspend
+
+Constructor used by FS::part_export::_export_unsuspend fallback. Stub returning
+same object for svc_ classes which don't implement a suspension fallback
+(everything except svc_acct at the moment). Document better.
+
+=cut
+
+sub clone_kludge_unsuspend {
+ shift;
+}
+
=back
=head1 VERSION
-$Id: svc_Common.pm,v 1.12 2002-06-14 11:22:53 ivan Exp $
+$Id: svc_Common.pm,v 1.12.4.5 2004-02-23 08:12:54 ivan Exp $
=head1 BUGS