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>
44 [%- IF SELF.all_departments.size %]
46 <th align="right">[% 'Department' | $T8 %]</th>
48 [% L.select_tag('order.department_id', SELF.all_departments, default=SELF.order.department_id, title_key='description', with_empty=1, style='width:300px') %]
54 <th align="right">[% 'Shipping Point' | $T8 %]</th>
55 <td>[% L.input_tag('order.shippingpoint', SELF.order.shippingpoint, style='width: 300px') %]</td>
59 <th align="right">[% 'Ship via' | $T8 %]</th>
60 <td>[% L.input_tag('order.shipvia', SELF.order.shipvia, style='width: 300px') %]</td>
64 <th align="right">[% 'Transaction description' | $T8 %]</th>
65 <td>[% L.input_tag('order.transaction_description', SELF.order.transaction_description, style='width: 300px') %]</td>
69 <th align="right">[% 'Project Number' | $T8 %]</th>
70 <td>[% L.project_picker('order.globalproject_id', SELF.order.globalproject_id, style='width: 300px') %]</td>
80 <td colspan="2" align="center">
81 [%- IF SELF.order.closed %] [% 'Closed' | $T8 %] [%- ELSE %] [% 'Open' | $T8 %] [%- END %]
86 <th align="right">[% 'Employee' | $T8 %]</th>
87 <td>[% L.select_tag('order.employee_id',
89 default=(SELF.order.employee_id ? SELF.order.employee_id : SELF.current_employee_id),
90 title_key='safe_name') %]</td>
93 [% IF SELF.cv == 'customer' %]
95 <th align="right">[% 'Salesman' | $T8 %]</th>
96 <td>[% L.select_tag('order.salesman_id',
98 default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
99 title_key='safe_name') %]</td>
104 <th width="70%" align="right" nowrap>[% 'Order Number' | $T8 %]</th>
105 <td>[% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]</td>
109 <th width="70%" align="right" nowrap>[% 'Quotation Number' | $T8 %]</th>
110 <td>[% L.input_tag('order.quonumber', SELF.order.quonumber, size = 11) %]</td>
114 <th width="70%" align="right" nowrap>[% 'Customer Order Number' | $T8 %]</th>
115 <td>[% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]</td>
119 <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
120 <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
124 <th width="70%" align="right" nowrap>[% 'Reqdate' | $T8 %]</th>
125 <td>[% L.date_tag('order.reqdate', SELF.order.reqdate) %]</td>
129 <th width="70%" align="right" nowrap>[% 'Insert Date' | $T8 %]</th>
130 <td>[% SELF.order.itime_as_date %]</td>
139 [%- PROCESS order/tabs/_item_input.html %]
141 [% L.button_tag('show_multi_items_dialog()', LxERP.t8('Add multiple items')) %]</td>
147 <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
148 <table id="row_table_id" width="100%">
150 <tr class="listheading">
151 <th class="listheading" style='display:none'></th>
152 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
153 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
154 <th class="listheading" nowrap width="15">[%- 'Partnumber' | $T8 %] </th>
155 <th class="listheading" nowrap >[%- 'Description' | $T8 %] </th>
156 <th class="listheading" nowrap width="5" >[%- 'Qty' | $T8 %] </th>
157 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
158 <th class="listheading" nowrap width="5" >[%- 'Unit' | $T8 %] </th>
159 <th class="listheading" nowrap width="5" >[%- 'Price Source' | $T8 %] </th>
160 <th class="listheading" nowrap width="15">[%- 'Price' | $T8 %] </th>
161 <th class="listheading" nowrap width="5" >[%- 'Discount' | $T8 %] </th>
162 <th class="listheading" nowrap width="10">[%- 'Extended' | $T8 %] </th>
166 [%- FOREACH item = SELF.order.items_sorted %]
167 [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id %]
180 <td colspan="100%" width="100%">
186 <th align="left">[% 'Notes' | $T8 %]</th>
187 <th align="left">[% 'Internal Notes' | $T8 %]</th>
191 [% L.textarea_tag('order.notes', SELF.order.notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
194 [% L.textarea_tag('order.intnotes', SELF.order.intnotes, wrap="soft", style="width: 350px; height: 150px") %]
203 <th align="right">[% 'Payment Terms' | $T8 %]</th>
204 <td>[% L.select_tag('order.payment_id',
205 SELF.all_payment_terms,
206 default = SELF.order.payment_id,
208 title_key = 'description',
209 style = 'width: 250px') %]</td>
212 <th align="right">[% 'Delivery Terms' | $T8 %]</th>
213 <td>[% L.select_tag('order.delivery_term_id',
214 SELF.all_delivery_terms,
215 default = SELF.order.delivery_term_id,
217 title_key = 'description',
218 style = 'width: 250px') %]</td>
225 <tr id="taxincluded_row_id" [%- IF !SELF.taxes.size %]style="display:none"[%- END %]>
226 <td align=right colspan="2">
227 <label for="order.taxincluded"><b>[% 'Tax Included' | $T8 %]</b></label>
228 [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %]
232 <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
233 <th align="right">[%- 'Subtotal' | $T8 %]</th>
235 [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
238 [%- FOREACH tax = SELF.taxes %]
239 [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %]
241 <tr id="amount_row_id">
242 <th align="right">[%- 'Total' | $T8 %]</th>
244 [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
260 [% L.sortable_element('#row_table_id') %]
262 <script type='text/javascript'>
263 function reload_cv_dependend_selections() {
264 var data = $('#order_form').serialize();
265 data += '&action=Order/customer_vendor_changed';
267 $.post("controller.pl", data, kivi.eval_json_result);
270 function unit_change(event) {
271 var row = $(event.target).parents("tbody").first();
272 var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
273 var sellprice_dom = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
274 var select_elt = $(row).find('[name="order.orderitems[].unit"]');
276 var oldval = $(select_elt).data('oldval');
277 $(select_elt).data('oldval', $(select_elt).val());
279 var data = $('#order_form').serialize();
280 data += '&action=Order/unit_changed';
281 data += '&item_id=' + item_id_dom.val();
282 data += '&old_unit=' + oldval;
283 data += '&sellprice_dom_id=' + sellprice_dom.attr('id');
285 $.post("controller.pl", data, kivi.eval_json_result);
288 function update_sellprice(item_id, price_str) {
289 var row = $('#item_' + item_id).parents("tbody").first();
290 var price_elt = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
291 var html_elt = $(row).find('[name="sellprice_text"]');
292 price_elt.val(price_str);
293 html_elt.html(price_str);
296 function add_item() {
297 if ($('#add_item_parts_id').val() == '') return;
298 if (!check_cv()) return;
300 var data = $('#order_form').serialize();
301 data += '&action=Order/add_item';
302 data += '&type=' + $('#type').val();
304 $.post("controller.pl", data, kivi.eval_json_result);
307 function show_multi_items_dialog() {
308 if (!check_cv()) return;
310 var data = 'type=' + $('#type').val();
311 data += 'type=' + $('#type').val();
313 url: 'controller.pl?action=Order/show_multi_items_dialog',
315 { 'type': $('#type').val(),
316 'callback': 'Order/add_multi_items',
317 'callback_data_id': 'order_form' }),
318 id: 'jq_multi_items_dialog',
320 title: kivi.t8('Add multiple items'),
328 function close_multi_items_dialog() {
329 $('#jq_multi_items_dialog').dialog('close');
332 function delete_order_item_row(clicked) {
333 var row = $(clicked).parents("tbody").first();
336 recalc_amounts_and_taxes();
339 function price_chooser_item_row(clicked) {
340 var row = $(clicked).parents("tbody").first();
341 var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
343 var data = $('#order_form').serialize();
344 data += '&action=Order/price_popup';
345 data += '&item_id=' + item_id_dom.val();
347 $.post("controller.pl", data, kivi.eval_json_result);
350 function update_price_source(item_id, source, descr, price_str) {
351 var row = $('#item_' + item_id).parents("tbody").first();
352 var source_elt = $(row).find('[name="order.orderitems[].active_price_source"]');
353 var button_elt = $(row).find('[name="price_chooser_button"]');
355 button_elt.val(button_elt.val().replace(/.*\|/, descr + " |"));
356 source_elt.val(source);
358 var editable_div_elt = $(row).find('[name="editable_price"]');
359 var not_editable_div_elt = $(row).find('[name="not_editable_price"]');
360 if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
362 $(editable_div_elt).show();
363 $(not_editable_div_elt).hide();
364 $(editable_div_elt).find(':input').prop("disabled", false);
365 $(not_editable_div_elt).find(':input').prop("disabled", true);
368 $(editable_div_elt).hide();
369 $(not_editable_div_elt).show();
370 $(editable_div_elt).find(':input').prop("disabled", true);
371 $(not_editable_div_elt).find(':input').prop("disabled", false);
375 var price_elt = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
376 var html_elt = $(row).find('[name="sellprice_text"]');
377 price_elt.val(price_str);
378 html_elt.html(price_str);
379 recalc_amounts_and_taxes();
382 kivi.io.close_dialog();
385 function update_discount_source(item_id, source, descr, discount_str) {
386 var row = $('#item_' + item_id).parents("tbody").first();
387 var source_elt = $(row).find('[name="order.orderitems[].active_discount_source"]');
388 var button_elt = $(row).find('[name="price_chooser_button"]');
390 button_elt.val(button_elt.val().replace(/\|.*/, "| " + descr));
391 source_elt.val(source);
393 var editable_div_elt = $(row).find('[name="editable_discount"]');
394 var not_editable_div_elt = $(row).find('[name="not_editable_discount"]');
395 if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
397 $(editable_div_elt).show();
398 $(not_editable_div_elt).hide();
399 $(editable_div_elt).find(':input').prop("disabled", false);
400 $(not_editable_div_elt).find(':input').prop("disabled", true);
403 $(editable_div_elt).hide();
404 $(not_editable_div_elt).show();
405 $(editable_div_elt).find(':input').prop("disabled", true);
406 $(not_editable_div_elt).find(':input').prop("disabled", false);
410 var discount_elt = $(row).find('[name="order.orderitems[].discount_as_percent"]');
411 var html_elt = $(row).find('[name="discount_text"]');
412 discount_elt.val(discount_str);
413 html_elt.html(discount_str);
414 recalc_amounts_and_taxes();
417 kivi.io.close_dialog();
420 function reformat_number(event) {
421 $(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2));
424 function recalc_amounts_and_taxes() {
425 var data = $('#order_form').serialize();
426 data += '&action=Order/recalc_amounts_and_taxes';
427 data += '&type=' + $('#type').val();
429 $.post("controller.pl", data, kivi.eval_json_result);
432 function redisplay_linetotals(data) {
433 $('.row_entry [name="linetotal"]').each(function(idx, elt) {
434 $(elt).html(data[idx]);
438 function row_table_scroll_down() {
439 $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
442 function row_set_keyboard_events_by_id(item_id) {
443 var row = $('#item_' + item_id).parents("tbody").first();
445 row_set_keyboard_events(row);
448 function row_set_keyboard_events(rows) {
449 $(rows).keydown(function(event) {
450 if(event.keyCode == 40 && event.shiftKey == true) {
452 event.preventDefault();
453 var row = $(event.target).parents(".row_entry").first();
454 $(row).children().not(':first').show();
457 if(event.keyCode == 38 && event.shiftKey == true) {
459 event.preventDefault();
460 var row = $(event.target).parents(".row_entry").first();
461 $(row).children().not(':first').hide();
466 $(rows).dblclick(function(event) {
467 event.preventDefault();
468 var row = $(event.target).parents(".row_entry").first();
469 $(row).children().not(':first').toggle();
474 function set_unit_change_with_oldval_by_id(item_id) {
475 var row = $('#item_' + item_id).parents("tbody").first();
476 var select_elt = $(row).find('[name="order.orderitems[].unit"]');
478 set_unit_change_with_oldval(select_elt)
481 function set_unit_change_with_oldval(selects) {
482 selects.data('oldval', selects.val());
484 selects.change(unit_change);
489 function show_email_dialog(html) {
490 var id = 'jqueryui_popup_dialog';
491 var dialog_params = {
496 close: function(event, ui) {
497 email_dialog.remove();
501 $('#' + id).remove();
503 email_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
504 email_dialog.html(html);
505 email_dialog.dialog(dialog_params);
507 $('.cancel').click(close_email_dialog);
512 close_email_dialog = function() {
513 email_dialog.dialog("close");
518 $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
519 [%- IF SELF.cv == 'customer' %]
520 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
522 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) });
524 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
525 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_unit').val(o.unit) });
526 $('.add_item_input').keydown(function(event) {
527 if(event.keyCode == 13) {
528 event.preventDefault();
533 row_set_keyboard_events($('.row_entry'));
534 $('.recalc').change(recalc_amounts_and_taxes);
535 $('.reformat_number').change(reformat_number);
537 set_unit_change_with_oldval($('.unitselect'));