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