return svc_external id and title as label instead of svcnum
[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     },
73   };
74 }
75
76 sub table { 'svc_external'; }
77
78 # oh!  this should be moved to svc_artera_turbo or something now
79 sub label {
80   my $self = shift;
81   my $conf = new FS::Conf;
82   if (    $conf->exists('svc_external-display_type')
83        && $conf->config('svc_external-display_type') eq 'artera_turbo' )
84   {
85     sprintf('%010d', $self->id). '-'.
86       substr('0000000000'.uc($self->title), -10);
87   } else {
88     #$self->SUPER::label;
89     $self->id. ' - '. $self->title;
90   }
91 }
92
93 =item insert [ , OPTION => VALUE ... ]
94
95 Adds this external service to the database.  If there is an error, returns the
96 error, otherwise returns false.
97
98 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be 
99 defined.  An FS::cust_svc record will be created and inserted.
100
101 Currently available options are: I<depend_jobnum>
102
103 If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
104 jobnums), all provisioning jobs will have a dependancy on the supplied
105 jobnum(s) (they will not run until the specific job(s) complete(s)).
106
107 =cut
108
109 #sub insert {
110 #  my $self = shift;
111 #  my $error;
112 #
113 #  $error = $self->SUPER::insert(@_);
114 #  return $error if $error;
115 #
116 #  '';
117 #}
118
119 =item delete
120
121 Delete this record from the database.
122
123 =cut
124
125 #sub delete {
126 #  my $self = shift;
127 #  my $error;
128 #
129 #  $error = $self->SUPER::delete;
130 #  return $error if $error;
131 #
132 #  '';
133 #}
134
135
136 =item replace OLD_RECORD
137
138 Replaces the OLD_RECORD with this one in the database.  If there is an error,
139 returns the error, otherwise returns false.
140
141 =cut
142
143 #sub replace {
144 #  my ( $new, $old ) = ( shift, shift );
145 #  my $error;
146 #
147 #  $error = $new->SUPER::replace($old);
148 #  return $error if $error;
149 #
150 #  '';
151 #}
152
153 =item suspend
154
155 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
156
157 =item unsuspend
158
159 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
160
161 =item cancel
162
163 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
164
165 =item check
166
167 Checks all fields to make sure this is a valid external service.  If there is
168 an error, returns the error, otherwise returns false.  Called by the insert
169 and replace methods.
170
171 =cut
172
173 #sub check {
174 #  my $self = shift;
175 #  my $error;
176 #
177 #  $error = $self->SUPER::delete;
178 #  return $error if $error;
179 #
180 #  '';
181 #}
182
183 =back
184
185 =head1 BUGS
186
187 =head1 SEE ALSO
188
189 L<FS::svc_External_Common>, L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>,
190 L<FS::part_svc>, L<FS::cust_pkg>, schema.html from the base documentation.
191
192 =cut
193
194 1;
195