my %hash = (
'pkgpart' => $pkgpart,
'quantity' => $quantity,
- 'start_date' => ( scalar($cgi->param('start_date'))
- ? parse_datetime($cgi->param('start_date'))
- : ''
- ),
'salesnum' => $salesnum,
'refnum' => $refnum,
'contactnum' => $contactnum,
);
$hash{'custnum'} = $cust_main->custnum if $cust_main;
+if ( $cgi->param('start') eq 'on_hold' ) {
+ $hash{'susp'} = 'now';
+} elsif ( $cgi->param('start') eq 'on_date' ) {
+ $hash{'start_date'} = scalar($cgi->param('start_date'))
+ ? parse_datetime($cgi->param('start_date'))
+ : '';
+}
+
if ( $quotationnum ) {
$quotation_pkg = new FS::quotation_pkg \%hash;
$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 {