db67d45b98e955259e77d9b21f57927c4a92e7b4
[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 ( !$conf->exists('cust_pkg-group_by_location') ) {
7 %     if ( $default ) {
8         <DIV STYLE="font-style: italic; font-size: small">
9 %     }
10
11       <% $loc->location_label( 'join_string'     => '<BR>',
12                                'double_space'    => ' &nbsp; ',
13                                'escape_function' => \&encode_entities,
14                                'countrydefault'  => $countrydefault,
15                              )
16       %>
17
18 %     if ( $loc->latitude && $loc->longitude ) {
19           <BR>
20           <FONT SIZE=-1>
21           <% $loc->latitude %>, <% $loc->longitude %>
22           <& /elements/coord-links.html,
23                $loc->latitude,
24                $loc->longitude,
25                $opt{'cust_main'}->name_short. ': '. $opt{'part_pkg'}->pkg,
26                $opt{'cust_main'}->agentnum,
27           &>
28           </FONT>
29 %     }
30 %     if ( $loc->censustract ) {
31          <BR>
32          <FONT SIZE=-1>
33          <% $loc->censustract %> (<% $loc->censusyear %> census)
34          </FONT>
35 %     } elsif ( $conf->exists('cust_main-require_censustract') ) {
36           <BR>
37           <FONT SIZE=-1 COLOR="#ee3300">
38           <% emt('Census tract unknown') %>
39           </FONT>
40 %     }
41
42 %     if ( $default ) {
43       </DIV>
44 %     }
45 %   } # all of this is hidden if packages are grouped by location, because
46 %     # it's in the top banner
47
48 %   if ( ! $cust_pkg->get('cancel')
49 %      && $FS::CurrentUser::CurrentUser->access_right('Change customer package')
50 %     )
51 %   {
52   <BR>
53   <FONT SIZE=-1>
54 %     unless ( $opt{no_links} or $opt{'change_from'} ) {
55       (&nbsp;<%pkg_change_location_link($cust_pkg)%>&nbsp;)
56 %     }
57 %     if ( $cust_pkg->locationnum && ! $opt{no_links} ) {
58         (&nbsp;<%pkg_edit_location_link($cust_pkg->locationnum)%>&nbsp;)
59 %     }
60   </FONT>
61 %   } 
62 % } # if the package is a scheduled future package change without location
63 %   # change, then don't show any of this at all.  It's all implied by the
64 %   # preceding package.
65 <%init>
66
67 my $conf = new FS::Conf;
68 my %opt = @_;
69
70 my $cust_pkg       = $opt{'cust_pkg'};
71 my $countrydefault = $opt{'countrydefault'} || 'US';
72 my $statedefault   = $opt{'statedefault'}
73                      || ($countrydefault eq 'US' ? 'CA' : '');
74
75 my $loc = $cust_pkg->cust_location_or_main;
76 # dubious--they should all have a location now
77 my $default = $cust_pkg->locationnum == $opt{'cust_main'}->ship_locationnum;
78
79 sub pkg_change_location_link {
80   my $cust_pkg = shift;
81   my $pkgpart = $cust_pkg->pkgpart;
82   include( '/elements/popup_link-cust_pkg.html',
83     'action'      => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
84                      "address1=;address2=;city=;county=;state=$statedefault;".
85                      "zip=;country=$countrydefault",
86     'label'       => emt('Change location'),
87     'actionlabel' => emt('Change'),
88     'cust_pkg'    => $cust_pkg,
89     'width'       => 960,
90     'height'      => 490,
91   );
92 }
93
94 sub pkg_edit_location_link {
95   my $locationnum = shift;
96   include( '/elements/popup_link.html',
97     'action'      => $p. "edit/cust_location.cgi?locationnum=$locationnum",
98     'label'       => emt('Edit location'),
99     'actionlabel' => emt('Edit'),
100     'width'       => 700,
101     'height'      => 355,
102    );
103 }
104
105 </%init>