summaryrefslogtreecommitdiff
path: root/httemplate/edit/cust_location.cgi
blob: 93311c5c3fec1b962f78c9b798b8c850e103a265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<% include('/elements/header-popup.html', "Edit Location") %>

<% include('/elements/error.html') %>

<FORM NAME="EditLocationForm" 
ACTION="<% $p %>edit/process/cust_location.cgi" METHOD=POST>
<INPUT TYPE="hidden" NAME="locationnum" VALUE="<% $locationnum %>">

<% ntable('#cccccc') %>
<& /elements/location.html,
  'object'              => $cust_location,
  'no_asterisks'        => 1,
  # these are service locations, so they need all this stuff
  'enable_coords'       => 1,
  'enable_district'     => 1,
  'enable_censustract'  => 1,
&>
<& /elements/standardize_locations.html,
            'form'          => 'EditLocationForm',
            'callback'    => $conf->exists('tax_district_method')
                              ? 'wa_state_tax_district()'
                              : 'submit_continue()',
            'with_census'   => 1,
            'with_census_functions' => 1,
&>
<script>
  <& /elements/wa_state_tax_district.js &>

  // wa_sate_tax_district() will call submit_continue() upon success,
  //   or submit_abort() upon error
  function submit_continue() {
    document.EditLocationForm.submit();
  }
</script>
</TABLE>

<BR>
<SCRIPT TYPE="text/javascript">
function go() {
  confirm('Modify this service location?') &&
    standardize_locations();
}

function submit_abort() {
  nd(1);
}
</SCRIPT>
<INPUT TYPE="button" NAME="submitButton" VALUE="Submit" onclick="go()">
</FORM>
</BODY>
</HTML>

<%init>

my $conf = new FS::Conf;

my $curuser = $FS::CurrentUser::CurrentUser;

# it's the same access right you'd need to do this by editing packages
die "access denied"
  unless $curuser->access_right('Change customer package');

my $locationnum = scalar($cgi->param('locationnum'));
my $cust_location = qsearchs({
    'select'    => 'cust_location.*',
    'table'     => 'cust_location',
    'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
    'hashref'   => { 'locationnum' => $locationnum },
    'extra_sql' => ' AND '. $curuser->agentnums_sql,
  }) or die "unknown locationnum $locationnum";

die "can't edit disabled locationnum $locationnum" if $cust_location->disabled;

my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_location->custnum })
  or die "can't get cust_main record for custnum ". $cust_location->custnum;

my @cust_pkgs = qsearch('cust_pkg', { 'locationnum' => $locationnum });

</%init>