summaryrefslogtreecommitdiff
path: root/rt/share/html/Elements
diff options
context:
space:
mode:
Diffstat (limited to 'rt/share/html/Elements')
-rw-r--r--rt/share/html/Elements/CustomerFields16
-rw-r--r--rt/share/html/Elements/RT__Ticket/ColumnMap1
-rw-r--r--rt/share/html/Elements/ServiceFields161
3 files changed, 172 insertions, 6 deletions
diff --git a/rt/share/html/Elements/CustomerFields b/rt/share/html/Elements/CustomerFields
index 553a34999..d5419d213 100644
--- a/rt/share/html/Elements/CustomerFields
+++ b/rt/share/html/Elements/CustomerFields
@@ -16,7 +16,6 @@ About the keys:
name to sort by.
</%doc>
<%once>
-return unless $RT::URI::freeside::IntegrationType eq 'Internal';
my @customer_fields = ( # ordered
{
@@ -158,8 +157,12 @@ sub select_table {
sub ticket_cust_resolvers {
my $Ticket = shift;
- my @Customers = @{ $Ticket->Customers->ItemsArrayRef };
- return map $_->TargetURI->Resolver, @Customers;
+ my @Customers = map { $_->TargetURI->Resolver->CustomerResolver }
+ @{ $Ticket->Customers->ItemsArrayRef };
+ # this can contain cust_svc links, careful
+ # uniq
+ my %seen = map { $_->URI => $_ } @Customers;
+ values %seen;
}
sub cust_info_attribute { # the simple case of $resolver->CustomerInfo->{foo}
@@ -177,7 +180,6 @@ sub cust_info_attribute { # the simple case of $resolver->CustomerInfo->{foo}
</%once>
<%init>
-return unless $RT::URI::freeside::IntegrationType eq 'Internal';
my $arg = shift;
if ( $arg eq 'Names' ) {
@@ -198,9 +200,11 @@ elsif ( $arg eq 'ColumnMap' ) {
grep { exists $_->{Display} }
@customer_fields;
}
-elsif ( $arg eq 'PickBasics' ) {
+elsif ( $arg eq 'Criteria' ) {
return map {
my $f = $_;
+ # argument to Search/Elements/ConditionRow
+ $f->{Condition} ||
{
Name => ($f->{QueryName} || $f->{Name}),
Field => ($f->{QueryLabel} || $f->{Label}),
@@ -208,7 +212,7 @@ elsif ( $arg eq 'PickBasics' ) {
Value => $f->{Value},
}
} #map
- grep { exists $_->{Value} }
+ grep { exists $_->{Condition} || exists $_->{Value} }
@customer_fields;
}
else { die "unknown CustomerFields mode '$arg'\n"; }
diff --git a/rt/share/html/Elements/RT__Ticket/ColumnMap b/rt/share/html/Elements/RT__Ticket/ColumnMap
index 9e6466cdd..35c0aad86 100644
--- a/rt/share/html/Elements/RT__Ticket/ColumnMap
+++ b/rt/share/html/Elements/RT__Ticket/ColumnMap
@@ -321,6 +321,7 @@ $COLUMN_MAP = {
#freeside
$m->comp('/Elements/CustomerFields', 'ColumnMap'),
+ $m->comp('/Elements/ServiceFields', 'ColumnMap'),
};
# if no GPG support, then KeyOwnerName and KeyRequestors fall back to the regular
diff --git a/rt/share/html/Elements/ServiceFields b/rt/share/html/Elements/ServiceFields
new file mode 100644
index 000000000..9c9a248c8
--- /dev/null
+++ b/rt/share/html/Elements/ServiceFields
@@ -0,0 +1,161 @@
+<%doc>
+Accessible Freeside svc_x fields go in here. RT::URI::freeside::Internal
+pulls all fields from cust_svc and the svc_x tables into ServiceInfo().
+RT::Tickets_Overlay resolves "Service.foo" as "cust_svc.foo", and
+"Service.svc_acct.bar" as "JOIN svc_acct USING (svcnum) ... svc_acct.bar".
+
+See /Elements/CustomerFields for notes on this data structure.
+</%doc>
+<%once>
+
+my @service_fields = ( # ordered
+ {
+ # svcnum
+ Name => 'Service',
+ Label => 'Service',
+ Display => sub {
+ my $Ticket = shift;
+ my @return = ();
+ foreach my $s (ticket_svc_resolvers($Ticket)) {
+ push @return, \'<A HREF="', $s->HREF, \'">',
+ $s->AsString,
+ \'</A>',
+ \'<BR>';
+ }
+ pop @return;
+ @return;
+ },
+ OrderBy => 'Service.Number',
+ },
+ {
+ #Column name (format string)
+ Name => 'ServiceType',
+ # Column heading/query builder name
+ Label => 'Service Type',
+ # Column value (coderef, cust_svc/svc_x field, or ServiceInfo key)
+ Display => 'ServiceType',
+ # Query builder options
+ # RT-SQL field, defaults to Name
+ QueryName => 'Service.svcpart',
+ Op => equals_notequals,
+ Value => select_table('part_svc', 'svcpart', 'svc'),
+ # RT-SQL sort key (if any)
+ OrderBy => 'Service.svcpart',
+ },
+ {
+ Name => 'ServiceKey', # loosely corresponds to smartsearch/label field
+ Label => '',
+ # not displayable
+ QueryLabel => {
+ Type => 'select',
+ Options => [
+ 'Service.svc_acct.username' => loc('Username'),
+ 'Service.svc_phone.phonenum' => loc('Phone Number'),
+ 'Service.svc_broadband.ip_addr' => loc('IP Address'),
+ 'Service.svc_broadband.mac_addr' => loc('MAC Address'),
+ ],
+ },
+ Op => matches_notmatches,
+ Value => { Type => 'text', Size => 20 },
+ },
+ {
+ Name => 'Router',
+ Label => 'Router',
+ QueryName => 'Service.svc_broadband.routernum',
+ # not displayable
+ Op => equals_notequals,
+ Value => select_table('router', 'routernum', 'routername'),
+ OrderBy => 'Service.svc_broadband.routernum',
+ },
+
+);
+#helper subs
+#Op
+sub equals_notequals {
+ {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => { TrueVal=> '=', FalseVal=> '!=' },
+ }
+}
+sub matches_notmatches {
+ {
+ Type => 'component',
+ Path => '/Elements/SelectMatch',
+ },
+}
+
+#Value
+sub select_table {
+ my ($table, $value_col, $name_col, $hashref) = @_;
+ $hashref ||= { disabled => '' }; # common case
+ return {
+ Type => 'select',
+ Options => [
+ '' => '-',
+ map { $_->$value_col, $_->$name_col }
+ qsearch($table, $hashref)
+ ],
+ }
+}
+
+sub ticket_svc_resolvers {
+ my $Ticket = shift;
+ my @Services = @{ $Ticket->Services->ItemsArrayRef };
+ return map $_->TargetURI->Resolver, @Services;
+}
+
+sub svc_info_attribute {
+ my $attribute = shift;
+ sub {
+ my $Ticket = shift;
+ my @return;
+ foreach my $s (ticket_svc_resolvers($Ticket)) {
+ push @return, $s->ServiceInfo->{$attribute}, '<BR>';
+ }
+ pop @return; #trailing <BR>
+ @return;
+ };
+}
+
+</%once>
+<%init>
+use Data::Dumper;
+#warn Dumper(\@service_fields);
+
+my $arg = shift;
+if ( $arg eq 'Names' ) {
+ return map { $_->{Name} }
+ grep { exists $_->{Display} }
+ @service_fields;
+}
+elsif ( $arg eq 'ColumnMap' ) {
+ return map {
+ my $f = $_;
+ $f->{Name} => {
+ title => $f->{Label},
+ attribute => $f->{OrderBy} || '',
+ value => ref($f->{Display}) eq 'CODE' ?
+ $f->{Display} :
+ svc_info_attribute($f->{Display})
+ }
+ } #map
+ grep { exists $_->{Display} }
+ @service_fields;
+}
+elsif ( $arg eq 'Criteria' ) {
+ return map {
+ my $f = $_;
+ # argument to Search/Elements/ConditionRow
+ {
+ Name => ($f->{QueryName} || $f->{Name}),
+ Field => ($f->{QueryLabel} || $f->{Label}),
+ Op => $f->{Op},
+ Value => $f->{Value},
+ }
+ } #map
+ grep { exists($_->{Value}) }
+ @service_fields;
+}
+else { die "unknown ServiceFields mode '$arg'\n"; }
+</%init>