Auftrags-Controller: Abteilungen
[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', class='recalc') %]</td>
42           </tr>
43
44 [%- IF SELF.all_departments.size %]
45           <tr>
46             <th align="right">[% 'Department' | $T8 %]</th>
47             <td>
48               [% L.select_tag('order.department_id', SELF.all_departments, default=SELF.order.department_id, title_key='description', with_empty=1, style='width:300px') %]
49             </td>
50           </tr>
51 [%- END %]
52
53           <tr>
54             <th align="right">[% 'Shipping Point' | $T8 %]</th>
55             <td>[% L.input_tag('order.shippingpoint', SELF.order.shippingpoint, style='width: 300px') %]</td>
56           </tr>
57
58           <tr>
59             <th align="right">[% 'Ship via' | $T8 %]</th>
60             <td>[% L.input_tag('order.shipvia', SELF.order.shipvia, style='width: 300px') %]</td>
61           </tr>
62
63           <tr>
64             <th align="right">[% 'Transaction description' | $T8 %]</th>
65             <td>[% L.input_tag('order.transaction_description', SELF.order.transaction_description, style='width: 300px') %]</td>
66           </tr>
67
68           <tr>
69             <th align="right">[% 'Project Number' | $T8 %]</th>
70             <td>[% L.project_picker('order.globalproject_id', SELF.order.globalproject_id, style='width: 300px') %]</td>
71           </tr>
72
73         </table>
74       </td>
75
76       <td align="right">
77         <table>
78
79           <tr>
80             <td colspan="2" align="center">
81               [%- IF SELF.order.id %]
82                 <label for="order.delivered">[% 'Delivery Order(s) for full qty created' | $T8 %]</label>
83                 [% L.yes_no_tag('order.delivered', SELF.order.delivered) %]
84                 <label for="order.closed">[% 'Closed' | $T8 %]</label>
85                 [% L.yes_no_tag('order.closed', SELF.order.closed) %]
86               [%- END %]
87             </td>
88           </tr>
89
90           <tr>
91             <th align="right">[% 'Employee' | $T8 %]</th>
92             <td>[% L.select_tag('order.employee_id',
93               SELF.all_employees,
94               default=(SELF.order.employee_id ? SELF.order.employee_id : SELF.current_employee_id),
95               title_key='safe_name') %]</td>
96           </tr>
97
98           [% IF SELF.cv == 'customer' %]
99           <tr>
100             <th align="right">[% 'Salesman' | $T8 %]</th>
101             <td>[% L.select_tag('order.salesman_id',
102               SELF.all_salesmen,
103               default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
104               title_key='safe_name') %]</td>
105           </tr>
106           [% END %]
107
108           <tr>
109             <th width="70%" align="right" nowrap>[% 'Order Number' | $T8 %]</th>
110             <td>[% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]</td>
111           </tr>
112
113           <tr>
114             <th width="70%" align="right" nowrap>[% 'Quotation Number' | $T8 %]</th>
115             <td>[% L.input_tag('order.quonumber', SELF.order.quonumber, size = 11) %]</td>
116           </tr>
117
118           <tr>
119             <th width="70%" align="right" nowrap>[% 'Customer Order Number' | $T8 %]</th>
120             <td>[% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]</td>
121           </tr>
122
123           <tr>
124             <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
125             <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
126           </tr>
127
128           <tr>
129             <th width="70%" align="right" nowrap>[% 'Reqdate' | $T8 %]</th>
130             <td>[% L.date_tag('order.reqdate', SELF.order.reqdate) %]</td>
131           </tr>
132
133           <tr>
134             <th width="70%" align="right" nowrap>[% 'Insert Date' | $T8 %]</th>
135             <td>[% SELF.order.itime_as_date %]</td>
136           </tr>
137
138         </table>
139
140       </td>
141     </tr>
142   </table>
143
144   [%- PROCESS order/tabs/_item_input.html %]
145
146   <table width="100%">
147     <tr>
148       <td>
149
150         <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
151           <table id="row_table_id" width="100%">
152             <thead>
153               <tr class="listheading">
154                 <th class="listheading" style='display:none'></th>
155                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
156                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
157                 <th class="listheading" nowrap width="15">[%- 'Partnumber'   | $T8 %] </th>
158                 <th class="listheading" nowrap           >[%- 'Description'  | $T8 %] </th>
159                 <th class="listheading" nowrap width="5" >[%- 'Qty'          | $T8 %] </th>
160                 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
161                 <th class="listheading" nowrap width="5" >[%- 'Unit'         | $T8 %] </th>
162                 <th class="listheading" nowrap width="5" >[%- 'Price Source' | $T8 %] </th>
163                 <th class="listheading" nowrap width="15">[%- 'Price'        | $T8 %] </th>
164                 <th class="listheading" nowrap width="5" >[%- 'Discount'     | $T8 %] </th>
165                 <th class="listheading" nowrap width="10">[%- 'Extended'     | $T8 %] </th>
166               </tr>
167             </thead>
168
169             [%- FOREACH item = SELF.order.items_sorted %]
170               [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id %]
171             [%- END %]
172
173           </table>
174         </div>
175
176       </td>
177     </tr>
178
179     <tr>
180     </tr>
181
182     <tr>
183       <td colspan="100%" width="100%">
184         <table width="100%">
185           <tr>
186             <td>
187               <table>
188                 <tr>
189                   <th align="left">[% 'Notes' | $T8 %]</th>
190                   <th align="left">[% 'Internal Notes' | $T8 %]</th>
191                 </tr>
192                 <tr valign="top">
193                   <td>
194                     [% L.textarea_tag('order.notes', SELF.order.notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
195                   </td>
196                   <td>
197                     [% L.textarea_tag('order.intnotes', SELF.order.intnotes, wrap="soft", style="width: 350px; height: 150px") %]
198                   </td>
199                 </tr>
200               </table>
201             </td>
202
203             <td>
204               <table>
205                 <tr>
206                   <th align="right">[% 'Payment Terms' | $T8 %]</th>
207                   <td>[% L.select_tag('order.payment_id',
208                                       SELF.all_payment_terms,
209                                       default = SELF.order.payment_id,
210                                       with_empty = 1,
211                                       title_key = 'description',
212                                       style = 'width: 250px') %]</td>
213                 </tr>
214                 <tr>
215                   <th align="right">[% 'Delivery Terms' | $T8 %]</th>
216                   <td>[% L.select_tag('order.delivery_term_id',
217                                       SELF.all_delivery_terms,
218                                       default = SELF.order.delivery_term_id,
219                                       with_empty = 1,
220                                       title_key = 'description',
221                                       style = 'width: 250px') %]</td>
222                 </tr>
223               </table>
224             </td>
225
226             <td align="right">
227               <table>
228                 <tr id="taxincluded_row_id" [%- IF !SELF.taxes.size %]style="display:none"[%- END %]>
229                   <td align=right colspan="2">
230                     <label for="order.taxincluded"><b>[% 'Tax Included' | $T8 %]</b></label>
231                     [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %]
232                   </td>
233                 </tr>
234
235                 <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
236                   <th align="right">[%- 'Subtotal' | $T8 %]</th>
237                   <td align="right">
238                     [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
239                   </td>
240                 </tr>
241                 [%- FOREACH tax = SELF.taxes %]
242                   [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %]
243                 [%- END %]
244                 <tr id="amount_row_id">
245                   <th align="right">[%- 'Total' | $T8 %]</th>
246                   <td align="right">
247                     [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
248                   </td>
249                 </tr>
250               </table>
251             </td>
252
253           </tr>
254         </table>
255       </td>
256     </tr>
257
258   </table>
259
260 </div>
261
262
263 [% L.sortable_element('#row_table_id') %]
264
265 <script type='text/javascript'>
266 function reload_cv_dependend_selections() {
267   var data = $('#order_form').serialize();
268   data += '&action=Order/customer_vendor_changed';
269
270   $.post("controller.pl", data, kivi.eval_json_result);
271 }
272
273 function add_item() {
274   if ($('#add_item_parts_id').val() == '') return;
275   if (!check_cv()) return;
276
277   var data = $('#order_form').serialize();
278   data += '&action=Order/add_item';
279
280   $.post("controller.pl", data, kivi.eval_json_result);
281 }
282
283 function delete_order_item_row(clicked) {
284   var row = $(clicked).parents("tbody").first();
285   $(row).remove();
286
287   recalc_amounts_and_taxes();
288 }
289
290 function price_chooser_item_row(clicked) {
291   var row = $(clicked).parents("tbody").first();
292   var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
293
294   var data = $('#order_form').serialize();
295   data += '&action=Order/price_popup';
296   data += '&item_id=' + item_id_dom.val();
297
298   $.post("controller.pl", data, kivi.eval_json_result);
299 }
300
301 function update_price_source(item_id, source, descr, price_str) {
302   var row = $('#item_' + item_id).parents("tbody").first();
303   var source_elt = $(row).find('[name="order.orderitems[].active_price_source"]');
304   var button_elt = $(row).find('[name="price_chooser_button"]');
305
306   button_elt.val(button_elt.val().replace(/.*\|/, descr + " |"));
307   source_elt.val(source);
308
309   var editable_div_elt = $(row).find('[name="editable_price"]');
310   var not_editable_div_elt = $(row).find('[name="not_editable_price"]');
311   if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
312     // editable
313     $(editable_div_elt).show();
314     $(not_editable_div_elt).hide();
315     $(editable_div_elt).find(':input').prop("disabled", false);
316     $(not_editable_div_elt).find(':input').prop("disabled", true);
317   } else {
318     // not editable
319     $(editable_div_elt).hide();
320     $(not_editable_div_elt).show();
321     $(editable_div_elt).find(':input').prop("disabled", true);
322     $(not_editable_div_elt).find(':input').prop("disabled", false);
323   }
324
325   if (price_str) {
326     var price_elt = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
327     var html_elt  = $(row).find('[name="sellprice_text"]');
328     price_elt.val(price_str);
329     html_elt.html(price_str);
330     recalc_amounts_and_taxes();
331   }
332
333   kivi.io.close_dialog();
334 }
335
336 function update_discount_source(item_id, source, descr, discount_str) {
337   var row = $('#item_' + item_id).parents("tbody").first();
338   var source_elt = $(row).find('[name="order.orderitems[].active_discount_source"]');
339   var button_elt = $(row).find('[name="price_chooser_button"]');
340
341   button_elt.val(button_elt.val().replace(/\|.*/, "| " + descr));
342   source_elt.val(source);
343
344   var editable_div_elt = $(row).find('[name="editable_discount"]');
345   var not_editable_div_elt = $(row).find('[name="not_editable_discount"]');
346   if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
347     // editable
348     $(editable_div_elt).show();
349     $(not_editable_div_elt).hide();
350     $(editable_div_elt).find(':input').prop("disabled", false);
351     $(not_editable_div_elt).find(':input').prop("disabled", true);
352   } else {
353     // not editable
354     $(editable_div_elt).hide();
355     $(not_editable_div_elt).show();
356     $(editable_div_elt).find(':input').prop("disabled", true);
357     $(not_editable_div_elt).find(':input').prop("disabled", false);
358   }
359
360   if (discount_str) {
361     var discount_elt = $(row).find('[name="order.orderitems[].discount_as_percent"]');
362     var html_elt     = $(row).find('[name="discount_text"]');
363     discount_elt.val(discount_str);
364     html_elt.html(discount_str);
365     recalc_amounts_and_taxes();
366   }
367
368   kivi.io.close_dialog();
369 }
370
371 function reformat_number(event) {
372   $(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2));
373 }
374
375 function recalc_amounts_and_taxes() {
376   var data = $('#order_form').serialize();
377   data += '&action=Order/recalc_amounts_and_taxes';
378
379   $.post("controller.pl", data, kivi.eval_json_result);
380 }
381
382 function redisplay_linetotals(data) {
383   $('.row_entry [name="linetotal"]').each(function(idx, elt) {
384     $(elt).html(data[idx]);
385   });
386 }
387
388 function row_table_scroll_down() {
389   $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
390 }
391
392 function row_set_keyboard_events_by_id(item_id) {
393   var row = $('#item_' + item_id).parents("tbody").first();
394
395   row_set_keyboard_events(row);
396 }
397
398 function row_set_keyboard_events(rows) {
399   $(rows).keydown(function(event) {
400     if(event.keyCode == 40 && event.shiftKey == true) {
401       // shift arrow down
402       event.preventDefault();
403       var row = $(event.target).parents(".row_entry").first();
404       $(row).children().not(':first').show();
405       return false;
406     }
407     if(event.keyCode == 38 && event.shiftKey == true) {
408       // shift arrow up
409       event.preventDefault();
410       var row = $(event.target).parents(".row_entry").first();
411       $(row).children().not(':first').hide();
412       return false;
413     }
414   });
415
416   $(rows).dblclick(function(event) {
417       event.preventDefault();
418       var row = $(event.target).parents(".row_entry").first();
419       $(row).children().not(':first').toggle();
420       return false;
421   });
422 }
423
424 var email_dialog;
425
426 function show_email_dialog(html) {
427   var id            = 'jqueryui_popup_dialog';
428   var dialog_params = {
429     id:     id,
430     width:  800,
431     height: 500,
432     modal:  true,
433     close: function(event, ui) {
434       email_dialog.remove();
435     },
436   };
437
438   $('#' + id).remove();
439
440   email_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
441   email_dialog.html(html);
442   email_dialog.dialog(dialog_params);
443
444   $('.cancel').click(close_email_dialog);
445
446   return true;
447 }
448
449 close_email_dialog = function() {
450   email_dialog.dialog("close");
451 }
452
453
454 $(function(){
455   $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
456   [%- IF SELF.cv == 'customer' %]
457     $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
458   [%- ELSE %]
459     $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) });
460   [%- END %]
461   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
462   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_unit').val(o.unit) });
463   $('.add_item_input').keydown(function(event) {
464     if(event.keyCode == 13) {
465       event.preventDefault();
466       add_item();
467       return false;
468     }
469   });
470   row_set_keyboard_events($('.row_entry'));
471   $('.recalc').change(recalc_amounts_and_taxes);
472   $('.reformat_number').change(reformat_number);
473 });
474
475 </script>