eliminate some false laziness in FS::Misc::send_email vs. msg_template/email.pm send_...
[freeside.git] / FS / FS / legacy_cust_history.pm
1 package FS::legacy_cust_history;
2 use base qw( FS::Record );
3
4 use strict;
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::legacy_cust_history - Object methods for legacy_cust_history records
10
11 =head1 SYNOPSIS
12
13   use FS::legacy_cust_history;
14
15   $record = new FS::legacy_cust_history \%hash;
16   $record = new FS::legacy_cust_history { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::legacy_cust_history object represents an item of customer change history
29 from a previous billing system.  FS::legacy_cust_history inherits from
30 FS::Record.  The following fields are currently supported:
31
32 =over 4
33
34 =item legacyhistorynum
35
36 primary key
37
38 =item custnum
39
40 Customer (see L<FS::cust_main>)
41
42 =item history_action
43
44 Action, such as add, edit, delete, etc.
45
46 =item history_date
47
48 Date, as a UNIX timestamp
49
50 =item history_usernum
51
52 Employee (see L<FS::access_user>)
53
54 =item item
55
56 The item (i.e. table) which was changed.
57
58 =item description
59
60 A text description of the change
61
62 =item change_data
63
64 A text data structure representing the change
65
66 =back
67
68 =head1 METHODS
69
70 =over 4
71
72 =item new HASHREF
73
74 Creates a new record.  To add the record to the database, see L<"insert">.
75
76 Note that this stores the hash reference, not a distinct copy of the hash it
77 points to.  You can ask the object for a copy with the I<hash> method.
78
79 =cut
80
81 sub table { 'legacy_cust_history'; }
82
83 =item insert
84
85 Adds this record to the database.  If there is an error, returns the error,
86 otherwise returns false.
87
88 =item delete
89
90 Delete this record from the database.
91
92 =item replace OLD_RECORD
93
94 Replaces the OLD_RECORD with this one in the database.  If there is an error,
95 returns the error, otherwise returns false.
96
97 =item check
98
99 Checks all fields to make sure this is a valid record.  If there is
100 an error, returns the error, otherwise returns false.  Called by the insert
101 and replace methods.
102
103 =cut
104
105 sub check {
106   my $self = shift;
107
108   my $error = 
109     $self->ut_numbern('legacyhistorynum')
110     || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
111     || $self->ut_text('history_action')
112     || $self->ut_numbern('history_date')
113     || $self->ut_foreign_keyn('history_usernum', 'access_user', 'usernum')
114     || $self->ut_textn('item')
115     || $self->ut_textn('description')
116     || $self->ut_anything('change_data')
117   ;
118   return $error if $error;
119
120   $self->SUPER::check;
121 }
122
123 =back
124
125 =head1 BUGS
126
127 =head1 SEE ALSO
128
129 L<FS::Record>
130
131 =cut
132
133 1;
134