don't generate invoices for COMP customers
[freeside.git] / FS / FS / part_referral.pm
1 package FS::part_referral;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record;
6
7 @ISA = qw( FS::Record );
8
9 =head1 NAME
10
11 FS::part_referral - Object methods for part_referral objects
12
13 =head1 SYNOPSIS
14
15   use FS::part_referral;
16
17   $record = new FS::part_referral \%hash
18   $record = new FS::part_referral { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::part_referral represents a advertising source - where a customer heard
31 of your services.  This can be used to track the effectiveness of a particular
32 piece of advertising, for example.  FS::part_referral inherits from FS::Record.
33 The following fields are currently supported:
34
35 =over 4
36
37 =item refnum - primary key (assigned automatically for new referrals)
38
39 =item referral - Text name of this advertising source
40
41 =item disabled - Disabled flag, empty or 'Y'
42
43 =back
44
45 =head1 NOTE
46
47 These were called B<referrals> before version 1.4.0 - the name was changed
48 so as not to be confused with the new customer-to-customer referrals.
49
50 =head1 METHODS
51
52 =over 4
53
54 =item new HASHREF
55
56 Creates a new advertising source.  To add the referral to the database, see
57 L<"insert">.
58
59 =cut
60
61 sub table { 'part_referral'; }
62
63 =item insert
64
65 Adds this advertising source to the database.  If there is an error, returns
66 the error, otherwise returns false.
67
68 =item delete
69
70 Currently unimplemented.
71
72 =cut
73
74 sub delete {
75   my $self = shift;
76   return "Can't (yet?) delete part_referral records";
77   #need to make sure no customers have this referral!
78 }
79
80 =item replace OLD_RECORD
81
82 Replaces OLD_RECORD with this one in the database.  If there is an error,
83 returns the error, otherwise returns false.
84
85 =item check
86
87 Checks all fields to make sure this is a valid advertising source.  If there is
88 an error, returns the error, otherwise returns false.  Called by the insert and
89 replace methods.
90
91 =cut
92
93 sub check {
94   my $self = shift;
95
96   my $error = $self->ut_numbern('refnum')
97     || $self->ut_text('referral')
98   ;
99   return $error if $error;
100
101   if ( $self->dbdef_table->column('disabled') ) {
102     $error = $self->ut_enum('disabled', [ '', 'Y' ] );
103     return $error if $error;
104   }
105
106   $self->SUPER::check;
107 }
108
109 =back
110
111 =head1 BUGS
112
113 The delete method is unimplemented.
114
115 `Advertising source'.  Yes, it's a sucky name.  The only other ones I could
116 come up with were "Marketing channel" and "Heard Abouts" and those are
117 definately both worse.
118
119 =head1 SEE ALSO
120
121 L<FS::Record>, L<FS::cust_main>, schema.html from the base documentation.
122
123 =cut
124
125 1;
126