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