X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fquick-cust_pkg.cgi;h=5afddde15bc86208dd388e3b26e824124475048a;hb=9972d7caa7a3e1a29dc4201e0c7256ba093ea705;hp=34f5d12bd8039818b8655a153710ddace7407e5e;hpb=899cf5029429c1183024cd4bf838573a951d0ede;p=freeside.git diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 34f5d12bd..5afddde15 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -79,9 +79,6 @@ 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 ) = ( '', '' ); @@ -114,19 +111,29 @@ my %hash = ( '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' ) { @@ -152,14 +159,38 @@ foreach my $quantity_param ( grep { $cgi->param($_) && $cgi->param($_) > 0 } } $hash{cust_pkg_usageprice} = \@cust_pkg_usageprice; +# extract details (false laziness with /misc/order_pkg.html) +my $details = { + 'invoice_detail' => [], + 'package_comment' => [], + 'quotation_detail' => [], +}; +foreach my $field ( $cgi->param ) { + foreach my $detailtype ( keys %$details ) { + if ($field =~ /^$detailtype(\d+)$/) { + $details->{$detailtype}->[$1] = $cgi->param($field); + } + } +} +foreach my $detailtype ( keys %$details ) { + @{ $details->{$detailtype} } = grep { length($_) } @{ $details->{$detailtype} }; +} + if ( $quotationnum ) { $quotation_pkg = new FS::quotation_pkg \%hash; $quotation_pkg->quotationnum($quotationnum); $quotation_pkg->prospectnum($prospect_main->prospectnum) if $prospect_main; + my %opt = @{ $details->{'quotation_detail'} } + ? ( + quotation_details => $details->{'quotation_detail'}, + copy_on_order => scalar($cgi->param('copy_on_order')) ? 'Y' : '', + ) + : (); + #XXX handle new location - $error = $quotation_pkg->insert || $quotation_pkg->estimate; + $error = $quotation_pkg->insert(%opt); } else { @@ -187,6 +218,9 @@ if ( $quotationnum ) { $opt{'locationnum'} = $locationnum; } + $opt{'invoice_details'} = $details->{'invoice_detail'} if @{ $details->{'invoice_detail'} }; + $opt{'package_comments'} = $details->{'package_comment'} if @{ $details->{'package_comment'} }; + $error = $cust_main->order_pkg( \%opt ); }