% if ( $error ) { <& /elements/header-popup.html, 'Error' &> <% $error |h %>

% } else { <& /elements/header-popup.html, $action &> % } <%init> my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('Generate quotation'); $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum'; my $pkgnum = $1; my $quotation_pkg = qsearchs({ 'table' => 'quotation_pkg', 'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'. 'LEFT JOIN cust_main USING ( custnum )', 'hashref' => { 'quotationpkgnum' => $pkgnum }, 'extra_sql' => ' AND '. $curuser->agentnums_sql, }) || qsearchs({ 'table' => 'quotation_pkg', 'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'. 'LEFT JOIN prospect_main USING ( prospectnum )', 'hashref' => { 'quotationpkgnum' => $pkgnum }, 'extra_sql' => ' AND '. $curuser->agentnums_sql, }); my @orig_details = $quotation_pkg->details(); my $action = 'Quotation details'. ( scalar(@orig_details) ? ' changed ' : ' added ' ); my $param = $cgi->Vars; my @details = (); for ( my $row = 0; exists($param->{"detail$row"}); $row++ ) { push @details, $param->{"detail$row"} if $param->{"detail$row"} =~ /\S/; } my $error = $quotation_pkg->set_details( details => \@details, copy_on_order => scalar($cgi->param('copy_on_order')) ? 'Y' : '' );