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};
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();
}
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();
}
$('.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) {
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);
};
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();
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);
};
'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',
'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' => '',
<table id="input_row_table_id">
<thead>
<tr class="listheading">
+ <th class="listheading" nowrap >[%- 'position' | $T8 %] </th>
<th class="listheading" nowrap >[%- 'Part' | $T8 %] </th>
<th class="listheading" nowrap >[%- 'Description' | $T8 %] </th>
<th class="listheading" nowrap width="5" >[%- 'Qty' | $T8 %] </th>
</thead>
<tbody>
<tr valign="top" class="listrow">
+ <td>[% L.input_tag('add_item.position', '', size = 5, class="add_item_input numeric") %]</td>
<td>
[%- SET PARAM_KEY = SELF.cv == "customer" ? 'with_customer_partnumber' : 'with_makemodel' -%]
[%- SET PARAM_VAL = SELF.search_cvpartnumber -%]
<div id='multi_items_result'></div>
<hr>
+[% 'At position' | $T8 %]
+[% L.input_tag('multi_items.position', '', size = 5, class="numeric") %]</td>
[% L.button_tag('kivi.Order.add_multi_items()', LxERP.t8('Continue'), id='multi_items_dialog_continue_button') %]
<a href="#" onclick="kivi.Order.close_multi_items_dialog();">[%- LxERP.t8("Cancel") %]</a>
[%- USE L %]
[%- USE P %]
-<tbody class="row_entry listrow"[%- IF MYCONFIG.show_form_details -%] data-expanded="1"[%- END -%]>
+<tbody class="row_entry listrow" data-position="[%- HTML.escape(ITEM.position) -%]"[%- IF MYCONFIG.show_form_details -%] data-expanded="1"[%- END -%]>
<tr>
<td align="center">
[%- IF MYCONFIG.show_form_details %]