1 package FS::svc_Common;
5 use FS::Record qw( qsearchs fields dbh );
9 @ISA = qw( FS::Record );
13 FS::svc_Common - Object method for all svc_ records
19 @ISA = qw( FS::svc_Common );
23 FS::svc_Common is intended as a base class for table-specific classes to
24 inherit from, i.e. FS::svc_acct. FS::svc_Common inherits from FS::Record.
32 Adds this record to the database. If there is an error, returns the error,
33 otherwise returns false.
35 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
36 defined. An FS::cust_svc record will be created and inserted.
44 local $SIG{HUP} = 'IGNORE';
45 local $SIG{INT} = 'IGNORE';
46 local $SIG{QUIT} = 'IGNORE';
47 local $SIG{TERM} = 'IGNORE';
48 local $SIG{TSTP} = 'IGNORE';
49 local $SIG{PIPE} = 'IGNORE';
51 my $oldAutoCommit = $FS::UID::AutoCommit;
52 local $FS::UID::AutoCommit = 0;
55 $error = $self->check;
56 return $error if $error;
58 my $svcnum = $self->svcnum;
61 $cust_svc = new FS::cust_svc ( {
62 #hua?# 'svcnum' => $svcnum,
63 'pkgnum' => $self->pkgnum,
64 'svcpart' => $self->svcpart,
66 $error = $cust_svc->insert;
68 $dbh->rollback if $oldAutoCommit;
71 $svcnum = $self->svcnum($cust_svc->svcnum);
74 $error = $self->SUPER::insert;
76 $dbh->rollback if $oldAutoCommit;
80 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
87 Deletes this account from the database. If there is an error, returns the
88 error, otherwise returns false.
90 The corresponding FS::cust_svc record will be deleted as well.
98 local $SIG{HUP} = 'IGNORE';
99 local $SIG{INT} = 'IGNORE';
100 local $SIG{QUIT} = 'IGNORE';
101 local $SIG{TERM} = 'IGNORE';
102 local $SIG{TSTP} = 'IGNORE';
103 local $SIG{PIPE} = 'IGNORE';
105 my $svcnum = $self->svcnum;
107 $error = $self->SUPER::delete;
108 return $error if $error;
110 my $cust_svc = $self->cust_svc;
111 $error = $cust_svc->delete;
112 return $error if $error;
119 Sets any fixed fields for this service (see L<FS::part_svc>). If there is an
120 error, returns the error, otherwise returns the FS::part_svc object (use ref()
121 to test the return). Usually called by the check method.
132 Sets all fields to their defaults (see L<FS::part_svc>), overriding their
133 current values. If there is an error, returns the error, otherwise returns
134 the FS::part_svc object (use ref() to test the return).
150 $self->ut_numbern('svcnum')
152 return $error if $error;
156 if ( $self->svcnum ) {
157 my $cust_svc = $self->cust_svc;
158 return "Unknown svcnum" unless $cust_svc;
159 $svcpart = $cust_svc->svcpart;
161 $svcpart = $self->getfield('svcpart');
163 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
164 return "Unkonwn svcpart" unless $part_svc;
166 #set default/fixed/whatever fields from part_svc
167 my $table = $self->table;
168 foreach my $field ( grep { $_ ne 'svcnum' } fields($table) ) {
169 my $part_svc_column = $part_svc->part_svc_column($field);
170 if ( $part_svc_column->columnflag eq $x ) {
171 $self->setfield( $field, $part_svc_column->columnvalue );
181 Returns the cust_svc record associated with this svc_ record, as a FS::cust_svc
182 object (see L<FS::cust_svc>).
188 qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
197 Stubs - return false (no error) so derived classes don't need to define these
198 methods. Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
203 sub unsuspend { ''; }
210 $Id: svc_Common.pm,v 1.7 2001-11-30 00:04:38 ivan Exp $
214 The setfixed method return value.
218 L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, schema.html
219 from the base documentation.