6 [%- INCLUDE 'generic/set_longdescription.html' %]
8 <div id="ui-tabs-basic-data">
14 <th align="right">[% SELF.cv | $T8 %]</th>
15 [% SET cv_id = SELF.cv _ '_id' %]
16 <td>[% L.customer_vendor_picker("order.${SELF.cv}" _ '_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %]</td>
19 <tr id='cp_row' [%- IF !SELF.order.${SELF.cv}.contacts.size %]style='display:none'[%- END %]>
20 <th align="right">[% 'Contact Person' | $T8 %]</th>
21 <td>[% L.select_tag('order.cp_id',
22 SELF.order.${SELF.cv}.contacts,
23 default=SELF.order.cp_id,
24 title_key='full_name_dep',
27 style='width: 300px') %]</td>
30 <tr id='shipto_row' [%- IF !SELF.order.${SELF.cv}.shipto.size %]style='display:none'[%- END %]>
31 <th align="right">[% 'Shipping Address' | $T8 %]</th>
32 <td>[% L.select_tag('order.shipto_id',
33 SELF.order.${SELF.cv}.shipto,
34 default=SELF.order.shipto_id,
35 title_key='displayable_id',
36 value_key='shipto_id',
38 style='width: 300px') %]</td>
42 <th align="right">[% 'Steuersatz' | $T8 %]</th>
43 <td>[% L.select_tag('order.taxzone_id', SELF.all_taxzones, default=SELF.order.taxzone_id, title_key='description', style='width: 300px', class='recalc') %]</td>
46 [%- IF SELF.all_departments.size %]
48 <th align="right">[% 'Department' | $T8 %]</th>
50 [% L.select_tag('order.department_id', SELF.all_departments, default=SELF.order.department_id, title_key='description', with_empty=1, style='width:300px') %]
56 <th align="right">[% 'Shipping Point' | $T8 %]</th>
57 <td>[% L.input_tag('order.shippingpoint', SELF.order.shippingpoint, style='width: 300px') %]</td>
61 <th align="right">[% 'Ship via' | $T8 %]</th>
62 <td>[% L.input_tag('order.shipvia', SELF.order.shipvia, style='width: 300px') %]</td>
66 <th align="right">[% 'Transaction description' | $T8 %]</th>
67 <td>[% L.input_tag('order.transaction_description', SELF.order.transaction_description, style='width: 300px') %]</td>
71 <th align="right">[% 'Project Number' | $T8 %]</th>
72 <td>[% L.project_picker('order.globalproject_id', SELF.order.globalproject_id, style='width: 300px') %]</td>
82 <td colspan="2" align="center">
83 [%- IF SELF.order.id %]
84 <label for="order.delivered">[% 'Delivery Order(s) for full qty created' | $T8 %]</label>
85 [% L.yes_no_tag('order.delivered', SELF.order.delivered) %]
86 <label for="order.closed">[% 'Closed' | $T8 %]</label>
87 [% L.yes_no_tag('order.closed', SELF.order.closed) %]
93 <th align="right">[% 'Employee' | $T8 %]</th>
94 <td>[% L.select_tag('order.employee_id',
96 default=(SELF.order.employee_id ? SELF.order.employee_id : SELF.current_employee_id),
97 title_key='safe_name') %]</td>
100 [% IF SELF.cv == 'customer' %]
102 <th align="right">[% 'Salesman' | $T8 %]</th>
103 <td>[% L.select_tag('order.salesman_id',
105 default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
106 title_key='safe_name') %]</td>
111 <th width="70%" align="right" nowrap>[% 'Order Number' | $T8 %]</th>
112 <td>[% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]</td>
116 <th width="70%" align="right" nowrap>[% 'Quotation Number' | $T8 %]</th>
117 <td>[% L.input_tag('order.quonumber', SELF.order.quonumber, size = 11) %]</td>
121 <th width="70%" align="right" nowrap>[% 'Customer Order Number' | $T8 %]</th>
122 <td>[% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]</td>
126 <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
127 <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
131 <th width="70%" align="right" nowrap>[% 'Reqdate' | $T8 %]</th>
132 <td>[% L.date_tag('order.reqdate', SELF.order.reqdate) %]</td>
136 <th width="70%" align="right" nowrap>[% 'Insert Date' | $T8 %]</th>
137 <td>[% SELF.order.itime_as_date %]</td>
146 [%- PROCESS order/tabs/_item_input.html %]
148 [% L.button_tag('show_multi_items_dialog()', LxERP.t8('Add multiple parts')) %]</td>
154 <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
155 <table id="row_table_id" width="100%">
157 <tr class="listheading">
158 <th class="listheading" style='display:none'></th>
159 <th class="listheading" nowrap width="3" >[%- 'position' | $T8 %] </th>
160 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
161 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
162 <th id="partnumber_header_id" class="listheading" nowrap width="15"><a href='#' onClick='javascript:reorder_items("partnumber")'> [%- 'Partnumber' | $T8 %]</a></th>
163 <th id="description_header_id" class="listheading" nowrap ><a href='#' onClick='javascript:reorder_items("description")'>[%- 'Description' | $T8 %]</a></th>
164 <th id="qty_header_id" class="listheading" nowrap width="5" ><a href='#' onClick='javascript:reorder_items("qty")'> [%- 'Qty' | $T8 %]</a></th>
165 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
166 <th class="listheading" nowrap width="5" >[%- 'Unit' | $T8 %] </th>
167 <th class="listheading" nowrap width="5" >[%- 'Price Source' | $T8 %] </th>
168 <th id="sellprice_header_id" class="listheading" nowrap width="15" ><a href='#' onClick='javascript:reorder_items("sellprice")'> [%- 'Price' | $T8 %]</a></th>
169 <th id="discount_header_id" class="listheading" nowrap width="15" ><a href='#' onClick='javascript:reorder_items("discount")'> [%- 'Discount' | $T8 %]</a></th>
170 <th class="listheading" nowrap width="10">[%- 'Extended' | $T8 %] </th>
174 [%- FOREACH item = SELF.order.items_sorted %]
175 [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id %]
188 <td colspan="100%" width="100%">
194 <th align="left">[% 'Notes' | $T8 %]</th>
195 <th align="left">[% 'Internal Notes' | $T8 %]</th>
199 [% L.textarea_tag('order.notes', SELF.order.notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
202 [% L.textarea_tag('order.intnotes', SELF.order.intnotes, wrap="soft", style="width: 350px; height: 150px") %]
211 <th align="right">[% 'Payment Terms' | $T8 %]</th>
212 <td>[% L.select_tag('order.payment_id',
213 SELF.all_payment_terms,
214 default = SELF.order.payment_id,
216 title_key = 'description',
217 style = 'width: 250px') %]</td>
220 <th align="right">[% 'Delivery Terms' | $T8 %]</th>
221 <td>[% L.select_tag('order.delivery_term_id',
222 SELF.all_delivery_terms,
223 default = SELF.order.delivery_term_id,
225 title_key = 'description',
226 style = 'width: 250px') %]</td>
233 <tr id="taxincluded_row_id" [%- IF !SELF.taxes.size %]style="display:none"[%- END %]>
234 <td align=right colspan="2">
235 <label for="order.taxincluded"><b>[% 'Tax Included' | $T8 %]</b></label>
236 [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %]
240 <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
241 <th align="right">[%- 'Subtotal' | $T8 %]</th>
243 [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
246 [%- FOREACH tax = SELF.taxes %]
247 [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %]
249 <tr id="amount_row_id">
250 <th align="right">[%- 'Total' | $T8 %]</th>
252 [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
268 [% L.sortable_element('#row_table_id') %]
270 <script type='text/javascript'>
271 function reload_cv_dependend_selections() {
272 var data = $('#order_form').serializeArray();
273 data.push({ name: 'action', value: 'Order/customer_vendor_changed' });
275 $.post("controller.pl", data, kivi.eval_json_result);
278 function unit_change(event) {
279 var row = $(event.target).parents("tbody").first();
280 var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
281 var sellprice_dom = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
282 var select_elt = $(row).find('[name="order.orderitems[].unit"]');
284 var oldval = $(select_elt).data('oldval');
285 $(select_elt).data('oldval', $(select_elt).val());
287 var data = $('#order_form').serializeArray();
288 data.push({ name: 'action', value: 'Order/unit_changed' });
289 data.push({ name: 'item_id', value: item_id_dom.val() });
290 data.push({ name: 'old_unit', value: oldval });
291 data.push({ name: 'sellprice_dom_id', value: sellprice_dom.attr('id') });
293 $.post("controller.pl", data, kivi.eval_json_result);
296 function update_sellprice(item_id, price_str) {
297 var row = $('#item_' + item_id).parents("tbody").first();
298 var price_elt = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
299 var html_elt = $(row).find('[name="sellprice_text"]');
300 price_elt.val(price_str);
301 html_elt.html(price_str);
304 function add_item() {
305 if ($('#add_item_parts_id').val() == '') return;
306 if (!check_cv()) return;
308 $('#row_table_id thead a img').remove();
310 var data = $('#order_form').serializeArray();
311 data.push({ name: 'action', value: 'Order/add_item' });
313 $.post("controller.pl", data, kivi.eval_json_result);
316 function show_multi_items_dialog() {
317 if (!check_cv()) return;
319 $('#row_table_id thead a img').remove();
322 url: 'controller.pl?action=Order/show_multi_items_dialog',
323 data: { type: $('#type').val(),
324 callback: 'Order/add_multi_items',
325 callback_data_id: 'order_form' },
326 id: 'jq_multi_items_dialog',
328 title: kivi.t8('Add multiple items'),
336 function close_multi_items_dialog() {
337 $('#jq_multi_items_dialog').dialog('close');
340 function delete_order_item_row(clicked) {
341 var row = $(clicked).parents("tbody").first();
344 renumber_positions();
345 recalc_amounts_and_taxes();
348 function price_chooser_item_row(clicked) {
349 var row = $(clicked).parents("tbody").first();
350 var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
352 var data = $('#order_form').serializeArray();
353 data.push({ name: 'action', value: 'Order/price_popup' });
354 data.push({ name: 'item_id', value: item_id_dom.val() });
356 $.post("controller.pl", data, kivi.eval_json_result);
359 function update_price_source(item_id, source, descr, price_str) {
360 var row = $('#item_' + item_id).parents("tbody").first();
361 var source_elt = $(row).find('[name="order.orderitems[].active_price_source"]');
362 var button_elt = $(row).find('[name="price_chooser_button"]');
364 button_elt.val(button_elt.val().replace(/.*\|/, descr + " |"));
365 source_elt.val(source);
367 var editable_div_elt = $(row).find('[name="editable_price"]');
368 var not_editable_div_elt = $(row).find('[name="not_editable_price"]');
369 if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
371 $(editable_div_elt).show();
372 $(not_editable_div_elt).hide();
373 $(editable_div_elt).find(':input').prop("disabled", false);
374 $(not_editable_div_elt).find(':input').prop("disabled", true);
377 $(editable_div_elt).hide();
378 $(not_editable_div_elt).show();
379 $(editable_div_elt).find(':input').prop("disabled", true);
380 $(not_editable_div_elt).find(':input').prop("disabled", false);
384 var price_elt = $(row).find('[name="order.orderitems[].sellprice_as_number"]');
385 var html_elt = $(row).find('[name="sellprice_text"]');
386 price_elt.val(price_str);
387 html_elt.html(price_str);
388 recalc_amounts_and_taxes();
391 kivi.io.close_dialog();
394 function update_discount_source(item_id, source, descr, discount_str) {
395 var row = $('#item_' + item_id).parents("tbody").first();
396 var source_elt = $(row).find('[name="order.orderitems[].active_discount_source"]');
397 var button_elt = $(row).find('[name="price_chooser_button"]');
399 button_elt.val(button_elt.val().replace(/\|.*/, "| " + descr));
400 source_elt.val(source);
402 var editable_div_elt = $(row).find('[name="editable_discount"]');
403 var not_editable_div_elt = $(row).find('[name="not_editable_discount"]');
404 if ([%- AUTH.assert('edit_prices', 1) %] == 1 && source == '') {
406 $(editable_div_elt).show();
407 $(not_editable_div_elt).hide();
408 $(editable_div_elt).find(':input').prop("disabled", false);
409 $(not_editable_div_elt).find(':input').prop("disabled", true);
412 $(editable_div_elt).hide();
413 $(not_editable_div_elt).show();
414 $(editable_div_elt).find(':input').prop("disabled", true);
415 $(not_editable_div_elt).find(':input').prop("disabled", false);
419 var discount_elt = $(row).find('[name="order.orderitems[].discount_as_percent"]');
420 var html_elt = $(row).find('[name="discount_text"]');
421 discount_elt.val(discount_str);
422 html_elt.html(discount_str);
423 recalc_amounts_and_taxes();
426 kivi.io.close_dialog();
429 function reformat_number(event) {
430 $(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2));
433 function recalc_amounts_and_taxes() {
434 var data = $('#order_form').serializeArray();
435 data.push({ name: 'action', value: 'Order/recalc_amounts_and_taxes' });
437 $.post("controller.pl", data, kivi.eval_json_result);
440 function redisplay_linetotals(data) {
441 $('.row_entry [name="linetotal"]').each(function(idx, elt) {
442 $(elt).html(data[idx]);
446 function row_table_scroll_down() {
447 $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
450 function row_set_keyboard_events_by_id(item_id) {
451 var row = $('#item_' + item_id).parents("tbody").first();
453 row_set_keyboard_events(row);
456 function row_set_keyboard_events(rows) {
457 $(rows).keydown(function(event) {
458 if(event.keyCode == 40 && event.shiftKey == true) {
460 event.preventDefault();
461 var row = $(event.target).parents(".row_entry").first();
462 $(row).children().not(':first').show();
465 if(event.keyCode == 38 && event.shiftKey == true) {
467 event.preventDefault();
468 var row = $(event.target).parents(".row_entry").first();
469 $(row).children().not(':first').hide();
474 $(rows).dblclick(function(event) {
475 event.preventDefault();
476 var row = $(event.target).parents(".row_entry").first();
477 $(row).children().not(':first').toggle();
482 function set_unit_change_with_oldval_by_id(item_id) {
483 var row = $('#item_' + item_id).parents("tbody").first();
484 var select_elt = $(row).find('[name="order.orderitems[].unit"]');
486 set_unit_change_with_oldval(select_elt);
489 function set_unit_change_with_oldval(selects) {
490 selects.each(function(idx,elt) {
491 $(elt).data('oldval', $(elt).val());
494 selects.change(unit_change);
499 function show_email_dialog(html) {
500 var id = 'jqueryui_popup_dialog';
501 var dialog_params = {
506 close: function(event, ui) {
507 email_dialog.remove();
511 $('#' + id).remove();
513 email_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
514 email_dialog.html(html);
515 email_dialog.dialog(dialog_params);
517 $('.cancel').click(close_email_dialog);
522 close_email_dialog = function() {
523 email_dialog.dialog("close");
526 function renumber_positions() {
527 $('.row_entry [name="position"]').each(function(idx, elt) {
532 function reorder_items(order_by) {
533 var dir = $('#' + order_by + '_header_id a img').attr("data-sort-dir");
534 $('#row_table_id thead a img').remove();
539 src = "image/up.png";
542 src = "image/down.png";
545 $('#' + order_by + '_header_id a').append('<img border=0 data-sort-dir=' + dir + ' src=' + src + ' alt="[%- LxERP.t8('sort items') %]">');
547 var data = $('#order_form').serializeArray();
548 data.push({ name: 'action', value: 'Order/reorder_items' });
549 data.push({ name: 'order_by', value: order_by });
550 data.push({ name: 'sort_dir', value: dir });
552 $.post("controller.pl", data, kivi.eval_json_result);
555 function redisplay_items(data) {
556 var old_rows = $('.row_entry').detach();
558 $(data).each(function(idx, elt) {
559 new_rows.push(old_rows[elt.old_pos - 1]);
561 $(new_rows).appendTo($('#row_table_id'));
562 renumber_positions();
565 function show_longdescription_dialog(clicked) {
566 var row = $(clicked).parents("tbody").first();
567 var position = $(row).find('[name="position"]').html();
568 var partnumber = $(row).find('[name="partnumber"]').html();
569 var description_elt = $(row).find('[name="order.orderitems[].description"]');
570 var description = description_elt.val();
571 var longdescription_elt = $(row).find('[name="order.orderitems[].longdescription"]');
574 if (!longdescription_elt.length) {
576 data.push({ name: 'action', value: 'Order/get_item_longdescription' });
577 data.push({ name: 'type', value: $('#type').val() });
578 data.push({ name: 'item_id', value: $(row).find('[name="order.orderitems[+].id"]').val() });
579 data.push({ name: 'parts_id', value: $(row).find('[name="order.orderitems[].parts_id"]').val() });
581 url: 'controller.pl',
586 success: function(val){
587 longdescription = val;
591 longdescription = longdescription_elt.val();
594 var params = { runningnumber: position,
595 partnumber: partnumber,
596 description: description,
597 default_longdescription: longdescription,
598 set_function: function(val){
599 longdescription_elt.remove();
600 $('<input type="hidden" name="order.orderitems[].longdescription">').insertAfter(description_elt).val(val);
604 kivi.SalesPurchase.edit_longdescription_with_params(params);
608 $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
609 [%- IF SELF.cv == 'customer' %]
610 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
612 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) });
614 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
615 $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_unit').val(o.unit) });
616 $('.add_item_input').keydown(function(event) {
617 if(event.keyCode == 13) {
618 event.preventDefault();
623 row_set_keyboard_events($('.row_entry'));
624 $('.recalc').change(recalc_amounts_and_taxes);
625 $('.reformat_number').change(reformat_number);
627 set_unit_change_with_oldval($('.unitselect'));
630 $('#row_table_id').on('sortstop', function(event, ui) {
631 $('#row_table_id thead a img').remove();
632 renumber_positions();