1 package FS::UI::Web::small_custview;
4 use vars qw(@EXPORT_OK @ISA);
8 use FS::Record qw(qsearchs);
12 @EXPORT_OK = qw( small_custview );
16 FS::UI::Web::small_custview
20 use FS::UI::Web::small_custview qw( small_custview );
23 $html = small_custview(
24 { 'cust_main' => $cust_main, #or 'custnum' => $custnum,
25 'countrydefault' => 'US',
27 'url' => 'http://freeside.machine/freeside/view/cust_main.cgi',
32 #old-style (deprecated)
33 $html = small_custview( $cust_main, $countrydefault, $nobalance, $url );
37 A subroutine for displaying customer information.
43 =item small_custview HASHREF
45 New-style interface. Keys are:
51 Customer (as a FS::cust_main object)
55 Customer number (if cust_main is not provided).
65 =item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT, NOBALANCE_FLAG, URL
67 Old-style (deprecated) interface.
72 my( $cust_main, $countrydefault, $nobalance, $url, $nopkg );
73 if ( ref($_[0]) eq 'HASH' ) {
75 $cust_main = $opt->{cust_main}
76 || qsearchs('cust_main', { 'custnum' => $opt->{custnum} } );
77 $countrydefault = $opt->{countrydefault} || 'US';
78 $nobalance = $opt->{nobalance};
80 $nopkg = $opt->{nopkg};
83 $countrydefault = shift || 'US';
88 $cust_main = ref($arg) ? $arg
89 : qsearchs('cust_main', { 'custnum' => $arg } )
90 or die "unknown custnum $arg";
93 my $html = '<DIV ID="fs_small_custview" CLASS="small_custview">';
95 $html = qq!<A HREF="$url?! . $cust_main->custnum . '">'
98 $html .= 'Customer #<B>'. $cust_main->display_custnum.
99 ': '. encode_entities($cust_main->name). '</B></A>';
100 ' - <B><FONT COLOR="#'. $cust_main->statuscolor. '">'.
101 ucfirst($cust_main->status). '</FONT></B>';
103 $html .= ' (Balance: <B>$'. $cust_main->balance. '</B>)'
106 my @part_tag = $cust_main->part_tag;
109 foreach my $part_tag ( @part_tag ) {
111 '<FONT '. ( length($part_tag->tagcolor)
112 ? 'STYLE="background-color:#'.$part_tag->tagcolor.'"'
116 encode_entities($part_tag->tagname.': '. $part_tag->tagdesc).
124 ntable('#e8e8e8'). '<TR><TD VALIGN="top">'. ntable("#cccccc",2).
125 '<TR><TD ALIGN="right" VALIGN="top">Billing<BR>Address</TD><TD BGCOLOR="#ffffff">';
127 $html .= encode_entities($cust_main->address1). '<BR>';
128 $html .= encode_entities($cust_main->address2). '<BR>'
129 if $cust_main->address2;
130 $html .= encode_entities($cust_main->city). ', '. $cust_main->state. ' '.
131 $cust_main->zip. '<BR>';
132 $html .= $cust_main->country. '<BR>'
133 if $cust_main->country && $cust_main->country ne $countrydefault;
135 $html .= '</TD></TR><TR><TD></TD><TD BGCOLOR="#ffffff">';
136 if ( $cust_main->daytime && $cust_main->night ) {
137 $html .= ( FS::Msgcat::_gettext('daytime') || 'Day' ).
138 ' '. $cust_main->daytime.
139 '<BR>'. ( FS::Msgcat::_gettext('night') || 'Night' ).
140 ' '. $cust_main->night;
141 } elsif ( $cust_main->daytime || $cust_main->night ) {
142 $html .= $cust_main->daytime || $cust_main->night;
144 if ( $cust_main->fax ) {
145 $html .= '<BR>Fax '. $cust_main->fax;
148 $html .= '</TD></TR></TABLE></TD>';
150 my $ship = $cust_main->ship_location;
152 $html .= '<TD VALIGN="top">'. ntable("#cccccc",2).
153 '<TR><TD ALIGN="right" VALIGN="top">Service<BR>Address</TD><TD BGCOLOR="#ffffff">';
154 $html .= join('<BR>',
155 map encode_entities($_), grep $_,
156 $cust_main->ship_company,
159 ($ship->city . ', ' . $ship->state . ' ' . $ship->zip),
160 ($ship->country eq $countrydefault ? '' : $ship->country ),
163 # ship phone numbers no longer exist...
165 $html .= '</TD></TR></TABLE></TD>';
169 #would be better to use ncancelled_active_pkgs, but that doesn't have an
170 # optimization to just count them yet, so it would be a perf problem on
171 # tons-of-package customers
172 if ( !$nopkg && scalar($cust_main->ncancelled_pkgs) < 20 ) {
174 foreach my $cust_pkg ( $cust_main->ncancelled_active_pkgs ) {
176 $html .= '<TR><TD COLSPAN="2">'.
177 '<B><FONT COLOR="#'. $cust_pkg->statuscolor. '">'.
178 ucfirst($cust_pkg->status). '</FONT></B> - '.
179 encode_entities($cust_pkg->part_pkg->pkg_comment_only(nopkgpart=>1)).
187 # last payment might be good here too?
194 #bah. don't want to pull in all of FS::CGI, that's the whole problem in the
198 my $cellspacing = shift || 0;
200 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing>!;
202 '<TABLE BORDER CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999">';
211 Sheesh. I did switch to mason, but this is still hanging around. Figure out
212 some better way to sling mason components to self-service & RT.
214 (Or, is it useful to have this without depending on the regular back-office UI
215 and Mason stuff to be in place? So we have something suitable for displaying
216 customer information in other external systems, not just RT?)