6 <div id="ui-tabs-basic-data">
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>
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',
25 style='width: 300px') %]</td>
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',
36 style='width: 300px') %]</td>
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>
45 <th align="right">[% 'Shipping Point' | $T8 %]</th>
46 <td>[% L.input_tag('order.shippingpoint', SELF.order.shippingpoint, style='width: 300px') %]</td>
50 <th align="right">[% 'Ship via' | $T8 %]</th>
51 <td>[% L.input_tag('order.shipvia', SELF.order.shipvia, style='width: 300px') %]</td>
55 <th align="right">[% 'Transaction description' | $T8 %]</th>
56 <td>[% L.input_tag('order.transaction_description', SELF.order.transaction_description, style='width: 300px') %]</td>
60 <th align="right">[% 'Project Number' | $T8 %]</th>
61 <td>[% L.project_picker('order.globalproject_id', SELF.order.globalproject_id, style='width: 300px') %]</td>
71 <td colspan="2" align="center">
72 [%- IF SELF.order.closed %] [% 'Closed' | $T8 %] [%- ELSE %] [% 'Open' | $T8 %] [%- END %]
77 <th align="right">[% 'Employee' | $T8 %]</th>
78 <td>[% L.select_tag('order.employee_id',
80 default=(SELF.order.employee_id ? SELF.order.employee_id : SELF.current_employee_id),
81 title_key='safe_name') %]</td>
84 [% IF SELF.cv == 'customer' %]
86 <th align="right">[% 'Salesman' | $T8 %]</th>
87 <td>[% L.select_tag('order.salesman_id',
89 default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
90 title_key='safe_name') %]</td>
95 <th width="70%" align="right" nowrap>[% 'Order Number' | $T8 %]</th>
96 <td>[% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]</td>
100 <th width="70%" align="right" nowrap>[% 'Quotation Number' | $T8 %]</th>
101 <td>[% L.input_tag('order.quonumber', SELF.order.quonumber, size = 11) %]</td>
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>
110 <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
111 <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
115 <th width="70%" align="right" nowrap>[% 'Insert Date' | $T8 %]</th>
116 <td>[% SELF.order.itime_as_date %]</td>
125 [%- PROCESS order/tabs/_item_input.html %]
127 [% L.button_tag('setup_multi_items_dialog()', LxERP.t8('Add multiple parts')) %]</td>
133 <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
134 <table id="row_table_id" width="100%">
136 <tr class="listheading">
137 <th class="listheading" style='display:none'></th>
138 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
139 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
140 <th class="listheading" nowrap width="15">[%- 'Partnumber' | $T8 %] </th>
141 <th class="listheading" nowrap >[%- 'Description' | $T8 %] </th>
142 <th class="listheading" nowrap width="5" >[%- 'Qty' | $T8 %] </th>
143 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
144 <th class="listheading" nowrap width="5" >[%- 'Unit' | $T8 %] </th>
145 <th class="listheading" nowrap width="5" >[%- 'Price Source' | $T8 %] </th>
146 <th class="listheading" nowrap width="15">[%- 'Price' | $T8 %] </th>
147 <th class="listheading" nowrap width="5" >[%- 'Discount' | $T8 %] </th>
148 <th class="listheading" nowrap width="10">[%- 'Extended' | $T8 %] </th>
152 [%- FOREACH item = SELF.order.items_sorted %]
153 [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id %]
166 <td colspan="100%" width="100%">
172 <th align="left">[% 'Notes' | $T8 %]</th>
173 <th align="left">[% 'Internal Notes' | $T8 %]</th>
177 [% L.textarea_tag('order.notes', SELF.order.notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
180 [% L.textarea_tag('order.intnotes', SELF.order.intnotes, wrap="soft", style="width: 350px; height: 150px") %]
189 <th align="right">[% 'Payment Terms' | $T8 %]</th>
190 <td>[% L.select_tag('order.payment_id',
191 SELF.all_payment_terms,
192 default = SELF.order.payment_id,
194 title_key = 'description',
195 style = 'width: 250px') %]</td>
198 <th align="right">[% 'Delivery Terms' | $T8 %]</th>
199 <td>[% L.select_tag('order.delivery_term_id',
200 SELF.all_delivery_terms,
201 default = SELF.order.delivery_term_id,
203 title_key = 'description',
204 style = 'width: 250px') %]</td>
211 <tr id="taxincluded_row_id" [%- IF !SELF.taxes.size %]style="display:none"[%- END %]>
212 <td align=right colspan="2">
213 <label for="order.taxincluded"><b>[% 'Tax Included' | $T8 %]</b></label>
214 [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %]
218 <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
219 <th align="right">[%- 'Subtotal' | $T8 %]</th>
221 [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
224 [%- FOREACH tax = SELF.taxes %]
225 [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %]
227 <tr id="amount_row_id">
228 <th align="right">[%- 'Total' | $T8 %]</th>
230 [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
246 [% L.sortable_element('#row_table_id') %]
248 <script type='text/javascript'>
249 function reload_cv_dependend_selections() {
250 var data = $('#order_form').serialize();
251 data += '&action=Order/customer_vendor_changed';
253 $.post("controller.pl", data, kivi.eval_json_result);
256 function add_item() {
257 if ($('#add_item_parts_id').val() == '') return;
258 if (!check_cv()) return;
260 var data = $('#order_form').serialize();
261 data += '&action=Order/add_item';
262 data += '&type=' + $('#type').val();
264 $.post("controller.pl", data, kivi.eval_json_result);
267 function setup_multi_items_dialog() {
268 if (!check_cv()) return;
269 var data = $('#order_form').serialize();
270 data += '&action=Order/show_multi_items_dialog';
272 $.post("controller.pl", data, kivi.eval_json_result);
275 var multi_items_dialog;
277 function show_multi_items_dialog(html, title) {
278 var id = 'jq_multi_items_dialog';
279 var dialog_params = {
284 close: function(event, ui) {
285 multi_items_dialog.remove();
289 $('#' + id).remove();
291 multi_items_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
292 multi_items_dialog.attr('title', title);
293 multi_items_dialog.html(html);
294 multi_items_dialog.dialog(dialog_params);
296 $('.cancel').click(close_multi_items_dialog);
301 var close_multi_items_dialog = function() {
302 multi_items_dialog.dialog('close');
305 function delete_order_item_row(clicked) {
306 var row = $(clicked).parents("tbody").first();
309 recalc_amounts_and_taxes();
312 function price_chooser_item_row(clicked) {
313 var row = $(clicked).parents("tbody").first();
314 var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
316 var data = $('#order_form').serialize();
317 data += '&action=Order/price_popup';
318 data += '&item_id=' + item_id_dom.val();
320 $.post("controller.pl", data, kivi.eval_json_result);
323 function update_price_source(item_id, source, descr, price_str) {
324 var row = $('#item_' + item_id).parents("tbody").first();
325 var source_elt = $(row).find('[name="order.orderitems[].active_price_source"]');
326 var button_elt = $(row).find('[name="price_chooser_button"]');
328 button_elt.val(button_elt.val().replace(/.*\|/, descr + " |"));
329 source_elt.val(source);
331 var editable_div_elt = $(row).find('[name="editable_price"]');
332 var not_editable_div_elt = $(row).find('[name="not_editable_price"]');
333 if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
335 $(editable_div_elt).show();
336 $(not_editable_div_elt).hide();
337 $(editable_div_elt).find(':input').prop("disabled", false);
338 $(not_editable_div_elt).find(':input').prop("disabled", true);
341 $(editable_div_elt).hide();
342 $(not_editable_div_elt).show();
343 $(editable_div_elt).find(':input').prop("disabled", true);
344 $(not_editable_div_elt).find(':input').prop("disabled", false);
348 var price_elt = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
349 var html_elt = $(row).find('[name="sellprice_text"]');
350 price_elt.val(price_str);
351 html_elt.html(price_str);
352 recalc_amounts_and_taxes();
355 kivi.io.close_dialog();
358 function update_discount_source(item_id, source, descr, discount_str) {
359 var row = $('#item_' + item_id).parents("tbody").first();
360 var source_elt = $(row).find('[name="order.orderitems[].active_discount_source"]');
361 var button_elt = $(row).find('[name="price_chooser_button"]');
363 button_elt.val(button_elt.val().replace(/\|.*/, "| " + descr));
364 source_elt.val(source);
366 var editable_div_elt = $(row).find('[name="editable_discount"]');
367 var not_editable_div_elt = $(row).find('[name="not_editable_discount"]');
368 if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
370 $(editable_div_elt).show();
371 $(not_editable_div_elt).hide();
372 $(editable_div_elt).find(':input').prop("disabled", false);
373 $(not_editable_div_elt).find(':input').prop("disabled", true);
376 $(editable_div_elt).hide();
377 $(not_editable_div_elt).show();
378 $(editable_div_elt).find(':input').prop("disabled", true);
379 $(not_editable_div_elt).find(':input').prop("disabled", false);
383 var discount_elt = $(row).find('[name="order.orderitems[].discount_as_percent"]');
384 var html_elt = $(row).find('[name="discount_text"]');
385 discount_elt.val(discount_str);
386 html_elt.html(discount_str);
387 recalc_amounts_and_taxes();
390 kivi.io.close_dialog();
393 function reformat_number(event) {
394 $(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2));
397 function recalc_amounts_and_taxes() {
398 var data = $('#order_form').serialize();
399 data += '&action=Order/recalc_amounts_and_taxes';
400 data += '&type=' + $('#type').val();
402 $.post("controller.pl", data, kivi.eval_json_result);
405 function redisplay_linetotals(data) {
406 $('.row_entry [name="linetotal"]').each(function(idx, elt) {
407 $(elt).html(data[idx]);
411 function row_table_scroll_down() {
412 $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
415 function row_set_keyboard_events_by_id(item_id) {
416 var row = $('#item_' + item_id).parents("tbody").first();
418 row_set_keyboard_events(row);
421 function row_set_keyboard_events(rows) {
422 $(rows).keydown(function(event) {
423 if(event.keyCode == 40 && event.shiftKey == true) {
425 event.preventDefault();
426 var row = $(event.target).parents(".row_entry").first();
427 $(row).children().not(':first').show();
430 if(event.keyCode == 38 && event.shiftKey == true) {
432 event.preventDefault();
433 var row = $(event.target).parents(".row_entry").first();
434 $(row).children().not(':first').hide();
439 $(rows).dblclick(function(event) {
440 event.preventDefault();
441 var row = $(event.target).parents(".row_entry").first();
442 $(row).children().not(':first').toggle();
449 function show_email_dialog(html) {
450 var id = 'jqueryui_popup_dialog';
451 var dialog_params = {
456 close: function(event, ui) {
457 email_dialog.remove();
461 $('#' + id).remove();
463 email_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
464 email_dialog.html(html);
465 email_dialog.dialog(dialog_params);
467 $('.cancel').click(close_email_dialog);
472 close_email_dialog = function() {
473 email_dialog.dialog("close");
478 $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
479 [%- IF SELF.cv == 'customer' %]
480 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
482 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) });
484 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
485 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_unit').val(o.unit) });
486 $('.add_item_input').keydown(function(event) {
487 if(event.keyCode == 13) {
488 event.preventDefault();
493 row_set_keyboard_events($('.row_entry'));
494 $('.recalc').change(recalc_amounts_and_taxes);
495 $('.reformat_number').change(reformat_number);