59efce14a22983e787e31a6d92c22bc21f7b11d7
[freeside.git] / httemplate / view / cust_main / packages / location.html
1 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
2
3 % unless ( $cust_pkg->locationnum ) {
4   <I><FONT SIZE=-1>(default service address)</FONT><BR>
5 % }
6
7   <% $loc->get($prefix.'address1') |h %><BR>
8
9 % if ( $loc->get($prefix.'address2') !~ /^\s*$/ ) {
10     <% $loc->get($prefix.'address2') |h %><BR>
11 % }
12
13   <% $loc->get($prefix.'city') |h %><% $loc->get($prefix.'county') ? ' ('.$loc->get($prefix.'county').' county)' : '' |h %>,
14   <% $loc->get($prefix.'state') |h %> &nbsp; <% $loc->get($prefix.'zip') |h %><BR>
15
16 % if ( $loc->get($prefix.'country') ne $countrydefault ) {
17   <% code2country( $loc->get($prefix.'country') ) %>
18 % }
19
20   </I>
21
22 % if ( ! $cust_pkg->get('cancel')
23 %      && $FS::CurrentUser::CurrentUser->access_right('Change customer package')
24 %    )
25 % {
26   <FONT SIZE=-1>
27     (&nbsp;<%pkg_change_location_link($cust_pkg)%>&nbsp;)
28   </FONT>
29 % } 
30
31 </TD>
32 <%init>
33
34 my %opt = @_;
35
36 my $bgcolor        = $opt{'bgcolor'};
37 my $cust_pkg       = $opt{'cust_pkg'};
38 my $part_pkg       = $opt{'part_pkg'};
39 my $countrydefault = $opt{'countrydefault'} || 'US';
40 my $statedefault   = $opt{'statedefault'}
41                      || ($countrydefault eq 'US' ? 'CA' : '');
42
43 my $loc = $cust_pkg->cust_location_or_main;
44 my $prefix =
45   ( $loc->table eq 'cust_main' && length($loc->ship_last) ) ? 'ship_' : ''; #doh
46
47 sub pkg_change_location_link {
48   my $cust_pkg = shift;
49   my $pkgpart = $cust_pkg->pkgpart;
50   include( '/elements/popup_link-cust_pkg.html',
51     'action'      => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
52                      "address1=;address2=;city=;county=;state=$statedefault;".
53                      "zip=;country=$countrydefault",
54     'label'       => 'Change&nbsp;location',
55     'actionlabel' => 'Change',
56     'cust_pkg'    => $cust_pkg,
57   );
58 }
59
60 </%init>