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