diff options
Diffstat (limited to 'rt')
-rw-r--r-- | rt/lib/RT/Interface/Web_Vendor.pm | 26 | ||||
-rwxr-xr-x | rt/lib/RT/Record.pm | 47 | ||||
-rw-r--r-- | rt/lib/RT/Tickets_Overlay.pm | 182 | ||||
-rw-r--r-- | rt/lib/RT/URI/freeside/Internal.pm | 81 | ||||
-rw-r--r-- | rt/share/html/Elements/CustomerFields | 16 | ||||
-rw-r--r-- | rt/share/html/Elements/RT__Ticket/ColumnMap | 1 | ||||
-rw-r--r-- | rt/share/html/Elements/ServiceFields | 161 | ||||
-rw-r--r-- | rt/share/html/Search/Elements/BuildFormatString | 1 | ||||
-rw-r--r-- | rt/share/html/Search/Elements/PickBasics | 1 | ||||
-rw-r--r-- | rt/share/html/Search/Elements/PickCriteria | 1 | ||||
-rw-r--r-- | rt/share/html/Search/Elements/PickCustomerFields | 8 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/AddCustomers | 37 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/EditCustomers | 45 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/ShowCustomers | 17 |
14 files changed, 528 insertions, 96 deletions
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm index ee8c34b55..ae7f0899a 100644 --- a/rt/lib/RT/Interface/Web_Vendor.pm +++ b/rt/lib/RT/Interface/Web_Vendor.pm @@ -76,12 +76,32 @@ sub ProcessTicketCustomers { ### ### + #find new services + ### + + my @svcnums = map { /^Ticket-AddService-(\d+)$/; $1 } + grep { /^Ticket-AddService-(\d+)$/ && $ARGSRef->{$_} } + keys %$ARGSRef; + + my @custnums; + foreach my $svcnum (@svcnums) { + my @link = ( 'Type' => 'MemberOf', + 'Target' => "freeside://freeside/cust_svc/$svcnum", + ); + + my( $val, $msg ) = $Ticket->AddLink(@link); + push @results, $msg; + next if !$val; + + } + + ### #find new customers ### - my @custnums = map { /^Ticket-AddCustomer-(\d+)$/; $1 } - grep { /^Ticket-AddCustomer-(\d+)$/ && $ARGSRef->{$_} } - keys %$ARGSRef; + push @custnums, map { /^Ticket-AddCustomer-(\d+)$/; $1 } + grep { /^Ticket-AddCustomer-(\d+)$/ && $ARGSRef->{$_} } + keys %$ARGSRef; #my @delete_custnums = # map { /^Ticket-AddCustomer-(\d+)$/; $1 } diff --git a/rt/lib/RT/Record.pm b/rt/lib/RT/Record.pm index 121c08686..41e60bd84 100755 --- a/rt/lib/RT/Record.pm +++ b/rt/lib/RT/Record.pm @@ -1177,7 +1177,9 @@ sub DependsOn { =head2 Customers - This returns an RT::Links object which references all the customers that this object is a member of. + This returns an RT::Links object which references all the customers that + this object is a member of. This includes both explicitly linked customers + and links implied by services. =cut @@ -1189,11 +1191,16 @@ sub Customers { $self->{'Customers'} = $self->MemberOf->Clone; - $self->{'Customers'}->Limit( - FIELD => 'Target', - OPERATOR => 'STARTSWITH', - VALUE => 'freeside://freeside/cust_main/', - ); + for my $fstable (qw(cust_main cust_svc)) { + + $self->{'Customers'}->Limit( + FIELD => 'Target', + OPERATOR => 'STARTSWITH', + VALUE => "freeside://freeside/$fstable", + ENTRYAGGREGATOR => 'OR', + SUBCLAUSE => 'customers', + ); + } } warn "->Customers method called on $self; returning ". @@ -1205,6 +1212,34 @@ sub Customers { # }}} +# {{{ Services + +=head2 Services + + This returns an RT::Links object which references all the services this + object is a member of. + +=cut + +sub Services { + my( $self, %opt ) = @_; + + unless ( $self->{'Services'} ) { + + $self->{'Services'} = $self->MemberOf->Clone; + + $self->{'Services'}->Limit( + FIELD => 'Target', + OPERATOR => 'STARTSWITH', + VALUE => "freeside://freeside/cust_svc", + ); + } + + return $self->{'Services'}; +} + +# }}} + # {{{ sub _Links =head2 Links DIRECTION [TYPE] diff --git a/rt/lib/RT/Tickets_Overlay.pm b/rt/lib/RT/Tickets_Overlay.pm index a5d37a378..0d482cd04 100644 --- a/rt/lib/RT/Tickets_Overlay.pm +++ b/rt/lib/RT/Tickets_Overlay.pm @@ -146,11 +146,8 @@ our %FIELD_METADATA = ( HasAttribute => [ 'HASATTRIBUTE', 1 ], HasNoAttribute => [ 'HASATTRIBUTE', 0 ], #freeside - Customer => [ 'FREESIDEFIELD', ], -# Agentnum => [ 'FREESIDEFIELD', ], -# Classnum => [ 'FREESIDEFIELD', ], -# Refnum => [ 'FREESIDEFIELD', ], -# Tagnum => [ 'FREESIDEFIELD', 'cust_tag' ], + Customer => [ 'FREESIDEFIELD' => 'Customer' ], + Service => [ 'FREESIDEFIELD' => 'Service' ], WillResolve => [ 'DATE' => 'WillResolve', ], #loc_left_pair ); @@ -1823,6 +1820,15 @@ sub OrderByCols { } push @res, { %$row, ALIAS => $custalias, FIELD => $cust_field }; + } elsif ( $field eq 'Service' ) { + + my $svcalias = $self->JoinToService; + my $svc_field = lc($subkey); + if ( !$svc_field or $svc_field eq 'number' ) { + $svc_field = 'svcnum'; + } + push @res, { %$row, ALIAS => $svcalias, FIELD => $svc_field }; + } #Freeside else { @@ -1842,7 +1848,7 @@ sub JoinToCustLinks { # and an sql expression to retrieve the custnum. my $self = shift; # only join once for each RT::Tickets object - my $linkalias = $self->{cust_linkalias}; + my $linkalias = $self->{cust_main_linkalias}; if (!$linkalias) { $linkalias = $self->Join( TYPE => 'LEFT', @@ -1864,7 +1870,7 @@ sub JoinToCustLinks { OPERATOR => 'STARTSWITH', VALUE => 'freeside://freeside/cust_main/', ); - $self->{cust_linkalias} = $linkalias; + $self->{cust_main_linkalias} = $linkalias; } my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS "; if ( RT->Config->Get('DatabaseType') eq 'mysql' ) { @@ -1890,9 +1896,79 @@ sub JoinToCustomer { return $custalias; } +sub JoinToSvcLinks { + my $self = shift; + my $linkalias = $self->{cust_svc_linkalias}; + if (!$linkalias) { + $linkalias = $self->Join( + TYPE => 'LEFT', + ALIAS1 => 'main', + FIELD1 => 'id', + TABLE2 => 'Links', + FIELD2 => 'LocalBase', + ); + + $self->SUPER::Limit( + LEFTJOIN => $linkalias, + FIELD => 'Type', + OPERATOR => '=', + VALUE => 'MemberOf', + ); + $self->SUPER::Limit( + LEFTJOIN => $linkalias, + FIELD => 'Target', + OPERATOR => 'STARTSWITH', + VALUE => 'freeside://freeside/cust_svc/', + ); + $self->{cust_svc_linkalias} = $linkalias; + } + my $svcnum_sql = "CAST(SUBSTR($linkalias.Target,30) AS "; + if ( RT->Config->Get('DatabaseType') eq 'mysql' ) { + $svcnum_sql .= 'SIGNED INTEGER)'; + } + else { + $svcnum_sql .= 'INTEGER)'; + } + return ($linkalias, $svcnum_sql); +} + +sub JoinToService { + my $self = shift; + my ($linkalias, $svcnum_sql) = $self->JoinToSvcLinks; + $self->Join( + TYPE => 'LEFT', + EXPRESSION => $svcnum_sql, + TABLE2 => 'cust_svc', + FIELD2 => 'svcnum', + ); +} + +# This creates an alternate left join path to cust_main via cust_svc. +# _FreesideFieldLimit needs to add this as a separate, independent join +# and include all tickets that have a matching cust_main record via +# either path. +sub JoinToCustomerViaService { + my $self = shift; + my $svcalias = $self->JoinToService; + my $cust_pkg = $self->Join( + TYPE => 'LEFT', + ALIAS1 => $svcalias, + FIELD1 => 'pkgnum', + TABLE2 => 'cust_pkg', + FIELD2 => 'pkgnum', + ); + my $cust_main = $self->Join( + TYPE => 'LEFT', + ALIAS1 => $cust_pkg, + FIELD1 => 'custnum', + TABLE2 => 'cust_main', + FIELD2 => 'custnum', + ); + $cust_main; +} + sub _FreesideFieldLimit { my ( $self, $field, $op, $value, %rest ) = @_; - my $alias = $self->JoinToCustomer; my $is_negative = 0; if ( $op eq '!=' || $op =~ /\bNOT\b/i ) { # if the op is negative, do the join as though @@ -1903,40 +1979,70 @@ sub _FreesideFieldLimit { $op =~ s/\bNOT\b//; } - my $cust_field = $rest{SUBKEY} || 'custnum'; + my (@alias, $table2, $subfield, $pkey); + if ( $field eq 'Customer' ) { + push @alias, $self->JoinToCustomer; + push @alias, $self->JoinToCustomerViaService; + $pkey = 'custnum'; + } + elsif ( $field eq 'Service' ) { + push @alias, $self->JoinToService; + $pkey = 'svcnum'; + } + else { + die "malformed Freeside query: $field"; + } + + $subfield = $rest{SUBKEY} || $pkey; my $table2; # compound subkey: separate into table name and field in that table # (must be linked by custnum) - ($table2, $cust_field) = ($1, $2) if $cust_field =~ /^(\w+)?\.(\w+)$/; - - $cust_field = lc($cust_field); - $cust_field = 'custnum' if !$cust_field or $cust_field eq 'number'; - - if ( $table2 ) { - $alias = $self->Join( - TYPE => 'LEFT', - ALIAS1 => $alias, - FIELD1 => 'custnum', - TABLE2 => $table2, - FIELD2 => 'custnum', - ); + $subfield = lc($subfield); + ($table2, $subfield) = ($1, $2) if $subfield =~ /^(\w+)?\.(\w+)$/; + $subfield = $pkey if $subfield eq 'number'; + + # if it's compound, create a join from cust_main or cust_svc to that + # table, using custnum or svcnum, and Limit on that table instead. + foreach my $a (@alias) { + if ( $table2 ) { + $a = $self->Join( + TYPE => 'LEFT', + ALIAS1 => $a, + FIELD1 => $pkey, + TABLE2 => $table2, + FIELD2 => $pkey, + ); + } + + # do the actual Limit + $self->SUPER::Limit( + LEFTJOIN => $a, + FIELD => $subfield, + OPERATOR => $op, + VALUE => $value, + ENTRYAGGREGATOR => 'AND', + # no SUBCLAUSE needed, limits on different aliases across left joins + # are inherently independent + ); + + # then, since it's a left join, exclude tickets for which there is now + # no matching record in the table we just limited on. (Or where there + # is a matching record, if $is_negative.) + # For a cust_main query (where there are two different aliases), this + # will produce a subclause: "cust_main_1.custnum IS NOT NULL OR + # cust_main_2.custnum IS NOT NULL" (or "IS NULL AND..." for a negative + # query). + $self->_SQLLimit( + %rest, + ALIAS => $a, + FIELD => $pkey, + OPERATOR => $is_negative ? 'IS' : 'IS NOT', + VALUE => 'NULL', + QUOTEVALUE => 0, + ENTRYAGGREGATOR => $is_negative ? 'AND' : 'OR', + SUBCLAUSE => 'fs_limit', + ); } - - $self->SUPER::Limit( - LEFTJOIN => $alias, - FIELD => $cust_field, - OPERATOR => $op, - VALUE => $value, - ENTRYAGGREGATOR => 'AND', - ); - $self->_SQLLimit( - %rest, - ALIAS => $alias, - FIELD => 'custnum', - OPERATOR => $is_negative ? 'IS' : 'IS NOT', - VALUE => 'NULL', - QUOTEVALUE => 0, - ); } #Freeside diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm index 5656a51d8..b5e56ee1f 100644 --- a/rt/lib/RT/URI/freeside/Internal.pm +++ b/rt/lib/RT/URI/freeside/Internal.pm @@ -38,8 +38,14 @@ use FS::Conf; use FS::Record qw(qsearchs qsearch dbdef); use FS::cust_main; use FS::cust_svc; +use FS::part_svc; use FS::payby; +#can I do this? +FS::UID->install_callback( + sub { @RT::URI::freeside::svc_tables = FS::part_svc->svc_tables() } +); + =head1 NAME RT::URI::freeside::Internal @@ -105,7 +111,23 @@ sub FreesideGetConfig { sub smart_search { #Subroutine - return map { { $_->hash } } &FS::cust_main::Search::smart_search(@_); + return map { { $_->hash } } &FS::cust_main::Search::smart_search(@_); + +} + +sub service_search { + + return map { + my $cust_pkg = $_->cust_pkg; + my $custnum = $cust_pkg->custnum if $cust_pkg; + my $label = join(': ',($_->label)[0, 1]); + my %hash = ( + $_->hash, + 'label' => $label, + 'custnum' => $custnum, # so that it's smart_searchable... + ); + \%hash + } &FS::cust_svc::smart_search(@_); } @@ -130,10 +152,22 @@ sub _FreesideURILabelLong { if ( $table eq 'cust_main' ) { my $rec = $self->_FreesideGetRecord(); - return small_custview( $rec->{'_object'}, + return '<A HREF="' . $self->HREF . '">' . + small_custview( $rec->{'_object'}, scalar(FS::Conf->new->config('countrydefault')), - 1 #nobalance - ); + 1, #nobalance + ) . '</A>'; + + } elsif ( $table eq 'cust_svc' ) { + + my $string = ''; + my $cust = $self->CustomerResolver; + if ( $cust ) { + $string = $cust->AsStringLong; + } + $string .= '<B><A HREF="' . $self->HREF . '">' . + $self->AsString . '</A></B>'; + return $string; } else { @@ -143,18 +177,36 @@ sub _FreesideURILabelLong { } -# no need to have a separate wrapper method for every one of these things +sub CustomerResolver { + my $self = shift; + if ( $self->{fstable} eq 'cust_main' ) { + return $self; + } + elsif ( $self->{fstable} eq 'cust_svc' ) { + my $rec = $self->_FreesideGetRecord(); + return if !$rec; + my $cust_pkg = $rec->{'_object'}->cust_pkg; + if ( $cust_pkg ) { + my $URI = RT::URI->new($self->CurrentUser); + $URI->FromURI('freeside://freeside/cust_main/'.$cust_pkg->custnum); + return $URI->Resolver; + } + } + return; +} + sub CustomerInfo { my $self = shift; + $self = $self->CustomerResolver or return; my $rec = $self->_FreesideGetRecord() or return; - my $cust_main = $rec->{'_object'}; + my $cust_main = delete $rec->{_object}; my $agent = $cust_main->agent; my $class = $cust_main->cust_class; my $referral = qsearchs('part_referral', { refnum => $cust_main->refnum }); my @part_tags = $cust_main->part_tag; return $self->{CustomerInfo} ||= { - $cust_main->hash, + %$rec, AgentName => ($agent ? ($agent->agentnum.': '.$agent->agent) : ''), CustomerClass => ($class ? $class->classname : ''), @@ -170,4 +222,19 @@ sub CustomerInfo { } } +sub ServiceInfo { + my $self = shift; + $self->{fstable} eq 'cust_svc' or return; + my $rec = $self->_FreesideGetRecord() or return; + my $cust_svc = $rec->{'_object'}; + my $svc_x = $cust_svc->svc_x; + my $part_svc = $cust_svc->part_svc; + return $self->{ServiceInfo} ||= { + $cust_svc->hash, + $svc_x->hash, + ServiceType => $part_svc->svc, + Label => $self->AsString, + } +} + 1; 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> diff --git a/rt/share/html/Search/Elements/BuildFormatString b/rt/share/html/Search/Elements/BuildFormatString index 96e6a2863..57c767911 100644 --- a/rt/share/html/Search/Elements/BuildFormatString +++ b/rt/share/html/Search/Elements/BuildFormatString @@ -76,6 +76,7 @@ my @fields = ( ), $m->comp('/Elements/CustomerFields', 'Names'), #freeside + $m->comp('/Elements/ServiceFields', 'Names'), #freeside qw( Status ExtendedStatus UpdateStatus diff --git a/rt/share/html/Search/Elements/PickBasics b/rt/share/html/Search/Elements/PickBasics index ff30f7c11..e9534237b 100644 --- a/rt/share/html/Search/Elements/PickBasics +++ b/rt/share/html/Search/Elements/PickBasics @@ -210,7 +210,6 @@ my @lines = ( ); #freeside -push @lines, $m->comp('/Elements/CustomerFields', 'PickBasics'); $m->callback( Conditions => \@lines ); diff --git a/rt/share/html/Search/Elements/PickCriteria b/rt/share/html/Search/Elements/PickCriteria index 44e3b7037..5eb112d17 100644 --- a/rt/share/html/Search/Elements/PickCriteria +++ b/rt/share/html/Search/Elements/PickCriteria @@ -52,6 +52,7 @@ <& PickBasics &> +<& PickCustomerFields &> <& PickCFs, cfqueues => \%cfqueues &> <tr class="separator"><td colspan="3"><hr /></td></tr> diff --git a/rt/share/html/Search/Elements/PickCustomerFields b/rt/share/html/Search/Elements/PickCustomerFields new file mode 100644 index 000000000..96d8e47e7 --- /dev/null +++ b/rt/share/html/Search/Elements/PickCustomerFields @@ -0,0 +1,8 @@ +% if ( $RT::URI::freeside::IntegrationType eq 'Internal' ) { +% my @lines; +% push @lines, $m->comp('/Elements/CustomerFields', 'Criteria'); +% push @lines, $m->comp('/Elements/ServiceFields', 'Criteria'); +% foreach( @lines ) { +<& ConditionRow, Condition => $_ &> +% } +% } diff --git a/rt/share/html/Ticket/Elements/AddCustomers b/rt/share/html/Ticket/Elements/AddCustomers index 09acdfd3f..3c2c82add 100644 --- a/rt/share/html/Ticket/Elements/AddCustomers +++ b/rt/share/html/Ticket/Elements/AddCustomers @@ -13,15 +13,25 @@ <BR> <%$msg%><br> -% if (@Customers) { +% if (@Customers or @Services) { -<br><i>(Check box to link)<i> +<br><i>(Check box to link)</i> <table> % foreach my $customer (@Customers) { <tr> <td> <input type="checkbox" name="Ticket-AddCustomer-<% $customer->{'custnum'} %>" VALUE="1" <% scalar(@Customers) == 1 ? 'CHECKED' : '' %>> - <A HREF="<%$freeside_url%>/view/cust_main.cgi?<% $customer->{'custnum'} %>"><% &RT::URI::freeside::small_custview($customer->{'custnum'}, &RT::URI::freeside::FreesideGetConfig('countrydefault'), 1) |n %> + <& .small_custview, $customer &> + </td> +</tr> +% } +% +% foreach my $service (@Services) { +<tr> + <td> + <input type="checkbox" name="Ticket-AddService-<% $service->{'svcnum'} %>" VALUE="1" <% scalar(@Services) == 1 ? 'CHECKED' : '' %>> + <& .small_custview, $service &> + <& .small_svcview, $service &> </td> </tr> % } @@ -29,11 +39,21 @@ % } +<%once> +my $freeside_url = &RT::URI::freeside::FreesideURL(); + +</%once> +<%def .small_custview> +% my $cust = shift; +<A HREF="<%$freeside_url%>/view/cust_main.cgi?<% $cust->{'custnum'}%>"><% &RT::URI::freeside::small_custview($cust->{'custnum'}, &RT::URI::freeside::FreesideGetConfig, 1) |n %></A> +</%def> +<%def .small_svcview> +% my $svc = shift; +<A HREF="<%$freeside_url%>/view/cust_svc.cgi?<% $svc->{'svcnum'}%>"><B><% $svc->{'label'} %></B></A> +</%def> <%INIT> my ($msg); -my $freeside_url = &RT::URI::freeside::FreesideURL(); - my @Customers = (); if ( $CustomerString ) { @Customers = &RT::URI::freeside::smart_search( @@ -43,8 +63,11 @@ if ( $CustomerString ) { } my @Services = (); -if ($ServiceString) { - @Services = (); #service_search(); +if ( $ServiceString + and $RT::URI::freeside::IntegrationType eq 'Internal' ) { + @Services = RT::URI::freeside::service_search( + 'search' => $ServiceString, + ); } </%INIT> diff --git a/rt/share/html/Ticket/Elements/EditCustomers b/rt/share/html/Ticket/Elements/EditCustomers index 0ba6e447b..96207f4cc 100644 --- a/rt/share/html/Ticket/Elements/EditCustomers +++ b/rt/share/html/Ticket/Elements/EditCustomers @@ -12,7 +12,7 @@ %# General Public License for more details. <TABLE width=100%> <TR> - <TD VALIGN=TOP WIDTH=50%> + <TD VALIGN=TOP WIDTH=50% ROWSPAN=3> <h3><&|/l&>Current Customers</&></h3> <table> @@ -25,33 +25,40 @@ <INPUT TYPE=CHECKBOX NAME="DeleteLink--<%$link->Type%>-<%$link->Target%>"> %# <& ShowLink, URI => $link->TargetURI &><br> - <A HREF="<% $link->TargetURI->Resolver->HREF %>"><% $link->TargetURI->Resolver->AsStringLong |n %></A> - <BR> + <% $link->TargetURI->Resolver->AsStringLong |n %></A> + <BR><BR> % } </td> </tr> </table> - + </TD> -<TD VALIGN=TOP> +<TD VALIGN=TOP WIDTH=50% COLSPAN=2> <h3><&|/l&>New Customer Links</&></h3> -<&|/l&>Find customer</&><BR> -<input name="CustomerString"> -<input type=submit name="OnlySearchForCustomers" value="<&|/l&>Go!</&>"> -<br><i>cust #, name, company or phone</i> -<BR> -%#<BR> -%#<&|/l&>Find service</&><BR> -%#<input name="ServiceString"> -%#<input type=submit name="OnlySearchForServices" value="<&|/l&>Go!</&>"> -%#<br><i>username, username@domain, domain, or IP address</i> -%#<BR> - +</TD> +</TR> +<TR VALIGN="top"> +%# rowspan + <td width=25%> + <&|/l&>Find customer</&><br> + <input name="CustomerString"> + <input type=submit name="OnlySearchForCustomers" value="<&|/l&>Go!</&>"> + <br><i>cust #, name, company or phone</i> + </td> + <td width=25%> + <&|/l&>Find service</&><br> + <input name="ServiceString"> + <input type=submit name="OnlySearchForServices" value="<&|/l&>Go!</&>"> + <br><i>user, email, ip, mac, phone</i> + </td> +</TR> +<TR> +%#rowspan... +<TD COLSPAN=2> <& AddCustomers, Ticket => $Ticket, CustomerString => $CustomerString, - ServiceString => $ServiceString, &> - + ServiceString => $ServiceString &> </TD> </TR> </TABLE> diff --git a/rt/share/html/Ticket/Elements/ShowCustomers b/rt/share/html/Ticket/Elements/ShowCustomers index 3acf92dd4..add562440 100644 --- a/rt/share/html/Ticket/Elements/ShowCustomers +++ b/rt/share/html/Ticket/Elements/ShowCustomers @@ -10,20 +10,19 @@ %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. <table> -% my $cust = 0; -% foreach my $custResolver ( map { $_->TargetURI->Resolver } -% @{ $Ticket->Customers->ItemsArrayRef } -% ) -% { -% $cust++; -% my $cust_main = ''; +% my @cust = map { $_->TargetURI->Resolver } +% @{ $Ticket->Customers->ItemsArrayRef }; +% +% foreach my $custResolver ( @cust ) { <tr> <td class="value"> - <A HREF="<% $custResolver->HREF %>"><% $custResolver->AsStringLong |n %></A> + <% $custResolver->AsStringLong |n %> +%# includes service label and view/svc_ link for cust_svc links </td> </tr> % } -% unless ( $cust ) { + +% unless ( @cust ) { <tr> <td class="labeltop"> <i>(none)<i> |