135a89837dd58eb489e7d68c79b66bc95118d090
[kivitendo-erp.git] / templates / webpages / do / stock_in_form.html
1 [%- USE T8 %]
2 [%- USE L %]
3 [%- USE HTML %][%- USE LxERP %][%- USE JavaScript %]
4  [%- UNLESS delivered %]
5  <script type="text/javascript">
6   <!--
7       warehouses = new Array();
8       [% USE WAREHOUSES_it = Iterator(WAREHOUSES) %][% FOREACH wh = WAREHOUSES_it %]
9       warehouses[[% WAREHOUSES_it.count - 1 %]] = new Array();
10       [% USE BINS_it = Iterator(wh.BINS) %][% FOREACH bin = BINS_it %]warehouses[[% WAREHOUSES_it.count - 1 %]][[% BINS_it.count - 1 %]] = ["[% JavaScript.escape(bin.description) %]", "[% JavaScript.escape(bin.id) %]"];
11       [% END %]
12       [% END %]
13
14       function warehouse_selected(row, index, initial_bin_index) {
15         var cname = "bin_id_" + row;
16         var control = document.getElementById(cname);
17
18         for (var i = control.options.length - 1; i >= 0; i--) {
19           control.options[i] = null;
20         }
21
22         for (i = 0; i < warehouses[index].length; i++) {
23           control.options[i] = new Option(warehouses[index][i][0], warehouses[index][i][1]);
24         }
25
26         if (!initial_bin_index)
27           initial_bin_index = 0;
28         control.options[initial_bin_index].selected = true;
29       }
30
31       $(function(){
32         var bin_id_index       = 0;
33         var warehouse_id_index = 0;
34         [%- USE STOCK_INFO_it = Iterator(STOCK_INFO) %][%- FOREACH si = STOCK_INFO_it %]
35           // new si for wh [% si.warehouse_id %] bin [% si.bin_id %]
36           [%- SET warehouse_selected = '0' %]
37           [%- USE WAREHOUSES_it = Iterator(WAREHOUSES) %][%- FOREACH wh = WAREHOUSES_it %]
38             // wh [% wh.id %]
39             [% IF HTML.escape(PART_INFO.warehouse_id) == wh.id %]
40               warehouse_id_index = [% WAREHOUSES_it.count - 1%];
41             [% END %]
42             [%- USE BINS_it = Iterator(wh.BINS) %][%- FOREACH bin = BINS_it %]
43               // bin [% bin.id %]
44               [% IF HTML.escape(PART_INFO.bin_id) == bin.id %]
45                 bin_id_index = [% BINS_it.count - 1%];
46               [% END %]
47               [%- IF bin.id == si.bin_id %]
48                 warehouse_selected([% STOCK_INFO_it.count %], [% WAREHOUSES_it.count - 1 %], [% BINS_it.count - 1%]);
49                 [%- SET warehouse_selected = '1' %]
50               [%- END %]
51             [%- END %]
52           [%- END %]
53           [%- UNLESS warehouse_selected %]
54             warehouse_selected([% STOCK_INFO_it.count %], warehouse_id_index, bin_id_index);
55           [%- END %]
56         [%- END %]
57       });
58     -->
59  </script>
60  [%- END %]
61
62  <form method="post" action="do.pl" name="Form">
63
64   <div class="listtop">[% title %]</div>
65
66   [%- IF ERRORS && ERRORS.size %]
67   <p><font color="#ff0000">[% ERRORS.join('<br>') %]</font></p>
68   [%- END %]
69
70   <p>
71    <table>
72     <tr>
73      <td>[% 'Part Number' | $T8 %]</td>
74      <td>[% HTML.escape(PART_INFO.partnumber) %]</td>
75     </tr>
76     <tr>
77      <td>[% 'Description' | $T8 %]</td>
78      <td>[% HTML.escape(PART_INFO.description) %]</td>
79     </tr>
80     <tr>
81      <td>[% 'Qty according to delivery order' | $T8 %]</td>
82      <td>[% HTML.escape(do_qty) %] [% HTML.escape(do_unit) %]</td>
83     </tr>
84    </table>
85   </p>
86
87   <input type="hidden" name="nextsub"        value="set_stock_in">
88   <input type="hidden" name="update_nextsub" value="update_stock_in">
89   <input type="hidden" name="rowcount"       value="[% HTML.escape(STOCK_INFO.size) %]">
90   <input type="hidden" name="in_out"         value="in">
91   <input type="hidden" name="parts_id"       value="[% HTML.escape(parts_id) %]">
92   <input type="hidden" name="partunit"       value="[% HTML.escape(PART_INFO.unit) %]">
93   <input type="hidden" name="do_qty"         value="[% HTML.escape(do_qty) %]">
94   <input type="hidden" name="do_unit"        value="[% HTML.escape(do_unit) %]">
95   <input type="hidden" name="row"            value="[% HTML.escape(row) %]">
96
97   <p>
98    <table>
99     <tr class="listheading">
100      <th class="listheading">&nbsp;</th>
101      <th class="listheading">[% 'Warehouse' | $T8 %]</th>
102      <th class="listheading">[% 'Bin' | $T8 %]</th>
103      <th class="listheading">[% 'Charge Number' | $T8 %]</th>
104      [% IF INSTANCE_CONF.get_show_bestbefore %]
105      <th class="listheading">[% 'Best Before' | $T8 %]</th>
106      [% END %]
107      <th align="right" class="listheading">[% 'Qty' | $T8 %]</th>
108      <th align="right" class="listheading">[% 'Unit' | $T8 %]</th>
109     </tr>
110
111     [%- FOREACH row = STOCK_INFO %]
112     <tr [% IF row.stock_error %] class="tr_error"[% ELSE %]class="listrow[% loop.count % 2 %]"[% END %]>
113      <td>[% loop.count %]</td>
114
115      [%- IF delivered %]
116
117      <td>[% HTML.escape(row.warehouse_description) %]</td>
118      <td>[% HTML.escape(row.bin_description) %]</td>
119      <td>[% HTML.escape(row.chargenumber) %]</td>
120      [% IF INSTANCE_CONF.get_show_bestbefore %]
121      <td>[% HTML.escape(row.bestbefore) %]</td>
122      [% END %]
123      <td>[% HTML.escape(LxERP.format_amount(row.qty)) %]</td>
124      <td>[% HTML.escape(row.unit) %]</td>
125
126      [%- ELSE %]
127
128      <td>
129       <select name="warehouse_id_[% loop.count %]" onchange="warehouse_selected([% loop.count %], this.selectedIndex)">
130        [%- FOREACH wh = WAREHOUSES %]
131      <option value="[% HTML.escape(wh.id) %]"[% IF wh.id == row.warehouse_id %] selected[% END %] [% IF wh.id == PART_INFO.warehouse_id && STOCK_INFO.size == 1  %] selected[% END %]>[% HTML.escape(wh.description) %]</option>
132        [%- END %]
133       </select>
134      </td>
135
136      <td><select name="bin_id_[% loop.count %]" id="bin_id_[% loop.count %]"></select></td>
137      <td><input name="chargenumber_[% loop.count %]" value="[% HTML.escape(row.chargenumber) %]"></td>
138      [% IF INSTANCE_CONF.get_show_bestbefore %]
139      <td>
140        [% L.date_tag('bestbefore_'_ loop.count, row.bestbefore) %]
141      </td>
142      [% END %]
143      <td><input name="qty_[% loop.count %]" size="12" value="[% HTML.escape(LxERP.format_amount(row.qty)) %]"></td>
144
145      <td>
146       <select name="unit_[% loop.count %]">
147        [%- FOREACH unit = UNITS %]
148        <option[% IF unit.selected %] selected[% END %]>[% HTML.escape(unit.name) %]</option>
149        [%- END %]
150       </select>
151      </td>
152
153      [%- END %]
154     </tr>
155
156     [%- END %]
157    </table>
158   </p>
159
160   <hr size="3" noshade>
161
162   <p>
163    [%- IF delivered %]
164    <button type="button" class="submit" name="action" onclick="window.close()">[% 'Close Window' | $T8 %]</button>
165    [%- ELSE %]
166    <input class="submit" type="submit" name="action" value="[% 'Update' | $T8 %]">
167    <input class="submit" type="submit" name="action" value="[% 'Continue' | $T8 %]">
168    [%- END %]
169   </p>
170  </form>
171