X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fquick-cust_pkg.cgi;h=60352154a1e03c253412622e5c97dcdc935cb6b7;hb=8c8872f684ccfa43dae290877c2cf8aed8828a9f;hp=0cc17d36b0554ecae3a40522802f9f5b0f7af671;hpb=54a357b171aa44f9399b4c146acd2afd3b686075;p=freeside.git diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 0cc17d36b..60352154a 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -70,15 +70,15 @@ my $quantity = $1 || 1; $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; $cgi->param('locationnum') =~ /^(\-?\d*)$/ or die 'illegal locationnum '. $cgi->param('locationnum'); my $locationnum = $1; -$cgi->param('discountnum') =~ /^(\-?\d*)$/ - or die 'illegal discountnum '. $cgi->param('discountnum'); -my $discountnum = $1; # for going right to a provision service after ordering a package my( $svcpart, $part_svc ) = ( '', '' ); @@ -107,28 +107,58 @@ my $error = ''; 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, - 'discountnum' => $discountnum, - #for the create a new discount case - 'discountnum__type' => scalar($cgi->param('discountnum__type')), - 'discountnum_amount' => scalar($cgi->param('discountnum_amount')), - 'discountnum_percent' => scalar($cgi->param('discountnum_percent')), - 'discountnum_months' => scalar($cgi->param('discountnum_months')), - 'discountnum_setup' => scalar($cgi->param('discountnum_setup')), 'contract_end' => ( scalar($cgi->param('contract_end')) ? parse_datetime($cgi->param('contract_end')) : '' ), - 'waive_setup' => ( $cgi->param('waive_setup') eq 'Y' ? 'Y' : '' ), ); + +if ( $cgi->param('setup_discountnum') =~ /^(-?\d+)$/ ) { + if ( $1 == -2 ) { + $hash{waive_setup} = 'Y'; + } else { + $hash{setup_discountnum} = $1; + $hash{setup_discountnum_amount} = $cgi->param('setup_discountnum_amount'); + $hash{setup_discountnum_percent} = $cgi->param('setup_discountnum_percent'); + } +} + +if ( $cgi->param('recur_discountnum') =~ /^(-?\d+)$/ ) { + $hash{recur_discountnum} = $1; + $hash{recur_discountnum_amount} = $cgi->param('recur_discountnum_amount'); + $hash{recur_discountnum_percent} = $cgi->param('recur_discountnum_percent'); + $hash{recur_discountnum_months} = $cgi->param('recur_discountnum_months'); +} + $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; @@ -155,11 +185,13 @@ if ( $quotationnum ) { } if ( $locationnum == -1 ) { - my $cust_location = FS::cust_location->new_or_existing({ + my $cust_location = FS::cust_location->new({ map { $_ => scalar($cgi->param($_)) } ('custnum', FS::cust_main->location_fields) }); $opt{'cust_location'} = $cust_location; + } else { + $opt{'locationnum'} = $locationnum; } $error = $cust_main->order_pkg( \%opt );