1 package FS::svc_Common;
5 use FS::Record qw( qsearchs fields );
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';
50 $error = $self->check;
51 return $error if $error;
53 my $svcnum = $self->svcnum;
56 $cust_svc = new FS::cust_svc ( {
58 'pkgnum' => $self->pkgnum,
59 'svcpart' => $self->svcpart,
61 $error = $cust_svc->insert;
62 return $error if $error;
63 $svcnum = $self->svcnum($cust_svc->svcnum);
66 $error = $self->SUPER::insert;
68 $cust_svc->delete if $cust_svc;
77 Deletes this account from the database. If there is an error, returns the
78 error, otherwise returns false.
80 The corresponding FS::cust_svc record will be deleted as well.
88 local $SIG{HUP} = 'IGNORE';
89 local $SIG{INT} = 'IGNORE';
90 local $SIG{QUIT} = 'IGNORE';
91 local $SIG{TERM} = 'IGNORE';
92 local $SIG{TSTP} = 'IGNORE';
94 my $svcnum = $self->svcnum;
96 $error = $self->SUPER::delete;
97 return $error if $error;
99 my $cust_svc = qsearchs( 'cust_svc' , { 'svcnum' => $svcnum } );
100 $error = $cust_svc->delete;
101 return $error if $error;
108 Sets any fixed fields for this service (see L<FS::part_svc>). If there is an
109 error, returns the error, otherwise returns the FS::part_svc object (use ref()
110 to test the return). Usually called by the check method.
120 $self->ut_numbern('svcnum')
122 return $error if $error;
126 if ( $self->svcnum ) {
127 my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
128 return "Unknown svcnum" unless $cust_svc;
129 $svcpart = $cust_svc->svcpart;
131 $svcpart = $self->getfield('svcpart');
133 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
134 return "Unkonwn svcpart" unless $part_svc;
136 #set fixed fields from part_svc
137 foreach my $field ( fields('svc_acct') ) {
138 if ( $part_svc->getfield('svc_acct__'. $field. '_flag') eq 'F' ) {
139 $self->setfield( $field, $part_svc->getfield('svc_acct__'. $field) );
153 Stubs - return false (no error) so derived classes don't need to define these
154 methods. Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
159 sub unsuspend { ''; }
166 $Id: svc_Common.pm,v 1.1 1998-12-30 00:30:45 ivan Exp $
170 The setfixed method return value.
172 The new method should set defaults from part_svc (like the check method
177 L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, schema.html
178 from the base documentation.
182 $Log: svc_Common.pm,v $
183 Revision 1.1 1998-12-30 00:30:45 ivan
184 svc_ stuff is more properly OO - has a common superclass FS::svc_Common