Auftrags-Controller: neue Eingabemakse für Aufträge basierend auf Controller
[kivitendo-erp.git] / templates / webpages / order / tabs / basic_data.html
1 [%- USE T8 %]
2 [%- USE HTML %]
3 [%- USE LxERP %]
4 [%- USE L %]
5
6 <div id="ui-tabs-basic-data">
7   <table width="100%">
8     <tr valign="top">
9       <td>
10         <table width="100%">
11           <tr>
12             <th align="right">[% SELF.cv | $T8 %]</th>
13             [% SET cv_id = SELF.cv _ '_id' %]
14             <td>[% L.customer_vendor_picker("order.${SELF.cv}" _ '_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %]</td>
15           </tr>
16
17           <tr id='cp_row' [%- IF !SELF.order.${SELF.cv}.contacts.size %]style='display:none'[%- END %]>
18             <th align="right">[% 'Contact Person' | $T8 %]</th>
19             <td>[% L.select_tag('order.cp_id',
20                                 SELF.order.${SELF.cv}.contacts,
21                                 default=SELF.order.cp_id,
22                                 title_key='full_name_dep',
23                                 value_key='cp_id',
24                                 with_empty=1,
25                                 style='width: 300px') %]</td>
26           </tr>
27
28           <tr id='shipto_row' [%- IF !SELF.order.${SELF.cv}.shipto.size %]style='display:none'[%- END %]>
29             <th align="right">[% 'Shipping Address' | $T8 %]</th>
30             <td>[% L.select_tag('order.shipto_id',
31                                 SELF.order.${SELF.cv}.shipto,
32                                 default=SELF.order.shipto_id,
33                                 title_key='displayable_id',
34                                 value_key='shipto_id',
35                                 with_empty=1,
36                                 style='width: 300px') %]</td>
37           </tr>
38
39           <tr>
40             <th align="right">[% 'Steuersatz' | $T8 %]</th>
41             <td>[% L.select_tag('order.taxzone_id', SELF.all_taxzones, default=SELF.order.taxzone_id, title_key='description', style='width: 300px') %]</td>
42           </tr>
43
44           <tr>
45             <th align="right">[% 'Shipping Point' | $T8 %]</th>
46             <td>[% L.input_tag('order.shippingpoint', SELF.order.shippingpoint, style='width: 300px') %]</td>
47           </tr>
48
49           <tr>
50             <th align="right">[% 'Ship via' | $T8 %]</th>
51             <td>[% L.input_tag('order.shipvia', SELF.order.shipvia, style='width: 300px') %]</td>
52           </tr>
53
54           <tr>
55             <th align="right">[% 'Transaction description' | $T8 %]</th>
56             <td>[% L.input_tag('order.transaction_description', SELF.order.transaction_description, style='width: 300px') %]</td>
57           </tr>
58
59         </table>
60       </td>
61
62       <td align="right">
63         <table>
64
65           <tr>
66             <td colspan="2" align="center">
67               [%- IF SELF.order.id %]
68                 <label for="order.delivered">[% 'Delivery Order(s) for full qty created' | $T8 %]</label>
69                 [% L.yes_no_tag('order.delivered', SELF.order.delivered) %]
70                 <label for="order.closed">[% 'Closed' | $T8 %]</label>
71                 [% L.yes_no_tag('order.closed', SELF.order.closed) %]
72               [%- END %]
73             </td>
74           </tr>
75
76           <tr>
77             <th align="right">[% 'Employee' | $T8 %]</th>
78             <td>[% L.select_tag('order.employee_id',
79               SELF.all_employees,
80               default=(SELF.order.employee_id ? SELF.order.employee_id : SELF.current_employee_id),
81               title_key='safe_name') %]</td>
82           </tr>
83
84           [% IF SELF.cv == 'customer' %]
85           <tr>
86             <th align="right">[% 'Salesman' | $T8 %]</th>
87             <td>[% L.select_tag('order.salesman_id',
88               SELF.all_salesmen,
89               default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
90               title_key='safe_name') %]</td>
91           </tr>
92           [% END %]
93
94           <tr>
95             <th width="70%" align="right" nowrap>[% 'Order Number' | $T8 %]</th>
96             <td>[% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]</td>
97           </tr>
98
99           <tr>
100             <th width="70%" align="right" nowrap>[% 'Customer Order Number' | $T8 %]</th>
101             <td>[% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]</td>
102           </tr>
103
104           <tr>
105             <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
106             <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
107           </tr>
108
109           <tr>
110             <th width="70%" align="right" nowrap>[% 'Project Number' | $T8 %]</th>
111             <td>[%- L.select_tag('order.globalproject_id', SELF.all_projects, default=SELF.order.globalproject_id, title_key='projectnumber', with_empty = 1) %]</td>
112           </tr>
113
114         </table>
115
116       </td>
117     </tr>
118   </table>
119
120   [%- PROCESS order/tabs/_item_input.html %]
121
122   <table width="100%">
123     <tr>
124       <td>
125
126         <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
127           <table id="row_table_id" width="100%">
128             <thead>
129               <tr class="listheading">
130                 <th class="listheading" style='display:none'></th>
131                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
132                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
133                 <th class="listheading" nowrap width="15">[%- 'Partnumber'   | $T8 %] </th>
134                 <th class="listheading" nowrap           >[%- 'Description'  | $T8 %] </th>
135                 <th class="listheading" nowrap width="5" >[%- 'Qty'          | $T8 %] </th>
136                 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
137                 <th class="listheading" nowrap width="5" >[%- 'Unit'         | $T8 %] </th>
138                 <th class="listheading" nowrap width="15">[%- 'Price'        | $T8 %] </th>
139                 <th class="listheading" nowrap width="5" >[%- 'Discount'     | $T8 %] </th>
140                 <th class="listheading" nowrap width="10">[%- 'Extended'     | $T8 %] </th>
141               </tr>
142             </thead>
143
144             [%- FOREACH item = SELF.order.items_sorted %]
145               [%- PROCESS order/tabs/_row.html ITEM=item %]
146             [%- END %]
147
148           </table>
149         </div>
150
151       </td>
152     </tr>
153
154     <tr>
155     </tr>
156
157     <tr>
158       <td align="right">
159         <table>
160           [%- IF NOT taxincluded %]
161           <tr>
162             <th align="right">[%- 'Subtotal' | $T8 %]</th>
163             <td align="right">
164               [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
165             </td>
166           </tr>
167           [%- END %]
168           [%- FOREACH tax = SELF.taxes %]
169             [%- PROCESS order/tabs/_tax_row.html TAX=tax %]
170           [%- END %]
171           <tr id="amount_row_id">
172             <th align="right">[%- 'Total' | $T8 %]</th>
173             <td align="right">
174               <table>
175                 [%- IF NOT taxincluded %]
176                 <tr>
177                   <th align="right">[%- 'Subtotal' | $T8 %]</th>
178                   <td align="right">
179                     [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
180                   </td>
181                 </tr>
182                 [%- END %]
183                 [%- FOREACH tax = SELF.taxes %]
184                   [%- PROCESS order/tabs/_tax_row.html TAX=tax %]
185                 [%- END %]
186                 <tr id="amount_row_id">
187                   <th align="right">[%- 'Total' | $T8 %]</th>
188                   <td align="right">
189                     [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
190                   </td>
191                 </tr>
192               </table>
193             </td>
194
195           </tr>
196         </table>
197       </td>
198     </tr>
199
200   </table>
201
202 </div>
203
204
205 [% L.sortable_element('#row_table_id') %]
206
207 <script type='text/javascript'>
208 function reload_cv_dependend_selections() {
209   $.post("controller.pl", { 'action': 'Order/customer_vendor_changed',
210                             'cv_id':  function(){ return $('#order_[%- cv_id%]').val() },
211                             'type':   function(){ return $('#type').val() },
212                           }, kivi.eval_json_result);
213 }
214
215 function add_item() {
216   if ($('#add_item_parts_id').val() == '') return;
217   if (!check_cv()) return;
218
219   var data = $('#order_form').serialize();
220   data += '&action=Order/add_item';
221
222   $.post("controller.pl", data, kivi.eval_json_result);
223 }
224
225 function delete_order_item_row(clicked) {
226   var row = $(clicked).parents("tbody").first();
227   $(row).remove();
228
229   recalc_amounts_and_taxes();
230 }
231
232 function recalc_amounts_and_taxes() {
233   var data = $('#order_form').serialize();
234   data += '&action=Order/recalc_amounts_and_taxes';
235
236   $.post("controller.pl", data, kivi.eval_json_result);
237 }
238
239 function redisplay_linetotals(data) {
240   $('.row_entry [name="linetotal"]').each(function(idx, elt) {
241     $(elt).html(data[idx]);
242   });
243 }
244
245 function row_table_scroll_down() {
246   $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
247 }
248
249 function row_set_keyboard_events_by_id(item_id) {
250   var row = $('#item_' + item_id).parents("tbody").first();
251
252   row_set_keyboard_events(row);
253 }
254
255 function row_set_keyboard_events(rows) {
256   $(rows).keydown(function(event) {
257     if(event.keyCode == 40 && event.shiftKey == true) {
258       // shift arrow down
259       event.preventDefault();
260       var row = $(event.target).parents(".row_entry").first();
261       $(row).children().not(':first').show();
262       return false;
263     }
264     if(event.keyCode == 38 && event.shiftKey == true) {
265       // shift arrow up
266       event.preventDefault();
267       var row = $(event.target).parents(".row_entry").first();
268       $(row).children().not(':first').hide();
269       return false;
270     }
271   });
272
273   $(rows).dblclick(function(event) {
274       event.preventDefault();
275       var row = $(event.target).parents(".row_entry").first();
276       $(row).children().not(':first').toggle();
277       return false;
278   });
279 }
280
281 $(function(){
282   $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
283   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
284   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
285   $('.add_item_input').keydown(function(event) {
286     if(event.keyCode == 13) {
287       event.preventDefault();
288       add_item();
289       return false;
290     }
291   });
292   row_set_keyboard_events($('.row_entry'));
293   $('.recalc').change(recalc_amounts_and_taxes);
294 });
295
296 </script>