add ability to select specific package defs. and package status to package report...
[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 =item country_full
93
94 Given an object that contains fields from cust_main (say, from a JOINed
95 search; see httemplate/search/ for examples), returns the equivalent of the
96 FS::cust_main I<country_full> method, or "(unlinked)" if this object is not
97 linked to a customer.
98
99 =cut
100
101 sub country_full {
102   my $self = shift;
103   $self->cust_linked
104     ? FS::cust_main::country_full($self)
105     : $self->cust_unlinked_msg;
106 }
107
108 =item invoicing_list_emailonly
109
110 Given an object that contains fields from cust_main (say, from a JOINed
111 search; see httemplate/search/ for examples), returns the equivalent of the
112 FS::cust_main I<country_full> method, or "(unlinked)" if this object is not
113 linked to a customer.
114
115 =cut
116
117 sub invoicing_list_emailonly {
118   my $self = shift;
119   warn "invoicing_list_email only called on $self, ".
120        "custnum ". $self->custnum. "\n";
121   $self->cust_linked
122     ? FS::cust_main::invoicing_list_emailonly($self)
123     : $self->cust_unlinked_msg;
124 }
125
126 #read-only
127 sub invoicing_list {
128   my $self = shift;
129   $self->cust_linked
130     ? FS::cust_main::invoicing_list($self)
131     : ();
132 }
133
134 =cut
135
136 =back
137
138 =head1 BUGS
139
140 =head1 SEE ALSO
141
142 L<FS::cust_main>, L<FS::Record>
143
144 =cut
145
146 1;
147