1 <% include("/elements/header-popup.html", $title, '',
2 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
6 %# <% include('/elements/error.html') %>
8 <FORM ACTION="process/quotation_pkg_detail.html" NAME="DetailForm" ID="DetailForm" METHOD="POST">
10 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
12 <TABLE ID="DetailTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=1 STYLE="background-color: #cccccc">
15 <TD ALIGN="right">Package</TD>
16 <TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
20 <TD ALIGN="right">Comment</TD>
21 <TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
27 <SELECT NAME="copy_on_order">
28 <OPTION VALUE=""<% $copy_on_order ? '' : ' SELECTED' %>>
29 <% emt('Details will only appear on quotation') %>
31 <OPTION VALUE="Y"<% $copy_on_order ? ' SELECTED' : '' %>>
32 <% emt('Copy details to invoice when placing order') %>
42 <TD ALIGN="right"><% $row ? '' : 'Detail' %></TD>
44 <INPUT TYPE="text" NAME="detail<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $_ |h %>" rownum="<% $row++ %>" onkeyup="possiblyAddRow" onchange="possiblyAddrow">
53 <INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="<% $title %>">
57 <SCRIPT TYPE="text/javascript">
58 % # abject false laziness with edit/cust_pkg_detail.html
60 var rownum = <% $row %>;
62 function possiblyAddRow() {
63 if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
70 var table = document.getElementById('DetailTable');
71 var tablebody = table.getElementsByTagName('tbody').item(0);
73 var row = document.createElement('TR');
75 var empty_cell = document.createElement('TD');
77 empty_cell.innerHTML = 'Detail:'
78 empty_cell.style.textAlign = 'right';
80 row.appendChild(empty_cell);
82 var detail_cell = document.createElement('TD');
84 var detail_input = document.createElement('INPUT');
85 detail_input.setAttribute('name', 'detail'+rownum);
86 detail_input.setAttribute('id', 'detail'+rownum);
87 detail_input.setAttribute('size', 60);
88 detail_input.setAttribute('maxLength', 65);
89 detail_input.setAttribute('rownum', rownum);
90 detail_input.onkeyup = possiblyAddRow;
91 detail_input.onchange = possiblyAddRow;
92 detail_cell.appendChild(detail_input);
94 row.appendChild(detail_cell);
96 tablebody.appendChild(row);
108 my $curuser = $FS::CurrentUser::CurrentUser;
111 unless $curuser->access_right('Generate quotation');
113 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum';
116 my $quotation_pkg = qsearchs({
117 'table' => 'quotation_pkg',
118 'addl_from' => 'LEFT JOIN quotation USING ( quotationnum )'.
119 'LEFT JOIN cust_main USING ( custnum )',
120 'hashref' => { 'quotationpkgnum' => $pkgnum },
121 'extra_sql' => ' AND '. $curuser->agentnums_sql,
124 my $part_pkg = $quotation_pkg->part_pkg;
126 my @details = $quotation_pkg->details;
128 my $copy_on_order = 0;
131 # currently, they should either all have this flag, or none
132 # but just in case, erring on the side of not copying to invoice
133 # unless every existing detail has copy_on_order
134 # (anyway, user has to submit change, this is just for autofill)
136 my @quotation_pkg_detail = $quotation_pkg->quotation_pkg_detail;
137 my @copy_on_order = grep { $_->copy_on_order } @quotation_pkg_detail;
138 $copy_on_order = 1 if @copy_on_order;
139 my @no_copy_on_order = grep { !$_->copy_on_order } @quotation_pkg_detail;
140 $copy_on_order = 0 if @no_copy_on_order;
143 my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). 'Quotation Details';