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