X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition.pm;h=efe0d3cf38b012269743410d75b5e71b43b04f6e;hb=3fba2e94993ce7d1d5c54970817f48bcf81f42fb;hp=ddd8a616f554bc2e8e0e6194d704fba29fa38e8a;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/FS/FS/part_event/Condition.pm b/FS/FS/part_event/Condition.pm index ddd8a616f..efe0d3cf3 100644 --- a/FS/FS/part_event/Condition.pm +++ b/FS/FS/part_event/Condition.pm @@ -145,7 +145,7 @@ passed as an argument. This method is used for optimizing event queries. You may want to add indices for any columns referenced. It is acceptable to return an SQL fragment which partially tests the condition; doing so will still reduce the number of -records which much be returned and tested with the B method. +records which must be returned and tested with the B method. =cut @@ -306,6 +306,28 @@ sub condition_sql_option { )"; } +#c.f. part_event_condition_option.pm / part_event_condition_option_option +#used for part_event/Condition/payby.pm +sub condition_sql_option_option { + my( $class, $option ) = @_; + + ( my $condname = $class ) =~ s/^.*:://; + + my $optionnum = + "( SELECT optionnum FROM part_event_condition_option + WHERE part_event_condition_option.eventconditionnum = + cond_$condname.eventconditionnum + AND part_event_condition_option.optionname = '$option' + AND part_event_condition_option.optionvalue = 'HASH' + )"; + + "( SELECT optionname FROM part_event_condition_option_option + WHERE optionnum = $optionnum + )"; + +} + + =item condition_sql_option_age_from OPTION FROM_TIMESTAMP This is a class method that returns an SQL fragment that will retreive a @@ -435,6 +457,21 @@ sub age2seconds_sql { } +=item condition_sql_option_integer OPTION [ DRIVER_NAME ] + +As I, but cast the option value to an integer so that +comparison to other integers is type-correct. + +=cut + +sub condition_sql_option_integer { + my ($class, $option, $driver_name) = @_; + + my $integer = ($driver_name =~ /^mysql/) ? 'UNSIGNED INTEGER' : 'INTEGER'; + + 'CAST('. $class->condition_sql_option($option). " AS $integer )"; +} + =head1 NEW CONDITION CLASSES A module should be added in FS/FS/part_event/Condition/ which implements the