communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / FS / FS / svc_External_Common.pm
1 package FS::svc_External_Common;
2
3 use strict;
4 use vars qw(@ISA);
5 use FS::svc_Common;
6
7 @ISA = qw( FS::svc_Common );
8
9 =head1 NAME
10
11 FS::svc_external - Object methods for svc_external records
12
13 =head1 SYNOPSIS
14
15   use FS::svc_external;
16
17   $record = new FS::svc_external \%hash;
18   $record = new FS::svc_external { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28   $error = $record->suspend;
29
30   $error = $record->unsuspend;
31
32   $error = $record->cancel;
33
34 =head1 DESCRIPTION
35
36 FS::svc_External_Common is intended as a base class for table-specific classes
37 to inherit from.  FS::svc_External_Common is used for services which connect
38 to externally tracked services via "id" and "table" fields.
39
40 FS::svc_External_Common inherits from FS::svc_Common.
41
42 The following fields are currently supported:
43
44 =over 4
45
46 =item svcnum - primary key
47
48 =item id - unique number of external record
49
50 =item title - for invoice line items
51
52 =back
53
54 =head1 METHODS
55
56 =over 4
57
58 =item search_sql
59
60 Provides a default search_sql method which returns an SQL fragment to search
61 the B<title> field.
62
63 =cut
64
65 sub search_sql {
66   my($class, $string) = @_;
67   $class->search_sql_field('title', $string);
68 }
69
70 =item new HASHREF
71
72 Creates a new external service.  To add the external service to the database,
73 see L<"insert">.  
74
75 Note that this stores the hash reference, not a distinct copy of the hash it
76 points to.  You can ask the object for a copy with the I<hash> method.
77
78 =cut
79
80 =item label
81
82 Returns a string identifying this external service in the form "id:title"
83
84 =cut
85
86 sub label {
87   my $self = shift;
88   $self->id. ':'. $self->title;
89 }
90
91 =item insert [ , OPTION => VALUE ... ]
92
93 Adds this external service to the database.  If there is an error, returns the
94 error, otherwise returns false.
95
96 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be 
97 defined.  An FS::cust_svc record will be created and inserted.
98
99 Currently available options are: I<depend_jobnum>
100
101 If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
102 jobnums), all provisioning jobs will have a dependancy on the supplied
103 jobnum(s) (they will not run until the specific job(s) complete(s)).
104
105 =cut
106
107 #sub insert {
108 #  my $self = shift;
109 #  my $error;
110 #
111 #  $error = $self->SUPER::insert(@_);
112 #  return $error if $error;
113 #
114 #  '';
115 #}
116
117 =item delete
118
119 Delete this record from the database.
120
121 =cut
122
123 #sub delete {
124 #  my $self = shift;
125 #  my $error;
126 #
127 #  $error = $self->SUPER::delete;
128 #  return $error if $error;
129 #
130 #  '';
131 #}
132
133
134 =item replace OLD_RECORD
135
136 Replaces the OLD_RECORD with this one in the database.  If there is an error,
137 returns the error, otherwise returns false.
138
139 =cut
140
141 #sub replace {
142 #  my ( $new, $old ) = ( shift, shift );
143 #  my $error;
144 #
145 #  $error = $new->SUPER::replace($old);
146 #  return $error if $error;
147 #
148 #  '';
149 #}
150
151 =item suspend
152
153 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
154
155 =item unsuspend
156
157 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
158
159 =item cancel
160
161 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
162
163 =item check
164
165 Checks all fields to make sure this is a valid external service.  If there is
166 an error, returns the error, otherwise returns false.  Called by the insert
167 and replace methods.
168
169 =cut
170
171 sub check {
172   my $self = shift;
173
174   my $x = $self->setfixed;
175   return $x unless ref($x);
176   my $part_svc = $x;
177
178   my $error = 
179     $self->ut_numbern('svcnum')
180     || $self->ut_numbern('id')
181     || $self->ut_textn('title')
182   ;
183
184   $self->SUPER::check;
185 }
186
187 =back
188
189 =head1 BUGS
190
191 =head1 SEE ALSO
192
193 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
194 L<FS::cust_pkg>, schema.html from the base documentation.
195
196 =cut
197
198 1;
199