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>[% 'Reqdate' | $T8 %]</th>
116 <td>[% L.date_tag('order.reqdate', SELF.order.reqdate) %]</td>
120 <th width="70%" align="right" nowrap>[% 'Insert Date' | $T8 %]</th>
121 <td>[% SELF.order.itime_as_date %]</td>
130 [%- PROCESS order/tabs/_item_input.html %]
132 [% L.button_tag('setup_multi_items_dialog()', LxERP.t8('Add multiple parts')) %]</td>
138 <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
139 <table id="row_table_id" width="100%">
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>
157 [%- FOREACH item = SELF.order.items_sorted %]
158 [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id %]
171 <td colspan="100%" width="100%">
177 <th align="left">[% 'Notes' | $T8 %]</th>
178 <th align="left">[% 'Internal Notes' | $T8 %]</th>
182 [% L.textarea_tag('order.notes', SELF.order.notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
185 [% L.textarea_tag('order.intnotes', SELF.order.intnotes, wrap="soft", style="width: 350px; height: 150px") %]
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,
199 title_key = 'description',
200 style = 'width: 250px') %]</td>
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,
208 title_key = 'description',
209 style = 'width: 250px') %]</td>
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') %]
223 <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
224 <th align="right">[%- 'Subtotal' | $T8 %]</th>
226 [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
229 [%- FOREACH tax = SELF.taxes %]
230 [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %]
232 <tr id="amount_row_id">
233 <th align="right">[%- 'Total' | $T8 %]</th>
235 [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
251 [% L.sortable_element('#row_table_id') %]
253 <script type='text/javascript'>
254 function reload_cv_dependend_selections() {
255 var data = $('#order_form').serialize();
256 data += '&action=Order/customer_vendor_changed';
258 $.post("controller.pl", data, kivi.eval_json_result);
261 function add_item() {
262 if ($('#add_item_parts_id').val() == '') return;
263 if (!check_cv()) return;
265 var data = $('#order_form').serialize();
266 data += '&action=Order/add_item';
267 data += '&type=' + $('#type').val();
269 $.post("controller.pl", data, kivi.eval_json_result);
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';
277 $.post("controller.pl", data, kivi.eval_json_result);
280 var multi_items_dialog;
282 function show_multi_items_dialog(html, title) {
283 var id = 'jq_multi_items_dialog';
284 var dialog_params = {
289 close: function(event, ui) {
290 multi_items_dialog.remove();
294 $('#' + id).remove();
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);
301 $('.cancel').click(close_multi_items_dialog);
306 var close_multi_items_dialog = function() {
307 multi_items_dialog.dialog('close');
310 function delete_order_item_row(clicked) {
311 var row = $(clicked).parents("tbody").first();
314 recalc_amounts_and_taxes();
317 function price_chooser_item_row(clicked) {
318 var row = $(clicked).parents("tbody").first();
319 var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
321 var data = $('#order_form').serialize();
322 data += '&action=Order/price_popup';
323 data += '&item_id=' + item_id_dom.val();
325 $.post("controller.pl", data, kivi.eval_json_result);
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"]');
333 button_elt.val(button_elt.val().replace(/.*\|/, descr + " |"));
334 source_elt.val(source);
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 == '') {
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);
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);
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();
360 kivi.io.close_dialog();
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"]');
368 button_elt.val(button_elt.val().replace(/\|.*/, "| " + descr));
369 source_elt.val(source);
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 == '') {
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);
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);
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();
395 kivi.io.close_dialog();
398 function reformat_number(event) {
399 $(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2));
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();
407 $.post("controller.pl", data, kivi.eval_json_result);
410 function redisplay_linetotals(data) {
411 $('.row_entry [name="linetotal"]').each(function(idx, elt) {
412 $(elt).html(data[idx]);
416 function row_table_scroll_down() {
417 $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
420 function row_set_keyboard_events_by_id(item_id) {
421 var row = $('#item_' + item_id).parents("tbody").first();
423 row_set_keyboard_events(row);
426 function row_set_keyboard_events(rows) {
427 $(rows).keydown(function(event) {
428 if(event.keyCode == 40 && event.shiftKey == true) {
430 event.preventDefault();
431 var row = $(event.target).parents(".row_entry").first();
432 $(row).children().not(':first').show();
435 if(event.keyCode == 38 && event.shiftKey == true) {
437 event.preventDefault();
438 var row = $(event.target).parents(".row_entry").first();
439 $(row).children().not(':first').hide();
444 $(rows).dblclick(function(event) {
445 event.preventDefault();
446 var row = $(event.target).parents(".row_entry").first();
447 $(row).children().not(':first').toggle();
454 function show_email_dialog(html) {
455 var id = 'jqueryui_popup_dialog';
456 var dialog_params = {
461 close: function(event, ui) {
462 email_dialog.remove();
466 $('#' + id).remove();
468 email_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
469 email_dialog.html(html);
470 email_dialog.dialog(dialog_params);
472 $('.cancel').click(close_email_dialog);
477 close_email_dialog = function() {
478 email_dialog.dialog("close");
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)) });
487 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) });
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();
498 row_set_keyboard_events($('.row_entry'));
499 $('.recalc').change(recalc_amounts_and_taxes);
500 $('.reformat_number').change(reformat_number);