cust_location editing features, RT#10766
[freeside.git] / httemplate / edit / process / cust_location.cgi
1 % if ($error) {
2 %   $cgi->param('error', Dumper($error));
3 %   $cgi->redirect(popurl(3). 'edit/cust_location.cgi?'. $cgi->query_string );
4 % } else {
5
6     <% header("Location changed") %>
7       <SCRIPT TYPE="text/javascript">
8         window.top.location.reload();
9       </SCRIPT>
10     </BODY>
11     </HTML>
12
13 % }
14 <%init>
15
16 my $curuser = $FS::CurrentUser::CurrentUser;
17
18 die "access denied"
19   unless $curuser->access_right('Change customer package');
20
21 my $locationnum = $cgi->param('locationnum');
22 my $cust_location = qsearchs({
23   'select'    => 'cust_location.*',
24   'table'     => 'cust_location',
25   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
26   'hashref'   => { 'locationnum' => $locationnum },
27   'extra_sql' => ' AND '. $curuser->agentnums_sql,
28 });
29 die "unknown locationnum $locationnum" unless $cust_location;
30
31 my $new = {
32   map { $_ => scalar($cgi->param($_)) }
33     qw( address1 address2 city county state zip country )
34 };
35
36 my $error = $cust_location->move_to($new);
37
38 </%init>