selfservice, TNG, RT#22193
[freeside.git] / FS / FS / cust_svc.pm
index 94f04e9..2066a05 100644 (file)
@@ -295,6 +295,17 @@ sub replace {
 #    }
 #  }
 
+  #trigger a pkg_change export on pkgnum changes
+  if ( $new->pkgnum != $old->pkgnum ) {
+    my $error = $new->svc_x->export('pkg_change', $new->cust_pkg,
+                                                  $old->cust_pkg,
+                                   );
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error if $error;
+    }
+  }
+
   #my $error = $new->SUPER::replace($old, @_);
   my $error = $new->SUPER::replace($old);
   if ( $error ) {
@@ -794,14 +805,17 @@ sub get_session_history {
 
 }
 
-=item tickets
+=item tickets  [ STATUS ]
 
 Returns an array of hashes representing the tickets linked to this service.
 
+An optional status (or arrayref or hashref of statuses) may be specified.
+
 =cut
 
 sub tickets {
   my $self = shift;
+  my $status = ( @_ && $_[0] ) ? shift : '';
 
   my $conf = FS::Conf->new;
   my $num = $conf->config('cust_main-max_tickets') || 10;
@@ -810,7 +824,12 @@ sub tickets {
   if ( $conf->config('ticket_system') ) {
     unless ( $conf->config('ticket_system-custom_priority_field') ) {
 
-      @tickets = @{ FS::TicketSystem->service_tickets($self->svcnum, $num) };
+      @tickets = @{ FS::TicketSystem->service_tickets( $self->svcnum,
+                                                       $num,
+                                                       undef,
+                                                       $status,
+                                                     )
+                  };
 
     } else {
 
@@ -820,10 +839,11 @@ sub tickets {
         last if scalar(@tickets) >= $num;
         push @tickets,
         @{ FS::TicketSystem->service_tickets( $self->svcnum,
-            $num - scalar(@tickets),
-            $priority,
-          )
-        };
+                                              $num - scalar(@tickets),
+                                              $priority,
+                                              $status,
+                                            )
+         };
       }
     }
   }