Revision 9ef0dcd3
Von Sven Schöling vor fast 3 Jahren hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
4 | 4 |
use parent qw(SL::Controller::Base); |
5 | 5 |
|
6 | 6 |
use SL::Helper::Flash qw(flash_later); |
7 |
use SL::Helper::Number qw(_format_number_units); |
|
7 |
use SL::Helper::Number qw(_format_number_units _parse_number);
|
|
8 | 8 |
use SL::Presenter::Tag qw(select_tag hidden_tag div_tag); |
9 | 9 |
use SL::Locale::String qw(t8); |
10 | 10 |
use SL::SessionFile::Random; |
... | ... | |
886 | 886 |
|
887 | 887 |
} |
888 | 888 |
|
889 |
sub action_stock_in_out_dialog { |
|
890 |
my ($self) = @_; |
|
891 |
|
|
892 |
my $part = SL::DB::Part->load_cached($::form->{parts_id}) or die "need parts_id"; |
|
893 |
my $stock = $::form->{stock}; |
|
894 |
my $unit = $::form->{unit}; |
|
895 |
my $qty = _parse_number($::form->{qty_as_number}); |
|
896 |
|
|
897 |
my $inout = $self->type_data->transfer; |
|
898 |
|
|
899 |
my @contents = DO->get_item_availability(parts_id => $part->id); |
|
900 |
my $stock_info = DO->unpack_stock_information(packed => $stock); |
|
901 |
|
|
902 |
$self->merge_stock_data($stock_info, \@contents, $part); |
|
903 |
|
|
904 |
$self->render("delivery_order/stock_dialog", { layout => 0 }, |
|
905 |
WHCONTENTS => $self->order->delivered ? $stock_info : \@contents, |
|
906 |
part => $part, |
|
907 |
do_qty => $qty, |
|
908 |
do_unit => $unit, |
|
909 |
); |
|
910 |
|
|
911 |
} |
|
912 |
|
|
913 |
sub merge_stock_data { |
|
914 |
my ($self, $stock_info, $contents, $part) = @_; |
|
915 |
# TODO rewrite to mapping |
|
916 |
|
|
917 |
if (!$self->order->delivered) { |
|
918 |
for my $row (@$contents) { |
|
919 |
$row->{available_qty} = _format_number_units($row->{qty}, $row->{unit}, $part->unit); |
|
920 |
|
|
921 |
for my $sinfo (@{ $stock_info }) { |
|
922 |
next if $row->{bin_id} != $sinfo->{bin_id} || |
|
923 |
$row->{warehouse_id} != $sinfo->{warehouse_id} || |
|
924 |
$row->{chargenumber} ne $sinfo->{chargenumber} || |
|
925 |
$row->{bestbefore} ne $sinfo->{bestbefore}; |
|
926 |
|
|
927 |
$row->{"stock_$_"} = $sinfo->{$_} |
|
928 |
for qw(qty unit error delivery_order_items_stock_id); |
|
929 |
} |
|
930 |
} |
|
931 |
|
|
932 |
} else { |
|
933 |
for my $sinfo (@{ $stock_info }) { |
|
934 |
my $bin = SL::DB::Bin->load_cached($sinfo->{bin_id}); |
|
935 |
$sinfo->{warehouse_description} = $bin->warehouse->description; |
|
936 |
$sinfo->{bin_description} = $bin->escription; |
|
937 |
map { $sinfo->{"stock_$_"} = $sinfo->{$_} } qw(qty unit); |
|
938 |
} |
|
939 |
} |
|
940 |
} |
|
941 |
|
|
889 | 942 |
# load the second row for one or more items |
890 | 943 |
# |
891 | 944 |
# This action gets the html code for all items second rows by rendering a template for |
Auch abrufbar als: Unified diff
DeliveryOrder: erste Version Lager-Dialog