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