prevent reload loops on process pages, #71249
[freeside.git] / httemplate / edit / process / cust_location.cgi
index 56c3968..3a23881 100644 (file)
@@ -5,7 +5,7 @@
 
     <% header("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>