5 use FS::Record qw(fields qsearch qsearchs);
12 FS::table_name - Object methods for table_name records
18 $record = new FS::table_name \%hash;
19 $record = new FS::table_name { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
29 $error = $record->suspend;
31 $error = $record->unsuspend;
33 $error = $record->cancel;
37 An FS::table_name object represents an example. FS::table_name inherits from
38 FS::Record. The following fields are currently supported:
42 =item field - description
52 Creates a new example. To add the example to the database, see L<"insert">.
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to. You can ask the object for a copy with the I<hash> method.
59 sub table { 'table_name'; }
63 Adds this record to the database. If there is an error, returns the error,
64 otherwise returns false.
66 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
67 defined. An FS::cust_svc record will be created and inserted.
75 local $SIG{HUP} = 'IGNORE';
76 local $SIG{INT} = 'IGNORE';
77 local $SIG{QUIT} = 'IGNORE';
78 local $SIG{TERM} = 'IGNORE';
79 local $SIG{TSTP} = 'IGNORE';
82 return $error if $error;
84 my($svcnum)=$self->svcnum;
87 $cust_svc=create FS::cust_svc ( {
89 'pkgnum' => $self->pkgnum,
90 'svcpart' => $self->svcpart,
92 my($error) = $cust_svc->insert;
93 return $error if $error;
94 $svcnum = $self->svcnum($cust_svc->svcnum);
99 #$cust_svc->del if $cust_svc;
100 $cust_svc->delete if $cust_svc;
108 Delete this record from the database.
117 return $error if $error;
122 =item replace OLD_RECORD
124 Replaces the OLD_RECORD with this one in the database. If there is an error,
125 returns the error, otherwise returns false.
133 return "(Old) Not a svc_table record!" unless $old->table eq "svc_table";
134 return "Can't change svcnum!"
135 unless $old->getfield('svcnum') eq $new->getfield('svcnum');
138 return $error if $error;
140 $error = $new->rep($old);
141 return $error if $error;
148 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
158 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
169 Just returns false (no error) for now.
171 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
181 Checks all fields to make sure this is a valid example. If there is
182 an error, returns the error, otherwise returns false. Called by the insert
189 return "Not a svc_table record!" unless $self->table eq "svc_table";
190 my($recref) = $self->hashref;
192 $recref->{svcnum} =~ /^(\d+)$/ or return "Illegal svcnum";
193 $recref->{svcnum} = $1;
197 my($svcnum)=$self->getfield('svcnum');
199 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum});
200 return "Unknown svcnum" unless $cust_svc;
201 $svcpart=$cust_svc->svcpart;
203 $svcpart=$self->getfield('svcpart');
205 my($part_svc)=qsearchs('part_svc',{'svcpart'=>$svcpart});
206 return "Unkonwn svcpart" unless $part_svc;
208 #set fixed fields from part_svc
210 foreach $field ( fields('svc_acct') ) {
211 if ( $part_svc->getfield('svc_acct__'. $field. '_flag') eq 'F' ) {
212 $self->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
223 $Id: table_template-svc.pm,v 1.3 1998-12-29 11:59:56 ivan Exp $
227 The author forgot to customize this manpage.
231 L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, schema.html
232 froom the base documentation.
236 ivan@voicenet.com 97-jul-21
238 $Log: table_template-svc.pm,v $
239 Revision 1.3 1998-12-29 11:59:56 ivan
240 mostly properly OO, some work still to be done with svc_ stuff
242 Revision 1.2 1998/11/15 04:33:01 ivan
243 updates for newest versoin