Reverted menu-left-example.png back to original and cleaned up menu-top-example to...
[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 || qsearchs({
66   'table'     => 'quotation_pkg',
67   'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'.
68                  'LEFT JOIN prospect_main USING ( prospectnum )',
69   'hashref'   => { 'quotationpkgnum' => $pkgnum },
70   'extra_sql' => ' AND '. $curuser->agentnums_sql,
71 });
72
73 my $part_pkg = $quotation_pkg->part_pkg;
74
75 my @details = $quotation_pkg->details;
76
77 my $copy_on_order = 0;
78 if (@details) {
79
80   # currently, they should either all have this flag, or none
81   # but just in case, erring on the side of not copying to invoice 
82   #   unless every existing detail has copy_on_order
83   # (anyway, user has to submit change, this is just for autofill)
84
85   my @quotation_pkg_detail = $quotation_pkg->quotation_pkg_detail;
86   my @copy_on_order = grep { $_->copy_on_order } @quotation_pkg_detail;
87   $copy_on_order = 1 if @copy_on_order;
88   my @no_copy_on_order = grep { !$_->copy_on_order } @quotation_pkg_detail;
89   $copy_on_order = 0 if @no_copy_on_order;  
90 }
91
92 my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). 'Quotation Details';
93
94 </%init>