$cgi->param('refnum') =~ /^(\d*)$/
or die 'illegal refnum '. $cgi->param('refnum');
my $refnum = $1;
+$cgi->param('salesnum') =~ /^(\d*)$/
+ or die 'illegal salesnum '. $cgi->param('salesnum');
+my $salesnum = $1;
$cgi->param('contactnum') =~ /^(\-?\d*)$/
or die 'illegal contactnum '. $cgi->param('contactnum');
my $contactnum = $1;
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,
'locationnum' => $locationnum,
);
$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'))
+ : '';
+}
+
+my @cust_pkg_usageprice = ();
+foreach my $quantity_param ( grep { $cgi->param($_) && $cgi->param($_) > 0 }
+ grep /^usagepricenum(\d+)_quantity$/,
+ $cgi->param
+ )
+{
+ $quantity_param =~ /^usagepricenum(\d+)_quantity$/ or die 'unpossible';
+ my $num = $1;
+ push @cust_pkg_usageprice, new FS::cust_pkg_usageprice {
+ usagepricepart => scalar($cgi->param("usagepricenum${num}_usagepricepart")),
+ quantity => scalar($cgi->param($quantity_param)),
+ };
+}
+$hash{cust_pkg_usageprice} = \@cust_pkg_usageprice;
+
if ( $quotationnum ) {
$quotation_pkg = new FS::quotation_pkg \%hash;