036bffdde2466ca3cba0b431eeb0875df313e6cf
[freeside.git] / httemplate / edit / quotation_pkg_detail.html
1 <& /elements/header-popup.html, $title &>
2
3 <FORM ACTION="process/quotation_pkg_detail.html" NAME="DetailForm" ID="DetailForm" METHOD="POST">
4
5 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
6
7 <TABLE ID="DetailTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=1 STYLE="background-color: #cccccc">
8
9   <TR>
10     <TD ALIGN="right">Package</TD>
11     <TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
12   </TR>
13
14   <TR>
15     <TD ALIGN="right">Comment</TD>
16     <TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
17   </TR>
18
19   <TR>
20     <TD></TD>
21     <TD>
22       <SELECT NAME="copy_on_order">
23         <OPTION VALUE=""<% $copy_on_order ? '' : ' SELECTED' %>>
24           <% emt('Details will only appear on quotation') %>
25         </OPTION>
26         <OPTION VALUE="Y"<% $copy_on_order ? ' SELECTED' : '' %>>
27           <% emt('Copy details to invoice when placing order') %>
28         </OPTION>
29       </SELECT>
30     </TD>
31   </TR>
32
33 <& elements/detail-table.html, 
34      id      => 'DetailTable',
35      details => \@details,
36      label   => 'Details',
37  &>
38
39 </TABLE>
40
41 <BR>
42 <INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="<% $title %>">
43
44 </FORM>
45
46 </BODY>
47 </HTML>
48 <%init>
49
50 my $curuser = $FS::CurrentUser::CurrentUser;
51
52 die "access denied"
53   unless $curuser->access_right('Generate quotation');
54
55 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum';
56 my $pkgnum = $1;
57
58 my $quotation_pkg = qsearchs({
59   'table'     => 'quotation_pkg',
60   'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'.
61                  'LEFT JOIN cust_main USING ( custnum )',
62   'hashref'   => { 'quotationpkgnum' => $pkgnum },
63   'extra_sql' => ' AND '. $curuser->agentnums_sql,
64 });
65
66 my $part_pkg = $quotation_pkg->part_pkg;
67
68 my @details = $quotation_pkg->details;
69
70 my $copy_on_order = 0;
71 if (@details) {
72
73   # currently, they should either all have this flag, or none
74   # but just in case, erring on the side of not copying to invoice 
75   #   unless every existing detail has copy_on_order
76   # (anyway, user has to submit change, this is just for autofill)
77
78   my @quotation_pkg_detail = $quotation_pkg->quotation_pkg_detail;
79   my @copy_on_order = grep { $_->copy_on_order } @quotation_pkg_detail;
80   $copy_on_order = 1 if @copy_on_order;
81   my @no_copy_on_order = grep { !$_->copy_on_order } @quotation_pkg_detail;
82   $copy_on_order = 0 if @no_copy_on_order;  
83 }
84
85 my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). 'Quotation Details';
86
87 </%init>