Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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   # these are service locations, so they need all this stuff
14   'enable_coords'       => 1,
15   'enable_district'     => 1,
16   'enable_censustract'  => 1,
17 &>
18 <& /elements/standardize_locations.html,
19             'form'          => 'EditLocationForm',
20             'callback'      => 'document.EditLocationForm.submit();',
21             'with_census'   => 1,
22 &>
23 </TABLE>
24
25 <BR>
26 <SCRIPT TYPE="text/javascript">
27 function go() {
28 % if ( FS::Conf->new->config('address_standardize_method') ) {
29   standardize_locations();
30 % } else {
31   confirm('Modify this service location?') &&
32     document.EditLocationForm.submit();
33 % }
34 }
35
36 function submit_abort() {
37   nd(1);
38 }
39 </SCRIPT>
40 <INPUT TYPE="button" NAME="submitButton" VALUE="Submit" onclick="go()">
41 </FORM>
42 </BODY>
43 </HTML>
44
45 <%init>
46
47 my $conf = new FS::Conf;
48
49 my $curuser = $FS::CurrentUser::CurrentUser;
50
51 # it's the same access right you'd need to do this by editing packages
52 die "access denied"
53   unless $curuser->access_right('Change customer package');
54
55 my $locationnum = scalar($cgi->param('locationnum'));
56 my $cust_location = qsearchs({
57     'select'    => 'cust_location.*',
58     'table'     => 'cust_location',
59     'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
60     'hashref'   => { 'locationnum' => $locationnum },
61     'extra_sql' => ' AND '. $curuser->agentnums_sql,
62   }) or die "unknown locationnum $locationnum";
63
64 die "can't edit disabled locationnum $locationnum" if $cust_location->disabled;
65
66 my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_location->custnum })
67   or die "can't get cust_main record for custnum ". $cust_location->custnum;
68
69 my @cust_pkgs = qsearch('cust_pkg', { 'locationnum' => $locationnum });
70
71 </%init>