X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fedit%2Fprocess%2Fquick-cust_pkg.cgi;h=34f5d12bd8039818b8655a153710ddace7407e5e;hb=9bac210768d909662b03bc2a6552b92b6651cddf;hp=0cc17d36b0554ecae3a40522802f9f5b0f7af671;hpb=ded0ab5cac02f099b387de360fb6dd6bd8cbb6b4;p=freeside.git diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 0cc17d36b..34f5d12bd 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -70,6 +70,9 @@ 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; @@ -107,10 +110,7 @@ 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, @@ -129,6 +129,29 @@ my %hash = ( ); $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; @@ -136,7 +159,7 @@ if ( $quotationnum ) { $quotation_pkg->prospectnum($prospect_main->prospectnum) if $prospect_main; #XXX handle new location - $error = $quotation_pkg->insert; + $error = $quotation_pkg->insert || $quotation_pkg->estimate; } else { @@ -155,11 +178,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 );