From: Bernd Bleßmann Date: Wed, 15 Apr 2020 13:59:52 +0000 (+0200) Subject: Auftrags-Controller: Einfüge-Position eines neuen Artiklens angeben können X-Git-Tag: release-3.5.6.1~232 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=59103201cf9d7131024c1c3d5bbb136addb79a3f;p=kivitendo-erp.git Auftrags-Controller: Einfüge-Position eines neuen Artiklens angeben können --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 76bc3f746..d39fea75d 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -775,8 +775,13 @@ sub action_add_item { SELF => $self, ); - $self->js - ->append('#row_table_id', $row_as_html); + if ($::form->{insert_before_item_id}) { + $self->js + ->before ('.row_entry:has(#item_' . $::form->{insert_before_item_id} . ')', $row_as_html); + } else { + $self->js + ->append('#row_table_id', $row_as_html); + } if ( $item->part->is_assortment ) { $form_attr->{qty_as_number} = 1 unless $form_attr->{qty_as_number}; @@ -800,18 +805,24 @@ sub action_add_item { ID => $item_id, SELF => $self, ); - $self->js - ->append('#row_table_id', $row_as_html); + if ($::form->{insert_before_item_id}) { + $self->js + ->before ('.row_entry:has(#item_' . $::form->{insert_before_item_id} . ')', $row_as_html); + } else { + $self->js + ->append('#row_table_id', $row_as_html); + } }; }; $self->js ->val('.add_item_input', '') ->run('kivi.Order.init_row_handlers') - ->run('kivi.Order.row_table_scroll_down') ->run('kivi.Order.renumber_positions') ->focus('#add_item_parts_id_name'); + $self->js->run('kivi.Order.row_table_scroll_down') if !$::form->{insert_before_item_id}; + $self->js_redisplay_amounts_and_taxes; $self->js->render(); } @@ -882,16 +893,23 @@ sub action_add_multi_items { SELF => $self, ); - $self->js->append('#row_table_id', $row_as_html); + if ($::form->{insert_before_item_id}) { + $self->js + ->before ('.row_entry:has(#item_' . $::form->{insert_before_item_id} . ')', $row_as_html); + } else { + $self->js + ->append('#row_table_id', $row_as_html); + } } $self->js ->run('kivi.Order.close_multi_items_dialog') ->run('kivi.Order.init_row_handlers') - ->run('kivi.Order.row_table_scroll_down') ->run('kivi.Order.renumber_positions') ->focus('#add_item_parts_id_name'); + $self->js->run('kivi.Order.row_table_scroll_down') if !$::form->{insert_before_item_id}; + $self->js_redisplay_amounts_and_taxes; $self->js->render(); } diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 6c739b5d5..9b6957866 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -339,6 +339,9 @@ namespace('kivi.Order', function(ns) { $('.row_entry [name="position"]').each(function(idx, elt) { $(elt).html(idx+1); }); + $('.row_entry').each(function(idx, elt) { + $(elt).data("position", idx+1); + }); }; ns.reorder_items = function(order_by) { @@ -374,14 +377,33 @@ namespace('kivi.Order', function(ns) { ns.renumber_positions(); }; + ns.get_insert_before_item_id = function(wanted_pos) { + if (wanted_pos === '') return; + + var insert_before_item_id; + // selection by data does not seem to work if data is changed at runtime + // var elt = $('.row_entry [data-position="' + wanted_pos + '"]'); + $('.row_entry').each(function(idx, elt) { + if ($(elt).data("position") == wanted_pos) { + insert_before_item_id = $(elt).find('[name="orderitem_ids[+]"]').val(); + return false; + } + }); + + return insert_before_item_id; + }; + ns.add_item = function() { if ($('#add_item_parts_id').val() === '') return; if (!ns.check_cv()) return; $('#row_table_id thead a img').remove(); + var insert_before_item_id = ns.get_insert_before_item_id($('#add_item_position').val()); + var data = $('#order_form').serializeArray(); - data.push({ name: 'action', value: 'Order/add_item' }); + data.push({ name: 'action', value: 'Order/add_item' }, + { name: 'insert_before_item_id', value: insert_before_item_id }); $.post("controller.pl", data, kivi.eval_json_result); }; @@ -439,12 +461,12 @@ namespace('kivi.Order', function(ns) { ns.multi_items_dialog_disable_continue = function() { // disable keydown-event and continue button to prevent // impatient users to add parts multiple times - $('#multi_items_result input').off("keydown"); + $('#multi_items_result input, #multi_items_position').off("keydown"); $('#multi_items_dialog_continue_button').prop('disabled', true); }; ns.multi_items_dialog_enable_continue = function() { - $('#multi_items_result input').keydown(function(event) { + $('#multi_items_result input, #multi_items_position').keydown(function(event) { if(event.keyCode == 13) { event.preventDefault(); ns.add_multi_items(); @@ -475,9 +497,12 @@ namespace('kivi.Order', function(ns) { ns.multi_items_dialog_disable_continue(); + var insert_before_item_id = ns.get_insert_before_item_id($('#multi_items_position').val()); + var data = $('#order_form').serializeArray(); data = data.concat($('#multi_items_form').serializeArray()); - data.push({ name: 'action', value: 'Order/add_multi_items' }); + data.push({ name: 'action', value: 'Order/add_multi_items' }, + { name: 'insert_before_item_id', value: insert_before_item_id }); $.post("controller.pl", data, kivi.eval_json_result); }; diff --git a/locale/de/all b/locale/de/all index 61696a2b1..e188831f0 100755 --- a/locale/de/all +++ b/locale/de/all @@ -350,6 +350,7 @@ $self->{texts} = { 'At least one Perl module that kivitendo ERP requires for running is not installed on your system.' => 'Mindestes ein Perl-Modul, das kivitendo ERP zur Ausführung benötigt, ist auf Ihrem System nicht installiert.', 'At least one of the columns #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (depending on the target table) is required for matching the entry to an existing customer or vendor.' => 'Mindestens eine der Spalten #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (von Zieltabelle abhängig) wird benötigt, um einen Eintrag einem bestehenden Kunden bzw. Lieferanten zuzuordnen.', 'At most' => 'Höchstens', + 'At position' => 'An Position', 'At the moment the transaction looks like this:' => 'Aktuell sieht die Buchung wie folgt aus:', 'Attach PDF:' => 'PDF anhängen', 'Attached Filename' => 'Name des Dateianhangs', diff --git a/locale/en/all b/locale/en/all index 7a8cae533..5c5b02bfc 100644 --- a/locale/en/all +++ b/locale/en/all @@ -350,6 +350,7 @@ $self->{texts} = { 'At least one Perl module that kivitendo ERP requires for running is not installed on your system.' => '', 'At least one of the columns #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (depending on the target table) is required for matching the entry to an existing customer or vendor.' => '', 'At most' => '', + 'At position' => '', 'At the moment the transaction looks like this:' => '', 'Attach PDF:' => '', 'Attached Filename' => '', diff --git a/templates/webpages/order/tabs/_item_input.html b/templates/webpages/order/tabs/_item_input.html index 80ba16393..d5c0ad0c3 100644 --- a/templates/webpages/order/tabs/_item_input.html +++ b/templates/webpages/order/tabs/_item_input.html @@ -4,6 +4,7 @@ + @@ -14,6 +15,7 @@ + [% L.button_tag('kivi.Order.add_multi_items()', LxERP.t8('Continue'), id='multi_items_dialog_continue_button') %] [%- LxERP.t8("Cancel") %] diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index ef51eef07..b93b72861 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -4,7 +4,7 @@ [%- USE L %] [%- USE P %] - +
[%- 'position' | $T8 %] [%- 'Part' | $T8 %] [%- 'Description' | $T8 %] [%- 'Qty' | $T8 %]
[% L.input_tag('add_item.position', '', size = 5, class="add_item_input numeric") %] [%- SET PARAM_KEY = SELF.cv == "customer" ? 'with_customer_partnumber' : 'with_makemodel' -%] [%- SET PARAM_VAL = SELF.search_cvpartnumber -%] diff --git a/templates/webpages/order/tabs/_multi_items_dialog.html b/templates/webpages/order/tabs/_multi_items_dialog.html index 3719a93ae..77cc1e529 100644 --- a/templates/webpages/order/tabs/_multi_items_dialog.html +++ b/templates/webpages/order/tabs/_multi_items_dialog.html @@ -18,6 +18,8 @@

+[% 'At position' | $T8 %] +[% L.input_tag('multi_items.position', '', size = 5, class="numeric") %]
[%- IF MYCONFIG.show_form_details %]