RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / process / quotation_pkg_detail.html
1 % if ( $error ) {
2 <& /elements/header-popup.html, 'Error' &>
3 <FONT COLOR="#ff0000"><B><% $error |h %></B></FONT><BR><BR>
4 <CENTER><INPUT TYPE="BUTTON" VALUE="OK" onClick="parent.cClick()"></CENTER>
5 </BODY></HTML>
6 % } else {
7 <& /elements/header-popup.html, $action &>
8   <SCRIPT TYPE="text/javascript">
9     topreload();
10   </SCRIPT>
11   </BODY></HTML>
12 % }
13 <%init>
14
15 my $curuser = $FS::CurrentUser::CurrentUser;
16
17 die "access denied"
18   unless $curuser->access_right('Generate quotation');
19
20 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum';
21 my $pkgnum = $1;
22
23 my $quotation_pkg = qsearchs({
24   'table'     => 'quotation_pkg',
25   'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'.
26                  'LEFT JOIN cust_main USING ( custnum )',
27   'hashref'   => { 'quotationpkgnum' => $pkgnum },
28   'extra_sql' => ' AND '. $curuser->agentnums_sql,
29 })
30 || qsearchs({
31   'table'     => 'quotation_pkg',
32   'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'.
33                  'LEFT JOIN prospect_main USING ( prospectnum )',
34   'hashref'   => { 'quotationpkgnum' => $pkgnum },
35   'extra_sql' => ' AND '. $curuser->agentnums_sql,
36 });
37
38
39 my @orig_details = $quotation_pkg->details();
40
41 my $action = 'Quotation details'.
42              ( scalar(@orig_details) ? ' changed ' : ' added ' );
43
44 my $param = $cgi->Vars;
45 my @details = ();
46 for ( my $row = 0; exists($param->{"detail$row"}); $row++ ) {
47   push @details, $param->{"detail$row"}
48     if $param->{"detail$row"} =~ /\S/;
49 }
50
51 my $error = $quotation_pkg->set_details( 
52               details => \@details,
53               copy_on_order => scalar($cgi->param('copy_on_order')) ? 'Y' : ''
54             );
55
56 </%init>