more accurate calculation of package start delays, #20686
[freeside.git] / FS / FS / part_event_condition.pm
index d13e849..78aa3b1 100644 (file)
@@ -2,7 +2,7 @@ package FS::part_event_condition;
 
 use strict;
 use vars qw( @ISA $DEBUG @SKIP_CONDITION_SQL );
-use FS::UID qw(dbh);
+use FS::UID qw( dbh driver_name );
 use FS::Record qw( qsearch qsearchs );
 use FS::option_Common;
 use FS::part_event; #for order_conditions_sql...
@@ -185,6 +185,10 @@ foreach my $INC ( @INC ) {
     };
     my $mod = $1;
     my $fullmod = "FS::part_event::Condition::$mod";
+    if ( $fullmod =~ /_(Mixin|Common)$/ ) {
+      #warn "skipping $1 class $fullmod\n";
+      next;
+    }
     eval "use $fullmod;";
     if ( $@ ) {
       die "error using $fullmod (skipping): $@\n" if $@;
@@ -220,8 +224,7 @@ sub conditions {
   my( $class, $eventtable ) = @_;
   (
     map  { $_ => $conditions{$_} }
-#    sort { $conditions{$a}->{'default_weight'}<=>$conditions{$b}->{'default_weight'} }
-#    sort by ?
+    sort {$conditions{$a}->{'description'} cmp $conditions{$b}->{'description'}}
     $class->all_conditionnames( $eventtable )
   );
 
@@ -285,7 +288,9 @@ sub where_conditions_sql {
     map {
           my $conditionname = $_;
           my $coderef = $conditions{$conditionname}->{condition_sql};
-          my $sql = &$coderef( $eventtable, 'time'=>$time );
+          my $sql = &$coderef( $eventtable, 'time'        => $time,
+                                            'driver_name' => driver_name(),
+                             );
           die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE';
           "( cond_$conditionname.conditionname IS NULL OR $sql )";
         }