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';
49 local $SIG{PIPE} = 'IGNORE';
51 $error = $self->check;
52 return $error if $error;
54 my $svcnum = $self->svcnum;
57 $cust_svc = new FS::cust_svc ( {
59 'pkgnum' => $self->pkgnum,
60 'svcpart' => $self->svcpart,
62 $error = $cust_svc->insert;
63 return $error if $error;
64 $svcnum = $self->svcnum($cust_svc->svcnum);
67 $error = $self->SUPER::insert;
69 $cust_svc->delete if $cust_svc;
78 Deletes this account from the database. If there is an error, returns the
79 error, otherwise returns false.
81 The corresponding FS::cust_svc record will be deleted as well.
89 local $SIG{HUP} = 'IGNORE';
90 local $SIG{INT} = 'IGNORE';
91 local $SIG{QUIT} = 'IGNORE';
92 local $SIG{TERM} = 'IGNORE';
93 local $SIG{TSTP} = 'IGNORE';
94 local $SIG{PIPE} = 'IGNORE';
96 my $svcnum = $self->svcnum;
98 $error = $self->SUPER::delete;
99 return $error if $error;
101 my $cust_svc = qsearchs( 'cust_svc' , { 'svcnum' => $svcnum } );
102 $error = $cust_svc->delete;
103 return $error if $error;
110 Sets any fixed fields for this service (see L<FS::part_svc>). If there is an
111 error, returns the error, otherwise returns the FS::part_svc object (use ref()
112 to test the return). Usually called by the check method.
123 Sets all fields to their defaults (see L<FS::part_svc>), overriding their
124 current values. If there is an error, returns the error, otherwise returns
125 the FS::part_svc object (use ref() to test the return).
141 $self->ut_numbern('svcnum')
143 return $error if $error;
147 if ( $self->svcnum ) {
148 my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
149 return "Unknown svcnum" unless $cust_svc;
150 $svcpart = $cust_svc->svcpart;
152 $svcpart = $self->getfield('svcpart');
154 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
155 return "Unkonwn svcpart" unless $part_svc;
157 #set default/fixed/whatever fields from part_svc
158 foreach my $field ( fields('svc_acct') ) {
159 if ( $part_svc->getfield('svc_acct__'. $field. '_flag') eq $x ) {
160 $self->setfield( $field, $part_svc->getfield('svc_acct__'. $field) );
174 Stubs - return false (no error) so derived classes don't need to define these
175 methods. Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
180 sub unsuspend { ''; }
187 $Id: svc_Common.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
191 The setfixed method return value.
193 The new method should set defaults from part_svc (like the check method
198 L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, schema.html
199 from the base documentation.