summaryrefslogtreecommitdiff
path: root/rt/lib/RT/URI
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/URI')
-rw-r--r--rt/lib/RT/URI/freeside.pm38
-rw-r--r--rt/lib/RT/URI/freeside/Internal.pm54
2 files changed, 34 insertions, 58 deletions
diff --git a/rt/lib/RT/URI/freeside.pm b/rt/lib/RT/URI/freeside.pm
index 0e1834f47..64fb377fd 100644
--- a/rt/lib/RT/URI/freeside.pm
+++ b/rt/lib/RT/URI/freeside.pm
@@ -299,39 +299,19 @@ if ($@ &&
die $@;
};
-=item AgentName
+=item CustomerInfo
-Return the name of the customer's agent.
+Return a hashref of customer information, including all fields from
+C<cust_main> as well as:
-=cut
-
-sub AgentName { undef }
-
-=item CustomerClass
-
-Return the name of the customer's class.
-
-=cut
-
-sub CustomerClass { undef }
-
-=item CustomerTags
-
-Return the list of tags attached to the customer. Each tag is returned
-as a hashref with keys "name", "desc", and "color".
-
-=cut
-
-sub CustomerTags { ( ) }
-
-=back
-
-=item Referral
-
-Return the customer's advertising source, as a string.
+- AgentName: the name of the customer's agent
+- CustomerClass: the name of the customer's class
+- CustomerTags: an arrayref of tags attached to the customer, each
+ as a hashref with keys "name", "desc", and "color".
+- Referral: the name of the customer's advertising source.
=cut
-sub Referral { undef }
+sub CustomerInfo { {} }
1;
diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm
index 4069b87af..5656a51d8 100644
--- a/rt/lib/RT/URI/freeside/Internal.pm
+++ b/rt/lib/RT/URI/freeside/Internal.pm
@@ -38,6 +38,7 @@ use FS::Conf;
use FS::Record qw(qsearchs qsearch dbdef);
use FS::cust_main;
use FS::cust_svc;
+use FS::payby;
=head1 NAME
@@ -53,7 +54,7 @@ See L<RT::URI::freeside> for public/private interface documentation.
-sub _FreesideGetRecord { # cache this?
+sub _FreesideGetRecord {
my $self = shift;
my ($table, $pkey) = ($self->{'fstable'}, $self->{'fspkey'});
@@ -142,36 +143,31 @@ sub _FreesideURILabelLong {
}
-sub AgentName {
+# no need to have a separate wrapper method for every one of these things
+sub CustomerInfo {
my $self = shift;
my $rec = $self->_FreesideGetRecord() or return;
- my $agent = $rec->{'_object'}->agent or return;
- return $agent->agentnum . ': ' . $agent->agent;
-}
-
-sub CustomerClass {
- my $self = shift;
- my $rec = $self->_FreesideGetRecord() or return;
- my $cust_class = $rec->{'_object'}->cust_class or return;
- return $cust_class->classname;
-}
-
-sub CustomerTags {
- my $self = shift;
- my $rec = $self->_FreesideGetRecord() or return;
- my @part_tag = $rec->{'_object'}->part_tag;
- return map {
- { 'name' => $_->tagname,
- 'desc' => $_->tagdesc,
- 'color' => $_->tagcolor }
- } @part_tag;
-}
-
-sub Referral {
- my $self = shift;
- my $rec = $self->_FreesideGetRecord() or return;
- my $ref = qsearchs('part_referral', { refnum => $rec->{'_object'}->refnum });
- $ref ? $ref->referral : ''
+ my $cust_main = $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,
+
+ AgentName => ($agent ? ($agent->agentnum.': '.$agent->agent) : ''),
+ CustomerClass => ($class ? $class->classname : ''),
+ CustomerTags => [
+ sort { $a->{'name'} <=> $b->{'name'} }
+ map {
+ { name => $_->tagname, desc => $_->tagdesc, color => $_->tagcolor }
+ } @part_tags
+ ],
+ Referral => ($referral ? $referral->referral : ''),
+ InvoiceEmail => $cust_main->invoicing_list_emailonly_scalar,
+ BillingType => FS::payby->longname($cust_main->payby),
+ }
}
1;