Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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 %   unless ( $opt{no_links} ) {
36       (&nbsp;<%pkg_change_location_link($cust_pkg)%>&nbsp;)
37 %   }
38 %   if ( $cust_pkg->locationnum && ! $opt{no_links} ) {
39         (&nbsp;<%edit_location_link($cust_pkg->locationnum)%>&nbsp;)
40 %   }
41   </FONT>
42 % } 
43
44 <%init>
45
46 my $conf = new FS::Conf;
47 my %opt = @_;
48
49 my $cust_pkg       = $opt{'cust_pkg'};
50 my $countrydefault = $opt{'countrydefault'} || 'US';
51 my $statedefault   = $opt{'statedefault'}
52                      || ($countrydefault eq 'US' ? 'CA' : '');
53
54 my $loc = $cust_pkg->cust_location_or_main;
55 # dubious--they should all have a location now
56 my $default = $cust_pkg->locationnum == $opt{'cust_main'}->ship_locationnum;
57
58 sub pkg_change_location_link {
59   my $cust_pkg = shift;
60   my $pkgpart = $cust_pkg->pkgpart;
61   include( '/elements/popup_link-cust_pkg.html',
62     'action'      => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
63                      "address1=;address2=;city=;county=;state=$statedefault;".
64                      "zip=;country=$countrydefault",
65     'label'       => emt('Change location'),
66     'actionlabel' => emt('Change'),
67     'cust_pkg'    => $cust_pkg,
68     'width'       => 763,
69     'height'      => 380,
70   );
71 }
72
73 sub edit_location_link {
74   my $locationnum = shift;
75   include( '/elements/popup_link.html',
76     'action'      => $p. "edit/cust_location.cgi?locationnum=$locationnum",
77     'label'       => emt('Edit location'),
78     'actionlabel' => emt('Edit'),
79     'width'       => 700,
80     'height'      => 355,
81    );
82 }
83
84 </%init>