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 Given an object that contains fields from cust_main (say, from a JOINed
32 search; see httemplate/search/ for examples), returns the equivalent of the
33 FS::cust_main I<name> method, or "(unlinked)" if this object is not linked to
38 sub cust_unlinked_msg { '(unlinked)'; }
39 sub cust_linked { $_[0]->custnum; }
44 ? FS::cust_main::name($self)
45 : $self->cust_unlinked_msg;
50 Given an object that contains fields from cust_main (say, from a JOINed
51 search; see httemplate/search/ for examples), returns the equivalent of the
52 FS::cust_main I<ship_name> method, or "(unlinked)" if this object is not
60 ? FS::cust_main::ship_name($self)
61 : $self->cust_unlinked_msg;
66 Given an object that contains fields from cust_main (say, from a JOINed
67 search; see httemplate/search/ for examples), returns the equivalent of the
68 FS::cust_main I<contact> method, or "(unlinked)" if this object is not linked
76 ? FS::cust_main::contact($self)
77 : $self->cust_unlinked_msg;
82 Given an object that contains fields from cust_main (say, from a JOINed
83 search; see httemplate/search/ for examples), returns the equivalent of the
84 FS::cust_main I<ship_contact> method, or "(unlinked)" if this object is not
92 ? FS::cust_main::ship_contact($self)
93 : $self->cust_unlinked_msg;
98 Given an object that contains fields from cust_main (say, from a JOINed
99 search; see httemplate/search/ for examples), returns the equivalent of the
100 FS::cust_main I<country_full> method, or "(unlinked)" if this object is not
101 linked to a customer.
108 ? FS::cust_main::country_full($self)
109 : $self->cust_unlinked_msg;
112 =item invoicing_list_emailonly
114 Given an object that contains fields from cust_main (say, from a JOINed
115 search; see httemplate/search/ for examples), returns the equivalent of the
116 FS::cust_main I<invoicing_list_emailonly> method, or "(unlinked)" if this
117 object is not linked to a customer.
121 sub invoicing_list_emailonly {
123 warn "invoicing_list_email only called on $self, ".
124 "custnum ". $self->custnum. "\n"
127 ? FS::cust_main::invoicing_list_emailonly($self)
128 : $self->cust_unlinked_msg;
131 =item invoicing_list_emailonly_scalar
133 Given an object that contains fields from cust_main (say, from a JOINed
134 search; see httemplate/search/ for examples), returns the equivalent of the
135 FS::cust_main I<invoicing_list_emailonly_scalar> method, or "(unlinked)" if
136 this object is not linked to a customer.
140 sub invoicing_list_emailonly_scalar {
142 warn "invoicing_list_emailonly called on $self, ".
143 "custnum ". $self->custnum. "\n"
146 ? FS::cust_main::invoicing_list_emailonly_scalar($self)
147 : $self->cust_unlinked_msg;
152 Given an object that contains fields from cust_main (say, from a JOINed
153 search; see httemplate/search/ for examples), returns the equivalent of the
154 FS::cust_main I<invoicing_list> method, or "(unlinked)" if this object is not
155 linked to a customer.
157 Note: this method is read-only.
165 ? FS::cust_main::invoicing_list($self)
171 Given an object that contains fields from cust_main (say, from a JOINed
172 search; see httemplate/search/ for examples), returns the equivalent of the
173 FS::cust_main I<status> method, or "(unlinked)" if this object is not linked to
180 return $self->cust_unlinked_msg unless $self->cust_linked;
182 #FS::cust_main::status($self)
183 #false laziness w/actual cust_main::status
184 # (make sure FS::cust_main methods are called)
185 for my $status (qw( prospect active inactive suspended cancelled )) {
186 my $method = $status.'_sql';
187 my $sql = FS::cust_main->$method();;
188 my $numnum = ( $sql =~ s/cust_main\.custnum/?/g );
189 my $sth = dbh->prepare("SELECT $sql") or die dbh->errstr;
190 $sth->execute( ($self->custnum) x $numnum )
191 or die "Error executing 'SELECT $sql': ". $sth->errstr;
192 return $status if $sth->fetchrow_arrayref->[0];
196 =item ucfirst_cust_status
198 Given an object that contains fields from cust_main (say, from a JOINed
199 search; see httemplate/search/ for examples), returns the equivalent of the
200 FS::cust_main I<ucfirst_status> method, or "(unlinked)" if this object is not
201 linked to a customer.
205 sub ucfirst_cust_status {
208 ? ucfirst( $self->cust_status(@_) )
209 : $self->cust_unlinked_msg;
212 =item cust_statuscolor
214 Given an object that contains fields from cust_main (say, from a JOINed
215 search; see httemplate/search/ for examples), returns the equivalent of the
216 FS::cust_main I<statuscol> method, or "000000" if this object is not linked to
221 sub cust_statuscolor {
225 ? FS::cust_main::cust_statuscolor($self)
239 Given an object that contains fields from cust_main (say, from a JOINed
240 search; see httemplate/search/ for examples), returns the equivalent of the
241 corresponding FS::cust_main method, or "0" if this object is not linked to
246 foreach my $sub (qw( prospect active inactive suspended cancelled )) {
251 ? FS::cust_main::${sub}_sql(\$self)
264 L<FS::cust_main>, L<FS::Record>