9e4ac3222aa101314f84eda2d930e676f1752f00
[freeside.git] / httemplate / edit / process / quotation_pkg_detail.html
1 % if ( $error ) {
2 <% header('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 <% header($action) %>
8   <SCRIPT TYPE="text/javascript">
9     window.top.location.reload();
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
31 my @orig_details = $quotation_pkg->details();
32
33 my $action = 'Quotation details'.
34              ( scalar(@orig_details) ? ' changed ' : ' added ' );
35
36 my $param = $cgi->Vars;
37 my @details = ();
38 for ( my $row = 0; exists($param->{"detail$row"}); $row++ ) {
39   push @details, $param->{"detail$row"}
40     if $param->{"detail$row"} =~ /\S/;
41 }
42
43 my $error = $quotation_pkg->set_details( 
44               details => \@details,
45               copy_on_order => scalar($cgi->param('copy_on_order')) ? 'Y' : ''
46             );
47
48 </%init>