summaryrefslogtreecommitdiff
path: root/rt/share
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-11-25 15:08:05 -0800
committerMark Wells <mark@freeside.biz>2015-11-25 15:08:05 -0800
commit974347d88d264c60e65cbd22ac52553931b25ab8 (patch)
treebb3227a64d89afb51fd1927df9152e197a62fbf3 /rt/share
parentd5f8aa5cf1787238224add1a836f0d7577f3b9b7 (diff)
add service location to RT ticket search, #19154
Diffstat (limited to 'rt/share')
-rw-r--r--rt/share/html/Elements/ServiceFields36
1 files changed, 36 insertions, 0 deletions
diff --git a/rt/share/html/Elements/ServiceFields b/rt/share/html/Elements/ServiceFields
index 9c9a248..70eea23 100644
--- a/rt/share/html/Elements/ServiceFields
+++ b/rt/share/html/Elements/ServiceFields
@@ -43,6 +43,11 @@ my @service_fields = ( # ordered
OrderBy => 'Service.svcpart',
},
{
+ Name => 'ServiceLocation',
+ Label => 'Service Location',
+ Display => svc_location_attribute('location'),
+ },
+ {
Name => 'ServiceKey', # loosely corresponds to smartsearch/label field
Label => '',
# not displayable
@@ -118,6 +123,37 @@ sub svc_info_attribute {
};
}
+sub svc_location_attribute {
+ # Tricky: if the ticket is linked to a service, we want to return the
+ # service's location, but if it's not, we want to return the customer's
+ # default service location.
+ # If it's linked to Customer A and also to Service A, it should return
+ # Service A's location (and not Customer A's default service location).
+ # But if it's linked to Service A and also to Customer B, then what? We
+ # can't satisfy all the constraints here.
+ my $attribute = shift;
+ sub {
+ my @return;
+ my $Ticket = shift;
+ my @svc_resolvers = ticket_svc_resolvers($Ticket);
+ if (@svc_resolvers) {
+ warn '#' . $Ticket->id . ", service attribute $attribute\n";
+ foreach my $s (@svc_resolvers) {
+ push @return, $s->ServiceInfo->{$attribute}, '<BR>';
+ }
+ } else {
+ warn '#' . $Ticket->id . ", customer attribute ship_$attribute\n";
+ my @cust_resolvers = map $_->TargetURI->Resolver,
+ @{ $Ticket->Customers->ItemsArrayRef };
+ foreach my $c (@cust_resolvers) {
+ push @return, $c->CustomerInfo->{"ship_$attribute"}, '<BR>';
+ }
+ }
+ pop @return; #trailing <BR>
+ @return;
+ };
+}
+
</%once>
<%init>
use Data::Dumper;