X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FURI%2Ffreeside%2FInternal.pm;h=33831bcacc46d441665dd8642c029c3971832352;hb=6cd1eaed3f43ff8d3e649f76eb2083587d8d63d1;hp=61b256ef95a48cadcaf039221a3a8f089fba953d;hpb=ef644359f646efb69ecb4c74d55fee05107dad11;p=freeside.git diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm index 61b256ef9..33831bcac 100644 --- a/rt/lib/RT/URI/freeside/Internal.pm +++ b/rt/lib/RT/URI/freeside/Internal.pm @@ -143,7 +143,7 @@ sub small_custview { } -sub _FreesideURILabelLong { +sub AsStringLong { my $self = shift; @@ -152,6 +152,9 @@ sub _FreesideURILabelLong { if ( $table eq 'cust_main' ) { my $rec = $self->_FreesideGetRecord(); + if (!$rec) { + return 'Customer #'.$self->{'fspkey'}.' (not found)'; + } return '' . small_custview( $rec->{'_object'}, scalar(FS::Conf->new->config('countrydefault')), @@ -161,30 +164,28 @@ sub _FreesideURILabelLong { } elsif ( $table eq 'cust_svc' ) { my $string = ''; - # we now do this within the UI - #my $cust = $self->CustomerResolver; - #if ( $cust ) { - # $string = $cust->AsStringLong; - #} - $string .= $self->AsString; + my $cust = $self->CustomerResolver; + if ( $cust ) { + # the customer's small_custview + $string = $cust->AsStringLong(); + } + # + the service label and link + $string .= $self->ShortLink; return $string; } else { - return $self->_FreesideURILabel(); + return $self->SUPER::AsStringLong; } } -sub AsString { +sub ShortLink { + # because I don't want AsString to sometimes return a hunk of HTML, but + # on the other hand AsStringLong does something specific. my $self = shift; - if ( $self->{'fstable'} eq 'cust_svc' ) { - return '' . - $self->_FreesideURILabel . ''; - } else { - $self->SUPER::AsString; - } + '' . $self->_FreesideURILabel . ''; } sub CustomerResolver { @@ -194,28 +195,50 @@ sub CustomerResolver { } 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; + 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; } return; } sub CustomerInfo { my $self = shift; - $self = $self->CustomerResolver or return; - my $rec = $self->_FreesideGetRecord() or return; + $self = $self->CustomerResolver; + return $self->{CustomerInfo} if $self->{CustomerInfo}; + + my $rec = $self->_FreesideGetRecord() if $self; + if (!$rec) { + # AsStringLong will report an error; + # here, just avoid breaking things + my $error = { + AgentName => '', + CustomerClass => '', + CustomerTags => [], + Referral => '', + InvoiceEmail => '', + BillingType => '', + }; + return $error; + } + 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} ||= { + my @lf = $cust_main->location_fields; + my $bill_location = $cust_main->bill_location; + my $ship_location = $cust_main->ship_location; + + my $info = { %$rec, AgentName => ($agent ? ($agent->agentnum.': '.$agent->agent) : ''), @@ -229,7 +252,17 @@ sub CustomerInfo { Referral => ($referral ? $referral->referral : ''), InvoiceEmail => $cust_main->invoicing_list_emailonly_scalar, BillingType => FS::payby->longname($cust_main->payby), + }; + + foreach my $field (@lf) { + $info->{"bill_$field"} = $bill_location->get($field); + $info->{"ship_$field"} = $ship_location->get($field); } + $info->{"bill_location"} = $bill_location->location_label(no_prefix => 1); + $info->{"ship_location"} = $ship_location->location_label(no_prefix => 1); + + + return $self->{CustomerInfo} = $info; } sub ServiceInfo {