6 use FS::Record qw(fields qsearch qsearchs);
13 FS::table_name - Object methods for table_name records
19 $record = create FS::table_name \%hash;
20 $record = create FS::table_name { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
30 $error = $record->suspend;
32 $error = $record->unsuspend;
34 $error = $record->cancel;
38 An FS::table_name object represents an example. FS::table_name inherits from
39 FS::Record. The following fields are currently supported:
43 =item field - description
53 Creates a new example. To add the example to the database, see L<"insert">.
55 Note that this stores the hash reference, not a distinct copy of the hash it
56 points to. You can ask the object for a copy with the I<hash> method.
61 my($proto,$hashref)=@_;
63 $proto->new('svc_table',$hashref);
69 Adds this record to the database. If there is an error, returns the error,
70 otherwise returns false.
72 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
73 defined. An FS::cust_svc record will be created and inserted.
81 local $SIG{HUP} = 'IGNORE';
82 local $SIG{INT} = 'IGNORE';
83 local $SIG{QUIT} = 'IGNORE';
84 local $SIG{TERM} = 'IGNORE';
85 local $SIG{TSTP} = 'IGNORE';
88 return $error if $error;
90 my($svcnum)=$self->svcnum;
93 $cust_svc=create FS::cust_svc ( {
95 'pkgnum' => $self->pkgnum,
96 'svcpart' => $self->svcpart,
98 my($error) = $cust_svc->insert;
99 return $error if $error;
100 $svcnum = $self->svcnum($cust_svc->svcnum);
105 #$cust_svc->del if $cust_svc;
106 $cust_svc->delete if $cust_svc;
114 Delete this record from the database.
123 return $error if $error;
128 =item replace OLD_RECORD
130 Replaces the OLD_RECORD with this one in the database. If there is an error,
131 returns the error, otherwise returns false.
139 return "(Old) Not a svc_table record!" unless $old->table eq "svc_table";
140 return "Can't change svcnum!"
141 unless $old->getfield('svcnum') eq $new->getfield('svcnum');
144 return $error if $error;
146 $error = $new->rep($old);
147 return $error if $error;
154 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
164 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
175 Just returns false (no error) for now.
177 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
187 Checks all fields to make sure this is a valid example. If there is
188 an error, returns the error, otherwise returns false. Called by the insert
195 return "Not a svc_table record!" unless $self->table eq "svc_table";
196 my($recref) = $self->hashref;
198 $recref->{svcnum} =~ /^(\d+)$/ or return "Illegal svcnum";
199 $recref->{svcnum} = $1;
203 my($svcnum)=$self->getfield('svcnum');
205 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum});
206 return "Unknown svcnum" unless $cust_svc;
207 $svcpart=$cust_svc->svcpart;
209 $svcpart=$self->getfield('svcpart');
211 my($part_svc)=qsearchs('part_svc',{'svcpart'=>$svcpart});
212 return "Unkonwn svcpart" unless $part_svc;
214 #set fixed fields from part_svc
216 foreach $field ( fields('svc_acct') ) {
217 if ( $part_svc->getfield('svc_acct__'. $field. '_flag') eq 'F' ) {
218 $self->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
229 $Id: table_template-svc.pm,v 1.2 1998-11-15 04:33:01 ivan Exp $
233 The author forgot to customize this manpage.
237 L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, schema.html
238 froom the base documentation.
242 ivan@voicenet.com 97-jul-21
244 $Log: table_template-svc.pm,v $
245 Revision 1.2 1998-11-15 04:33:01 ivan
246 updates for newest versoin