"Edit Location" should standardize, #13763, #14717
[freeside.git] / httemplate / edit / cust_location.cgi
1 <% include('/elements/header-popup.html', "Edit Location") %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM NAME="EditLocationForm" 
6 ACTION="<% $p %>edit/process/cust_location.cgi" METHOD=POST>
7 <INPUT TYPE="hidden" NAME="locationnum" VALUE="<% $locationnum %>">
8
9 <% ntable('#cccccc') %>
10 <& /elements/location.html,
11             'object'        => $cust_location,
12             'no_asterisks'  => 1,
13 &>
14 <& /elements/standardize_locations.html,
15             'form'          => 'EditLocationForm',
16             'callback'      => 'document.EditLocationForm.submit();',
17 &>
18 </TABLE>
19
20 <BR>
21 <SCRIPT TYPE="text/javascript">
22 function go() {
23 % if ( FS::Conf->new->config('address_standardize_method') ) {
24   standardize_locations();
25 % } else {
26   confirm('Modify this service location?') &&
27     document.EditLocationForm.submit();
28 % }
29 }
30 </SCRIPT>
31 <INPUT TYPE="button" NAME="submitButton" VALUE="Submit" onclick="go()">
32 </FORM>
33 </BODY>
34 </HTML>
35
36 <%init>
37
38 my $conf = new FS::Conf;
39
40 my $curuser = $FS::CurrentUser::CurrentUser;
41
42 # it's the same access right you'd need to do this by editing packages
43 die "access denied"
44   unless $curuser->access_right('Change customer package');
45
46 my $locationnum = scalar($cgi->param('locationnum'));
47 my $cust_location = qsearchs({
48     'select'    => 'cust_location.*',
49     'table'     => 'cust_location',
50     'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
51     'hashref'   => { 'locationnum' => $locationnum },
52     'extra_sql' => ' AND '. $curuser->agentnums_sql,
53   }) or die "unknown locationnum $locationnum";
54
55 die "can't edit disabled locationnum $locationnum" if $cust_location->disabled;
56
57 my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_location->custnum })
58   or die "can't get cust_main record for custnum ". $cust_location->custnum;
59
60 my @cust_pkgs = qsearch('cust_pkg', { 'locationnum' => $locationnum });
61
62 </%init>