zip email CDRs, RT#40112
[freeside.git] / httemplate / edit / quotation_pkg_detail.html
1 <% include("/elements/header-popup.html", $title, '',
2             ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
3           )
4 %>
5
6 %# <% include('/elements/error.html') %>
7
8 <FORM ACTION="process/quotation_pkg_detail.html" NAME="DetailForm" ID="DetailForm" METHOD="POST">
9
10 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
11
12 <TABLE ID="DetailTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=1 STYLE="background-color: #cccccc">
13
14   <TR>
15     <TD ALIGN="right">Package</TD>
16     <TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
17   </TR>
18
19   <TR>
20     <TD ALIGN="right">Comment</TD>
21     <TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
22   </TR>
23
24   <TR>
25     <TD></TD>
26     <TD>
27       <SELECT NAME="copy_on_order">
28         <OPTION VALUE=""<% $copy_on_order ? '' : ' SELECTED' %>>
29           <% emt('Details will only appear on quotation') %>
30         </OPTION>
31         <OPTION VALUE="Y"<% $copy_on_order ? ' SELECTED' : '' %>>
32           <% emt('Copy details to invoice when placing order') %>
33         </OPTION>
34       </SELECT>
35     </TD>
36   </TR>
37
38 % my $row = 0;
39 % for ( @details ) { 
40
41     <TR>
42       <TD ALIGN="right"><% $row ? '' : 'Detail' %></TD>
43       <TD>
44         <INPUT TYPE="text" NAME="detail<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $_ |h %>" rownum="<% $row++ %>" onkeyup="possiblyAddRow" onchange="possiblyAddrow">
45       </TD>
46     </TR>
47
48 % } 
49
50 </TABLE>
51
52 <BR>
53 <INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="<% $title %>">
54
55 </FORM>
56
57 <SCRIPT TYPE="text/javascript">
58 % # abject false laziness with edit/cust_pkg_detail.html
59
60   var rownum = <% $row %>;
61
62   function possiblyAddRow() {
63     if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
64       addRow();
65     }
66   }
67
68   function addRow() {
69
70     var table = document.getElementById('DetailTable');
71     var tablebody = table.getElementsByTagName('tbody').item(0);
72
73     var row = document.createElement('TR');
74
75     var empty_cell = document.createElement('TD');
76     if (!rownum) {
77       empty_cell.innerHTML = 'Detail:'
78       empty_cell.style.textAlign = 'right';
79     }
80     row.appendChild(empty_cell);
81
82     var detail_cell = document.createElement('TD');
83
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);
93
94     row.appendChild(detail_cell);
95
96     tablebody.appendChild(row);
97
98     rownum++;
99
100   }
101
102 </SCRIPT>
103
104 </BODY>
105 </HTML>
106 <%init>
107
108 my $curuser = $FS::CurrentUser::CurrentUser;
109
110 die "access denied"
111   unless $curuser->access_right('Generate quotation');
112
113 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum';
114 my $pkgnum = $1;
115
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,
122 });
123
124 my $part_pkg = $quotation_pkg->part_pkg;
125
126 my @details = $quotation_pkg->details;
127
128 my $copy_on_order = 0;
129 if (@details) {
130
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)
135
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;  
141 }
142
143 my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). 'Quotation Details';
144
145 </%init>