Revert "RT#41671 Fix double click prevention for all legacy buttons [renamed all...
[freeside.git] / httemplate / edit / quotation_pkg_detail.html
index b8f589a..036bffd 100644 (file)
@@ -1,9 +1,4 @@
-<% include("/elements/header-popup.html", $title, '',
-            ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
-          )
-%>
-
-%# <% include('/elements/error.html') %>
+<& /elements/header-popup.html, $title &>
 
 <FORM ACTION="process/quotation_pkg_detail.html" NAME="DetailForm" ID="DetailForm" METHOD="POST">
 
   </TR>
 
   <TR>
-    <TD COLSPAN=2>Detail: </TD>
+    <TD></TD>
+    <TD>
+      <SELECT NAME="copy_on_order">
+        <OPTION VALUE=""<% $copy_on_order ? '' : ' SELECTED' %>>
+          <% emt('Details will only appear on quotation') %>
+        </OPTION>
+        <OPTION VALUE="Y"<% $copy_on_order ? ' SELECTED' : '' %>>
+          <% emt('Copy details to invoice when placing order') %>
+        </OPTION>
+      </SELECT>
+    </TD>
   </TR>
 
-% my $row = 0;
-% for ( @details ) { 
-
-    <TR>
-      <TD></TD>
-      <TD>
-        <INPUT TYPE="text" NAME="detail<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $_ |h %>" rownum="<% $row++ %>" onkeyup="possiblyAddRow" onchange="possiblyAddrow">
-      </TD>
-    </TR>
-
-% } 
+<& elements/detail-table.html, 
+     id      => 'DetailTable',
+     details => \@details,
+     label   => 'Details',
+ &>
 
 </TABLE>
 
 
 </FORM>
 
-<SCRIPT TYPE="text/javascript">
-% # abject false laziness with edit/cust_pkg_detail.html
-
-  var rownum = <% $row %>;
-
-  function possiblyAddRow() {
-    if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
-      addRow();
-    }
-  }
-
-  function addRow() {
-
-    var table = document.getElementById('DetailTable');
-    var tablebody = table.getElementsByTagName('tbody').item(0);
-
-    var row = document.createElement('TR');
-
-    var empty_cell = document.createElement('TD');
-    row.appendChild(empty_cell);
-
-    var detail_cell = document.createElement('TD');
-
-      var detail_input = document.createElement('INPUT');
-      detail_input.setAttribute('name', 'detail'+rownum);
-      detail_input.setAttribute('id',   'detail'+rownum);
-      detail_input.setAttribute('size', 60);
-      detail_input.setAttribute('maxLength', 65);
-      detail_input.setAttribute('rownum',   rownum);
-      detail_input.onkeyup = possiblyAddRow;
-      detail_input.onchange = possiblyAddRow;
-      detail_cell.appendChild(detail_input);
-
-    row.appendChild(detail_cell);
-
-    tablebody.appendChild(row);
-
-    rownum++;
-
-  }
-
-</SCRIPT>
-
 </BODY>
 </HTML>
 <%init>
@@ -111,6 +67,21 @@ my $part_pkg = $quotation_pkg->part_pkg;
 
 my @details = $quotation_pkg->details;
 
+my $copy_on_order = 0;
+if (@details) {
+
+  # currently, they should either all have this flag, or none
+  # but just in case, erring on the side of not copying to invoice 
+  #   unless every existing detail has copy_on_order
+  # (anyway, user has to submit change, this is just for autofill)
+
+  my @quotation_pkg_detail = $quotation_pkg->quotation_pkg_detail;
+  my @copy_on_order = grep { $_->copy_on_order } @quotation_pkg_detail;
+  $copy_on_order = 1 if @copy_on_order;
+  my @no_copy_on_order = grep { !$_->copy_on_order } @quotation_pkg_detail;
+  $copy_on_order = 0 if @no_copy_on_order;  
+}
+
 my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). 'Quotation Details';
 
 </%init>