Skip to content

Commit

Permalink
Lagerplätze natürlich nach Beschreibung in Listen sortieren
Browse files Browse the repository at this point in the history
Für alle Lagerfunktionen und für den Standardlagerplatz der Waren
kivijan committed Nov 23, 2023
1 parent dca820e commit 6798d5b
Showing 5 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions SL/Controller/Inventory.pm
Original file line number Diff line number Diff line change
@@ -722,7 +722,7 @@ sub sanitize_target {
my ($self) = @_;

$self->warehouse($self->warehouses->[0]) if !$self->warehouse || !$self->warehouse->id;
$self->bin ($self->warehouse->bins->[0]) if !$self->bin || !$self->bin->id;
$self->bin ($self->warehouse->bins_sorted_naturally->[0]) if !$self->bin || !$self->bin->id;
# foreach my $warehouse ( $self->warehouses ) {
# $warehouse->{BINS} = [];
# foreach my $bin ( $self->bins ) {
@@ -768,7 +768,7 @@ sub build_warehouse_select {
}

sub build_bin_select {
select_tag('bin_id', [ $_[0]->warehouse->bins ],
select_tag('bin_id', [ $_[0]->warehouse->bins_sorted_naturally ],
title_key => 'description',
default => $_[0]->bin->id,
);
4 changes: 2 additions & 2 deletions SL/Controller/Part.pm
Original file line number Diff line number Diff line change
@@ -674,7 +674,7 @@ sub action_warehouse_changed {
die unless ref($self->warehouse) eq 'SL::DB::Warehouse';

if ( $self->warehouse->id and @{$self->warehouse->bins} ) {
$self->bin($self->warehouse->bins_sorted->[0]);
$self->bin($self->warehouse->bins_sorted_naturally->[0]);
$self->js
->html('#bin', $self->build_bin_select)
->focus('#part_bin_id');
@@ -1202,7 +1202,7 @@ sub parse_form_customerprices {
}

sub build_bin_select {
select_tag('part.bin_id', [ @{ $_[0]->warehouse->bins_sorted } ],
select_tag('part.bin_id', [ @{ $_[0]->warehouse->bins_sorted_naturally } ],
title_key => 'description',
default => $_[0]->bin->id,
);
5 changes: 5 additions & 0 deletions SL/DB/Warehouse.pm
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ package SL::DB::Warehouse;

use strict;

use Sort::Naturally;

use SL::DB::MetaSetup::Warehouse;
use SL::DB::Manager::Warehouse;
use SL::DB::Helper::ActsAsList;
@@ -19,6 +21,9 @@ __PACKAGE__->meta->initialize;
sub bins_sorted {
return [ sort { $a->id <=> $b->id } @{ shift()->bins || [] } ];
}
sub bins_sorted_naturally {
return [ sort { ncmp ($a->description, $b->description) } @{ shift()->bins || [] } ];
}

sub first_bin {
return shift()->bins_sorted->[0];
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ <h1>[% title | html %]</h1>
<td class="wi-wide below">
[% L.select_tag('warehouse_id', SELF.warehouses, default=SELF.warehouse.id, title_key='description', class='wi-wide') %]
[% IF SELF.warehouse.id %]
[% L.select_tag('bin_id', SELF.warehouse.bins, default=SELF.bin.id, title_key='description', class='wi-wide below') %]
[% L.select_tag('bin_id', SELF.warehouse.bins_sorted_naturally, default=SELF.bin.id, title_key='description', class='wi-wide below') %]
[% ELSE %]
<span id="bin_id" class="data wi-wide"></span>
[% END %]
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ <h1>[% title | html %]</h1>
<th align="right" nowrap>[% 'Destination warehouse' | $T8 %]</th>
<td>[% L.select_tag('warehouse_id', SELF.warehouses, default=SELF.warehouse.id, title_key='description') %]
[% IF SELF.warehouse.id %]
[% L.select_tag('bin_id', SELF.warehouse.bins, default=SELF.bin.id, title_key='description') %]
[% L.select_tag('bin_id', SELF.warehouse.bins_sorted_naturally, default=SELF.bin.id, title_key='description') %]
[%- ELSE %]
<span id='bin_id'></span>
[% END %]

0 comments on commit 6798d5b

Please sign in to comment.