RT# 82949 - changes section name from fees to pricing, better opiton
[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     <& /elements/header-popup.html, emt("Location changed") &>
7       <SCRIPT TYPE="text/javascript">
8         topreload();
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 = FS::cust_location->new({
32   custnum     => $cust_location->custnum,
33   prospectnum => $cust_location->prospectnum,
34   map { $_ => scalar($cgi->param($_)) } FS::cust_main->location_fields
35 });
36 my $error = $new->find_or_insert;
37 $error  ||= $cust_location->move_to($new);
38
39 </%init>