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