save logging information so we have a historical record of exactly when problems...
[freeside.git] / FS / FS / log_context.pm
1 package FS::log_context;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 my @contexts = ( qw(
8   bill_and_collect
9   FS::cust_main::Billing::bill_and_collect
10   FS::cust_main::Billing::bill
11   FS::cust_main::Billing_Realtime::realtime_bop
12   FS::cust_main::Billing_Realtime::realtime_tokenize
13   FS::cust_main::Billing_Realtime::realtime_verify_bop
14   FS::cust_main::Billing_Realtime::token_check
15   FS::pay_batch::import_from_gateway
16   FS::part_pkg
17   FS::Misc::Geo::standardize_uscensus
18   FS::saved_search::send
19   FS::saved_search::render
20   FS::cust_location::process_district_update
21   Cron::bill
22   Cron::backup
23   Cron::upload
24   spool_upload
25   daily
26   queue
27   upgrade
28   upgrade_taxable_billpkgnum
29   freeside-ipifony-download
30   freeside-paymentech-upload
31   freeside-paymentech-download
32   test
33   FS::TaxEngine::billsoft
34 ) );
35
36 =head1 NAME
37
38 FS::log_context - Object methods for log_context records
39
40 =head1 SYNOPSIS
41
42   use FS::log_context;
43
44   $record = new FS::log_context \%hash;
45   $record = new FS::log_context { 'column' => 'value' };
46
47   $error = $record->insert;
48
49   $error = $new_record->replace($old_record);
50
51   $error = $record->delete;
52
53   $error = $record->check;
54
55 =head1 DESCRIPTION
56
57 An FS::log_context object represents a context tag attached to a log entry
58 (L<FS::log>).  FS::log_context inherits from FS::Record.  The following 
59 fields are currently supported:
60
61 =over 4
62
63 =item logcontextnum - primary key
64
65 =item lognum - lognum (L<FS::log> foreign key)
66
67 =item context - context
68
69 =back
70
71 =head1 METHODS
72
73 =over 4
74
75 =item new HASHREF
76
77 Creates a new context tag.  To add the example to the database, see 
78 L<"insert">.
79
80 Note that this stores the hash reference, not a distinct copy of the hash it
81 points to.  You can ask the object for a copy with the I<hash> method.
82
83 =cut
84
85 sub table { 'log_context'; }
86
87 =item insert
88
89 Adds this record to the database.  If there is an error, returns the error,
90 otherwise returns false.
91
92 =item delete
93
94 Delete this record from the database.
95
96 =item replace OLD_RECORD
97
98 Replaces the OLD_RECORD with this one in the database.  If there is an error,
99 returns the error, otherwise returns false.
100
101 =item check
102
103 Checks all fields to make sure this is a valid example.  If there is
104 an error, returns the error, otherwise returns false.  Called by the insert
105 and replace methods.
106
107 =cut
108
109 sub check {
110   my $self = shift;
111
112   my $error = 
113     $self->ut_numbern('logcontextnum')
114     || $self->ut_number('lognum')
115     || $self->ut_text('context') #|| $self->ut_enum('context', \@contexts)
116   ;
117   return $error if $error;
118
119   $self->SUPER::check;
120 }
121
122 =back
123
124 =head1 CLASS METHODS
125
126 =over 4
127
128 =item contexts
129
130 Returns a list of all valid contexts.
131
132 =cut
133
134 sub contexts { @contexts }
135
136 =back
137
138 =head1 BUGS
139
140 =head1 SEE ALSO
141
142 L<FS::Log>, L<FS::Record>, schema.html from the base documentation.
143
144 =cut
145
146 1;
147