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