2 Accessible Freeside svc_x fields go in here. RT::URI::freeside::Internal
3 pulls all fields from cust_svc and the svc_x tables into ServiceInfo().
4 RT::Tickets_Overlay resolves "Service.foo" as "cust_svc.foo", and
5 "Service.svc_acct.bar" as "JOIN svc_acct USING (svcnum) ... svc_acct.bar".
7 See /Elements/CustomerFields for notes on this data structure.
11 my @service_fields = ( # ordered
19 foreach my $s (ticket_svc_resolvers($Ticket)) {
20 push @return, \'<A HREF="', $s->HREF, \'">',
28 OrderBy => 'Service.Number',
31 #Column name (format string)
32 Name => 'ServiceType',
33 # Column heading/query builder name
34 Label => 'Service Type',
35 # Column value (coderef, cust_svc/svc_x field, or ServiceInfo key)
36 Display => 'ServiceType',
37 # Query builder options
38 # RT-SQL field, defaults to Name
39 QueryName => 'Service.svcpart',
40 Op => equals_notequals,
41 Value => select_table('part_svc', 'svcpart', 'svc'),
42 # RT-SQL sort key (if any)
43 OrderBy => 'Service.svcpart',
46 Name => 'ServiceKey', # loosely corresponds to smartsearch/label field
52 'Service.svc_acct.username' => loc('Username'),
53 'Service.svc_phone.phonenum' => loc('Phone Number'),
54 'Service.svc_broadband.ip_addr' => loc('IP Address'),
55 'Service.svc_broadband.mac_addr' => loc('MAC Address'),
58 Op => matches_notmatches,
59 Value => { Type => 'text', Size => 20 },
64 QueryName => 'Service.svc_broadband.routernum',
66 Op => equals_notequals,
67 Value => select_table('router', 'routernum', 'routername'),
68 OrderBy => 'Service.svc_broadband.routernum',
74 sub equals_notequals {
77 Path => '/Elements/SelectBoolean',
78 Arguments => { TrueVal=> '=', FalseVal=> '!=' },
81 sub matches_notmatches {
84 Path => '/Elements/SelectMatch',
90 my ($table, $value_col, $name_col, $hashref) = @_;
91 $hashref ||= { disabled => '' }; # common case
96 map { $_->$value_col, $_->$name_col }
97 qsearch($table, $hashref)
102 sub ticket_svc_resolvers {
104 my @Services = @{ $Ticket->Services->ItemsArrayRef };
105 return map $_->TargetURI->Resolver, @Services;
108 sub svc_info_attribute {
109 my $attribute = shift;
113 foreach my $s (ticket_svc_resolvers($Ticket)) {
114 push @return, $s->ServiceInfo->{$attribute}, '<BR>';
116 pop @return; #trailing <BR>
124 #warn Dumper(\@service_fields);
127 if ( $arg eq 'Names' ) {
128 return map { $_->{Name} }
129 grep { exists $_->{Display} }
132 elsif ( $arg eq 'ColumnMap' ) {
136 title => $f->{Label},
137 attribute => $f->{OrderBy} || '',
138 value => ref($f->{Display}) eq 'CODE' ?
140 svc_info_attribute($f->{Display})
143 grep { exists $_->{Display} }
146 elsif ( $arg eq 'Criteria' ) {
149 # argument to Search/Elements/ConditionRow
151 Name => ($f->{QueryName} || $f->{Name}),
152 Field => ($f->{QueryLabel} || $f->{Label}),
154 Value => $f->{Value},
157 grep { exists($_->{Value}) }
160 else { die "unknown ServiceFields mode '$arg'\n"; }