backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / log_context.pm
index 372bdaa..6b69a80 100644 (file)
@@ -4,14 +4,38 @@ use strict;
 use base qw( FS::Record );
 use FS::Record qw( qsearch qsearchs );
 
 use base qw( FS::Record );
 use FS::Record qw( qsearch qsearchs );
 
-my @contexts = ( qw(
-  test
+# Items in @default_contexts will always be included in the
+# output of contexts() method
+my @default_contexts = ( qw(
   bill_and_collect
   bill_and_collect
+  FS::cust_main::Billing::bill_and_collect
+  FS::cust_main::Billing::bill
+  FS::cust_main::Billing_Realtime::realtime_bop
+  FS::cust_main::Billing_Realtime::realtime_tokenize
+  FS::cust_main::Billing_Realtime::realtime_verify_bop
+  FS::cust_main::Billing_Realtime::token_check
+  FS::pay_batch::import_from_gateway
+  FS::part_pkg
+  FS::Misc::Geo::standardize_uscensus
+  FS::saved_search::send
+  FS::saved_search::render
+  FS::cust_location::process_district_update
   Cron::bill
   Cron::bill
+  Cron::backup
   Cron::upload
   spool_upload
   daily
   queue
   Cron::upload
   spool_upload
   daily
   queue
+  upgrade
+  upgrade_taxable_billpkgnum
+  freeside-ipifony-download
+  freeside-paymentech-upload
+  freeside-paymentech-download
+  test
+  FS::TaxEngine::billsoft
+  wa_sales
+  wa_tax_rate_update
+  tax_rate_update
 ) );
 
 =head1 NAME
 ) );
 
 =head1 NAME
@@ -63,8 +87,6 @@ points to.  You can ask the object for a copy with the I<hash> method.
 
 =cut
 
 
 =cut
 
-# the new method can be inherited from FS::Record, if a table method is defined
-
 sub table { 'log_context'; }
 
 =item insert
 sub table { 'log_context'; }
 
 =item insert
@@ -72,27 +94,15 @@ sub table { 'log_context'; }
 Adds this record to the database.  If there is an error, returns the error,
 otherwise returns false.
 
 Adds this record to the database.  If there is an error, returns the error,
 otherwise returns false.
 
-=cut
-
-# the insert method can be inherited from FS::Record
-
 =item delete
 
 Delete this record from the database.
 
 =item delete
 
 Delete this record from the database.
 
-=cut
-
-# the delete method can be inherited from FS::Record
-
 =item replace OLD_RECORD
 
 Replaces the OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
 =item replace OLD_RECORD
 
 Replaces the OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
-=cut
-
-# the replace method can be inherited from FS::Record
-
 =item check
 
 Checks all fields to make sure this is a valid example.  If there is
 =item check
 
 Checks all fields to make sure this is a valid example.  If there is
@@ -101,16 +111,13 @@ and replace methods.
 
 =cut
 
 
 =cut
 
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
 sub check {
   my $self = shift;
 
   my $error = 
     $self->ut_numbern('logcontextnum')
     || $self->ut_number('lognum')
 sub check {
   my $self = shift;
 
   my $error = 
     $self->ut_numbern('logcontextnum')
     || $self->ut_number('lognum')
-    || $self->ut_enum('context', \@contexts)
+    || $self->ut_text('context') #|| $self->ut_enum('context', \@contexts)
   ;
   return $error if $error;
 
   ;
   return $error if $error;
 
@@ -125,11 +132,25 @@ sub check {
 
 =item contexts
 
 
 =item contexts
 
-Returns a list of all valid contexts.
+Returns a list of all log contexts, by combining @default_contexts
+with all context values seen in the log_context table
 
 =cut
 
 
 =cut
 
-sub contexts { @contexts }
+sub contexts {
+  my $self = shift;
+
+  my %contexts = map { $_ => 1 } @default_contexts;
+
+  $contexts{ $_->context } = 1
+    for qsearch({
+      select  => 'DISTINCT context AS context',
+      table   => 'log_context',
+      hashref => {},
+    });
+
+  sort { lc $a cmp lc $b } keys %contexts;
+}
 
 =back
 
 
 =back