This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / FS / FS / cust_main_Mixin.pm
1 package FS::cust_main_Mixin;
2
3 use strict;
4 use FS::cust_main;
5
6 =head1 NAME
7
8 FS::cust_main_Mixin - Mixin class for records that contain fields from cust_main
9
10 =head1 SYNOPSIS
11
12 package FS::some_table;
13 use vars qw(@ISA);
14 @ISA = qw( FS::cust_main_Mixin FS::Record );
15
16 =head1 DESCRIPTION
17
18 This is a mixin class for records that contain fields from the cust_main table,
19 for example, from a JOINed search.  See httemplate/search/ for examples.
20
21 =head1 METHODS
22
23 =over 4
24
25 =item name
26
27 Given an object that contains fields from cust_main (say, from a JOINed
28 search; see httemplate/search/ for examples), returns the equivalent of the
29 FS::cust_main I<name> method, or "(unlinked)" if this object is not linked to
30 a customer.
31
32 =cut
33
34 sub cust_unlinked_msg { '(unlinked)'; }
35 sub cust_linked { $_[0]->custnum; }
36
37 sub name {
38   my $self = shift;
39   $self->cust_linked
40     ? FS::cust_main::name($self)
41     : $self->cust_unlinked_msg;
42 }
43
44 =item ship_name
45
46 Given an object that contains fields from cust_main (say, from a JOINed
47 search; see httemplate/search/ for examples), returns the equivalent of the
48 FS::cust_main I<ship_name> method, or "(unlinked)" if this object is not
49 linked to a customer.
50
51 =cut
52
53 sub ship_name {
54   my $self = shift;
55   $self->cust_linked
56     ? FS::cust_main::ship_name($self)
57     : $self->cust_unlinked_msg;
58 }
59
60 =item contact
61
62 Given an object that contains fields from cust_main (say, from a JOINed
63 search; see httemplate/search/ for examples), returns the equivalent of the
64 FS::cust_main I<contact> method, or "(unlinked)" if this object is not linked
65 to a customer.
66
67 =cut
68
69 sub contact {
70   my $self = shift;
71   $self->cust_linked
72     ? FS::cust_main::contact($self)
73     : $self->cust_unlinked_msg;
74 }
75
76 =item ship_contact
77
78 Given an object that contains fields from cust_main (say, from a JOINed
79 search; see httemplate/search/ for examples), returns the equivalent of the
80 FS::cust_main I<ship_contact> method, or "(unlinked)" if this object is not
81 linked to a customer.
82
83 =cut
84
85 sub ship_contact {
86   my $self = shift;
87   $self->cust_linked
88     ? FS::cust_main::ship_contact($self)
89     : $self->cust_unlinked_msg;
90 }
91
92 =back
93
94 =head1 BUGS
95
96 =head1 SEE ALSO
97
98 L<FS::cust_main>, L<FS::Record>
99
100 =cut
101
102 1;
103