fix adding a new location on a quotation (v3 fix), RT#73236
[freeside.git] / httemplate / edit / process / quick-cust_pkg.cgi
index 38d5c44..b1d0fe4 100644 (file)
@@ -143,8 +143,21 @@ if ( $quotationnum ) {
   $quotation_pkg->quotationnum($quotationnum);
   $quotation_pkg->prospectnum($prospect_main->prospectnum) if $prospect_main;
 
-  #XXX handle new location
-  $error = $quotation_pkg->insert;
+  my %opt = ();
+
+  if ( $locationnum == -1 ) {
+    my $cust_location = FS::cust_location->new({
+      'custnum'     => $cust_main ? $cust_main->custnum : '',
+      'prospectnum' => $prospect_main ? $prospect_main->prospectnum : '',
+      map { $_ => scalar($cgi->param($_)) }
+        FS::cust_main->location_fields
+    });
+    $opt{'cust_location'} = $cust_location;
+  } else {
+    $opt{'locationnum'} = $locationnum;
+  }
+
+  $error = $quotation_pkg->insert(%opt) || $quotation_pkg->estimate;
 
 } else {