From: Jan Büren Date: Mon, 5 Oct 2015 16:17:54 +0000 (+0200) Subject: Optionale Sortierfunktion in Lieferscheinen X-Git-Tag: release-3.4.1~661 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=fc762fdc0aa43e80fa0ccb22f123983961c1c03a;p=kivitendo-erp.git Optionale Sortierfunktion in Lieferscheinen Den Commit aus dem Kundenprojekt entsprechend für den Standard überarbeitet und als optionale Aufruf für ein HTML-Template zu Verfügung gestellt.Entsprechend kurz im POD beschrieben. --- diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 4b8ead658..ede2116e6 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -42,7 +42,7 @@ use SL::IS; use SL::MoreCommon qw(ary_diff); use SL::ReportGenerator; use SL::WH; -use Sort::Naturally; +use Sort::Naturally (); require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/invoice_io.pl"; @@ -1725,9 +1725,12 @@ sub transfer_in_out_default { $form->redirect; } + sub sort { $main::lxdebug->enter_sub(); + check_do_access(); + my $form = $main::form; my %temp_hash; @@ -1738,23 +1741,43 @@ sub sort { $temp_hash{$form->{"delivery_order_items_id_$i"}} = { runningnumber => $form->{"runningnumber_$i"}, partnumber => $form->{"partnumber_$i"} }; } # naturally sort partnumbers and get a sorted array of doi_ids - my @sorted_doi_ids = sort { ncmp($temp_hash{$a}->{"partnumber"}, $temp_hash{$b}->{"partnumber"}) } keys %temp_hash; + my @sorted_doi_ids = sort { Sort::Naturally::ncmp($temp_hash{$a}->{"partnumber"}, $temp_hash{$b}->{"partnumber"}) } keys %temp_hash; - #$main::lxdebug->message(0, 'sortiert, vorher :' . Dumper(%temp_hash)); - #$main::lxdebug->message(0, 'sortiert, nachher:' . Dumper(@sorted_doi_ids)); my $new_number = 1; + for (@sorted_doi_ids) { - # reposition old runningnumber with the new order 1 .. n $form->{"runningnumber_$temp_hash{$_}->{runningnumber}"} = $new_number; - - #$main::lxdebug->message(0, 'hier jetzt:' . 'ferner' . $temp_hash{$_}->{runningnumber} . - # 'mit' . $form->{"runningnumber_{$temp_hash{$_}->{runningnumber}}"}); #" = $new_number; - $new_number++; } - # update or save directly - # update_delivery_order; $main::lxdebug->leave_sub(); save(); } + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +do.pl - Script for all calls to delivery order + + +=head1 FUNCTIONS + +=over 2 + +=item C + +Sorts all position with Natural Sort. Can be activated in form_footer.html like this +Cinput class="submit" type="submit" name="action_sort" id="sort_button" value="[% 'Sort and Save' | $T8 %]"E> + +=back + +=head1 TODO + +Sort and Save can be implemented as an optional button if configuration ca be set by client config. +Example coding for database scripts and templates in (git show af2f24b8), check also +autogeneration for rose (scripts/rose_auto_create_model.pl --h) diff --git a/templates/webpages/do/form_footer.html b/templates/webpages/do/form_footer.html index 67f631e4f..6c8e0c62e 100644 --- a/templates/webpages/do/form_footer.html +++ b/templates/webpages/do/form_footer.html @@ -92,7 +92,6 @@ [%- END %] [%- END %] [%- IF id %] - [%- UNLESS closed %]