fix selecting multiple services with "Invoice is billing for a certain service type...
[freeside.git] / FS / FS / part_event / Condition / cust_bill_has_service.pm
index 7e63e0e..3f3c908 100644 (file)
@@ -23,6 +23,9 @@ sub option_fields {
   (
     'has_service' => { 'label'      => 'Has service',
                        'type'       => 'select-part_svc',
+                       'multiple'   => 1, #the HTML element seems to have it
+                                          #by default, but edit/part_event.html
+                                          #(and process) need to know
                      },
   );
 }
@@ -32,15 +35,18 @@ sub condition {
   my($self, $cust_bill) = @_;
 
   my $servicenum = $self->option('has_service');
+
   grep { $servicenum == $_->svcpart } 
-  map { $_->cust_pkg->cust_svc }
-  $cust_bill->cust_bill_pkg ;
+    map { $_->cust_svc }
+        $cust_bill->cust_pkg;
 }
 
 sub condition_sql {
-  my( $class, $table ) = @_;
-  
-  my $servicenum = $class->condition_sql_option('has_service');
+  my( $class, $table, %opt ) = @_;
+
+  my $servicenum =
+    $class->condition_sql_option_integer('has_service', $opt{'driver_name'});
+
   my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart)
      FROM cust_bill_pkg cbp, cust_svc cs
     WHERE cbp.invnum = cust_bill.invnum