1 package FS::cust_main_Mixin;
12 FS::cust_main_Mixin - Mixin class for records that contain fields from cust_main
16 package FS::some_table;
18 @ISA = qw( FS::cust_main_Mixin FS::Record );
22 This is a mixin class for records that contain fields from the cust_main table,
23 for example, from a JOINed search. See httemplate/search/ for examples.
31 sub cust_unlinked_msg { '(unlinked)'; }
32 sub cust_linked { $_[0]->custnum; }
36 Given an object that contains fields from cust_main (say, from a JOINed
37 search; see httemplate/search/ for examples), returns the equivalent of the
38 FS::cust_main I<name> method, or "(unlinked)" if this object is not linked to
46 ? FS::cust_main::display_custnum($self)
47 : $self->cust_unlinked_msg;
52 Given an object that contains fields from cust_main (say, from a JOINed
53 search; see httemplate/search/ for examples), returns the equivalent of the
54 FS::cust_main I<name> method, or "(unlinked)" if this object is not linked to
62 ? FS::cust_main::name($self)
63 : $self->cust_unlinked_msg;
68 Given an object that contains fields from cust_main (say, from a JOINed
69 search; see httemplate/search/ for examples), returns the equivalent of the
70 FS::cust_main I<ship_name> method, or "(unlinked)" if this object is not
78 ? FS::cust_main::ship_name($self)
79 : $self->cust_unlinked_msg;
84 Given an object that contains fields from cust_main (say, from a JOINed
85 search; see httemplate/search/ for examples), returns the equivalent of the
86 FS::cust_main I<contact> method, or "(unlinked)" if this object is not linked
94 ? FS::cust_main::contact($self)
95 : $self->cust_unlinked_msg;
100 Given an object that contains fields from cust_main (say, from a JOINed
101 search; see httemplate/search/ for examples), returns the equivalent of the
102 FS::cust_main I<ship_contact> method, or "(unlinked)" if this object is not
103 linked to a customer.
110 ? FS::cust_main::ship_contact($self)
111 : $self->cust_unlinked_msg;
116 Given an object that contains fields from cust_main (say, from a JOINed
117 search; see httemplate/search/ for examples), returns the equivalent of the
118 FS::cust_main I<country_full> method, or "(unlinked)" if this object is not
119 linked to a customer.
126 ? FS::cust_main::country_full($self)
127 : $self->cust_unlinked_msg;
130 =item invoicing_list_emailonly
132 Given an object that contains fields from cust_main (say, from a JOINed
133 search; see httemplate/search/ for examples), returns the equivalent of the
134 FS::cust_main I<invoicing_list_emailonly> method, or "(unlinked)" if this
135 object is not linked to a customer.
139 sub invoicing_list_emailonly {
141 warn "invoicing_list_email only called on $self, ".
142 "custnum ". $self->custnum. "\n"
145 ? FS::cust_main::invoicing_list_emailonly($self)
146 : $self->cust_unlinked_msg;
149 =item invoicing_list_emailonly_scalar
151 Given an object that contains fields from cust_main (say, from a JOINed
152 search; see httemplate/search/ for examples), returns the equivalent of the
153 FS::cust_main I<invoicing_list_emailonly_scalar> method, or "(unlinked)" if
154 this object is not linked to a customer.
158 sub invoicing_list_emailonly_scalar {
160 warn "invoicing_list_emailonly called on $self, ".
161 "custnum ". $self->custnum. "\n"
164 ? FS::cust_main::invoicing_list_emailonly_scalar($self)
165 : $self->cust_unlinked_msg;
170 Given an object that contains fields from cust_main (say, from a JOINed
171 search; see httemplate/search/ for examples), returns the equivalent of the
172 FS::cust_main I<invoicing_list> method, or "(unlinked)" if this object is not
173 linked to a customer.
175 Note: this method is read-only.
183 ? FS::cust_main::invoicing_list($self)
189 Given an object that contains fields from cust_main (say, from a JOINed
190 search; see httemplate/search/ for examples), returns the equivalent of the
191 FS::cust_main I<status> method, or "(unlinked)" if this object is not linked to
198 return $self->cust_unlinked_msg unless $self->cust_linked;
200 #FS::cust_main::status($self)
201 #false laziness w/actual cust_main::status
202 # (make sure FS::cust_main methods are called)
203 for my $status (qw( prospect active inactive suspended cancelled )) {
204 my $method = $status.'_sql';
205 my $sql = FS::cust_main->$method();;
206 my $numnum = ( $sql =~ s/cust_main\.custnum/?/g );
207 my $sth = dbh->prepare("SELECT $sql") or die dbh->errstr;
208 $sth->execute( ($self->custnum) x $numnum )
209 or die "Error executing 'SELECT $sql': ". $sth->errstr;
210 return $status if $sth->fetchrow_arrayref->[0];
214 =item ucfirst_cust_status
216 Given an object that contains fields from cust_main (say, from a JOINed
217 search; see httemplate/search/ for examples), returns the equivalent of the
218 FS::cust_main I<ucfirst_status> method, or "(unlinked)" if this object is not
219 linked to a customer.
223 sub ucfirst_cust_status {
226 ? ucfirst( $self->cust_status(@_) )
227 : $self->cust_unlinked_msg;
230 =item cust_statuscolor
232 Given an object that contains fields from cust_main (say, from a JOINed
233 search; see httemplate/search/ for examples), returns the equivalent of the
234 FS::cust_main I<statuscol> method, or "000000" if this object is not linked to
239 sub cust_statuscolor {
243 ? FS::cust_main::cust_statuscolor($self)
257 Given an object that contains fields from cust_main (say, from a JOINed
258 search; see httemplate/search/ for examples), returns the equivalent of the
259 corresponding FS::cust_main method, or "0" if this object is not linked to
264 foreach my $sub (qw( prospect active inactive suspended cancelled )) {
269 ? FS::cust_main::${sub}_sql(\$self)
282 L<FS::cust_main>, L<FS::Record>