replace FS::CGI::header function with header-popup component, related to #71249
[freeside.git] / httemplate / edit / process / cust_location.cgi
index 56c3968..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>
@@ -28,12 +28,12 @@ my $cust_location = qsearchs({
 });
 die "unknown locationnum $locationnum" unless $cust_location;
 
-my $new = FS::cust_location->new_or_existing({
+my $new = FS::cust_location->new({
   custnum     => $cust_location->custnum,
   prospectnum => $cust_location->prospectnum,
   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>