replace FS::CGI::header function with header-popup component, related to #71249
[freeside.git] / httemplate / edit / process / cust_location.cgi
index b9f93db..962b1a0 100644 (file)
@@ -3,9 +3,9 @@
 %   $cgi->redirect(popurl(3). 'edit/cust_location.cgi?'. $cgi->query_string );
 % } else {
 
-    <% header("Location changed") %>
+    <& /elements/header-popup.html, emt("Location changed") &>
       <SCRIPT TYPE="text/javascript">
-        window.top.location.reload();
+        topreload();
       </SCRIPT>
     </BODY>
     </HTML>
@@ -31,10 +31,9 @@ die "unknown locationnum $locationnum" unless $cust_location;
 my $new = FS::cust_location->new({
   custnum     => $cust_location->custnum,
   prospectnum => $cust_location->prospectnum,
-  map { $_ => scalar($cgi->param($_)) }
-    qw( address1 address2 city county state zip country )
+  map { $_ => scalar($cgi->param($_)) } FS::cust_main->location_fields
 });
-
-my $error = $cust_location->move_to($new);
+my $error = $new->find_or_insert;
+$error  ||= $cust_location->move_to($new);
 
 </%init>