fix non-grouped display of package locations, #22207
[freeside.git] / httemplate / view / cust_main / packages / location.html
1 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" WIDTH="20%">
2
3 % if ( $default ) {
4   <DIV STYLE="font-style: italic; font-size: small">
5   (<% emt('default service address') %>)<BR>
6 % }
7
8     <% $loc->location_label( 'join_string'     => '<BR>',
9                              'double_space'    => ' &nbsp; ',
10                              'escape_function' => \&encode_entities,
11                              'countrydefault'  => $countrydefault,
12                            )
13     %>
14
15 %   if ( $loc->latitude && $loc->longitude ) {
16         <BR>
17         <FONT SIZE=-1>
18         <% $loc->latitude %>, <% $loc->longitude %>
19         <& /elements/coord-links.html,
20              $loc->latitude,
21              $loc->longitude,
22              $opt{'cust_main'}->name_short. ': '. $opt{'part_pkg'}->pkg,
23              $opt{'cust_main'}->agentnum,
24         &>
25         </FONT>
26 %   }
27
28 % if ( $default ) {
29   </DIV>
30 % }
31
32 % if ( ! $cust_pkg->get('cancel')
33 %      && $FS::CurrentUser::CurrentUser->access_right('Change customer package')
34 %    )
35 % {
36   <BR>
37   <FONT SIZE=-1>
38     (&nbsp;<%pkg_change_location_link($cust_pkg)%>&nbsp;)
39 %   if ( $cust_pkg->locationnum ) {
40         (&nbsp;<%edit_location_link($cust_pkg->locationnum)%>&nbsp;)
41 %   }
42   </FONT>
43 % } 
44
45 </TD>
46 <%init>
47
48 my $conf = new FS::Conf;
49 my %opt = @_;
50
51 my $bgcolor        = $opt{'bgcolor'};
52 my $cust_pkg       = $opt{'cust_pkg'};
53 my $countrydefault = $opt{'countrydefault'} || 'US';
54 my $statedefault   = $opt{'statedefault'}
55                      || ($countrydefault eq 'US' ? 'CA' : '');
56
57 my $loc = $cust_pkg->cust_location_or_main;
58 # dubious--they should all have a location now
59 my $default = $cust_pkg->locationnum == $opt{'cust_main'}->ship_locationnum;
60
61 sub pkg_change_location_link {
62   my $cust_pkg = shift;
63   my $pkgpart = $cust_pkg->pkgpart;
64   include( '/elements/popup_link-cust_pkg.html',
65     'action'      => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
66                      "address1=;address2=;city=;county=;state=$statedefault;".
67                      "zip=;country=$countrydefault",
68     'label'       => emt('Change location'),
69     'actionlabel' => emt('Change'),
70     'cust_pkg'    => $cust_pkg,
71   );
72 }
73
74 sub edit_location_link {
75   my $locationnum = shift;
76   include( '/elements/popup_link.html',
77     'action'      => $p. "edit/cust_location.cgi?locationnum=$locationnum",
78     'label'       => emt('Edit location'),
79     'actionlabel' => emt('Edit'),
80   );
81 }
82
83 </%init>