Revision 1e0fd485
Von Sven Schöling vor fast 3 Jahren hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
26 | 26 |
use SL::DB::RecordLink; |
27 | 27 |
use SL::DB::Shipto; |
28 | 28 |
use SL::DB::Translation; |
29 |
use SL::DB::TransferType; |
|
29 | 30 |
|
30 | 31 |
use SL::Helper::CreatePDF qw(:all); |
31 | 32 |
use SL::Helper::PrintOptions; |
... | ... | |
950 | 951 |
$self->js->render(); |
951 | 952 |
} |
952 | 953 |
|
954 |
sub action_transfer_stock { |
|
955 |
my ($self) = @_; |
|
956 |
|
|
957 |
if ($self->order->delivered) { |
|
958 |
return $self->js->flash("error", t8('The parts for this order have already been transferred'))->render; |
|
959 |
} |
|
960 |
|
|
961 |
my $errors = $self->save; |
|
962 |
|
|
963 |
if (@$errors) { |
|
964 |
$self->js->flash('error', $_) for @$errors; |
|
965 |
return $self->js->render; |
|
966 |
} |
|
967 |
|
|
968 |
my $order = $self->order; |
|
969 |
|
|
970 |
# TODO move to type data |
|
971 |
my $trans_type = $self->type_data->properties('transfer') eq 'in' |
|
972 |
? SL::DB::Manager::TransferType->find_by(direction => "id", description => "stock") |
|
973 |
: SL::DB::Manager::TransferType->find_by(direction => "out", deescription => "shipped"); |
|
974 |
|
|
975 |
my @transfer_requests; |
|
976 |
|
|
977 |
for my $item (@{ $order->items_sorted }) { |
|
978 |
for my $stock (@{ $item->delivery_order_stock_entries }) { |
|
979 |
my $transfer = SL::DB::Inventory->new_from($stock); |
|
980 |
$transfer->trans_type($trans_type); |
|
981 |
|
|
982 |
push @transfer_requests, $transfer; |
|
983 |
}; |
|
984 |
} |
|
985 |
|
|
986 |
if (!@transfer_requests) { |
|
987 |
$self->js->flash("error", t8("No stock to transfer"))->render; |
|
988 |
} |
|
989 |
|
|
990 |
SL::DB->with_transaction(sub { |
|
991 |
$_->save for @transfer_requests; |
|
992 |
$self->order->update_attributes(deliverd => 1); |
|
993 |
}); |
|
994 |
|
|
995 |
$self->js->flash("info", t8("Stock transfered"))->render; |
|
996 |
} |
|
997 |
|
|
953 | 998 |
sub js_load_second_row { |
954 | 999 |
my ($self, $item, $item_id, $do_parse) = @_; |
955 | 1000 |
|
... | ... | |
1541 | 1586 |
); |
1542 | 1587 |
} |
1543 | 1588 |
|
1544 |
|
|
1545 | 1589 |
sub pre_render { |
1546 | 1590 |
my ($self) = @_; |
1547 | 1591 |
|
... | ... | |
1707 | 1751 |
only_if => $self->type_data->show_menu("delete"), |
1708 | 1752 |
], |
1709 | 1753 |
|
1754 |
combobox => [ |
|
1755 |
action => [ |
|
1756 |
t8('Transfer out'), |
|
1757 |
submit => [ '#order_form', { action => "DeliveryOrder/transfer_stock" } ], |
|
1758 |
disabled => $self->order->delivered ? t8('The parts for this order have already been transferred') : undef, |
|
1759 |
only_if => $self->type_data->properties('transfer') eq 'out', |
|
1760 |
confirm => t8('Do you really want to transfer the stock and set this order to delivered?'), |
|
1761 |
], |
|
1762 |
action => [ |
|
1763 |
t8('Transfer in'), |
|
1764 |
submit => [ '#order_form', { action => "DeliveryOrder/transfer_stock" } ], |
|
1765 |
disabled => $self->order->delivered ? t8('The parts for this order have already been transferred') : undef, |
|
1766 |
only_if => $self->type_data->properties('transfer') eq 'in', |
|
1767 |
confirm => t8('Do you really want to transfer the stock and set this order to delivered?'), |
|
1768 |
], |
|
1769 |
], |
|
1770 |
|
|
1710 | 1771 |
combobox => [ |
1711 | 1772 |
action => [ |
1712 | 1773 |
t8('more') |
Auch abrufbar als: Unified diff
DeliveryOrder: Einlagern/Auslagern