Lines 56-90
sub default_processing {
Link Here
|
56 |
|
56 |
|
57 |
Add item to this train |
57 |
Add item to this train |
58 |
|
58 |
|
59 |
my $train_item = $train->add_item({item_id => $itemnumber, processing_id => $processing_id}); |
59 |
my $train_item = $train->add_item({item_id => $itemnumber, processing_id => $processing_id}, { skip_waiting_list_check => 0|1 }); |
60 |
my $train_item = $train->add_item({barcode => $barcode, processing_id => $processing_id}); |
60 |
my $train_item = $train->add_item({barcode => $barcode, processing_id => $processing_id, { skip_waiting_list_check => 0|1 }); |
|
|
61 |
|
62 |
skip_waitin_list_check can be set to true if the item can be added to the train even if the item is not in the waiting list. |
61 |
|
63 |
|
62 |
=cut |
64 |
=cut |
63 |
|
65 |
|
64 |
sub add_item { |
66 |
sub add_item { |
65 |
my ( $self, $train_item ) = @_; |
67 |
my ( $self, $train_item, $params ) = @_; |
|
|
68 |
|
69 |
my $skip_waiting_list_check = $params->{skip_waiting_list_check} || 0; |
66 |
|
70 |
|
67 |
my $not_for_loan = C4::Context->preference('PreservationNotForLoanWaitingListIn'); |
71 |
my $not_for_loan = C4::Context->preference('PreservationNotForLoanWaitingListIn'); |
68 |
|
72 |
|
69 |
my $key = exists $train_item->{item_id} ? 'itemnumber' : 'barcode'; |
73 |
my $key = exists $train_item->{item_id} ? 'itemnumber' : 'barcode'; |
70 |
my $item = Koha::Items->find( { $key => $train_item->{item_id} || $train_item->{barcode} } ); |
74 |
my $item = Koha::Items->find( { $key => $train_item->{item_id} || $train_item->{barcode} } ); |
71 |
Koha::Exceptions::Preservation::ItemNotFound->throw unless $item; |
75 |
Koha::Exceptions::Preservation::ItemNotFound->throw unless $item; |
72 |
Koha::Exceptions::Preservation::ItemNotInWaitingList->throw if $item->notforloan != $not_for_loan; |
76 |
|
|
|
77 |
Koha::Exceptions::Preservation::ItemNotInWaitingList->throw |
78 |
if !$skip_waiting_list_check && $item->notforloan != $not_for_loan; |
73 |
|
79 |
|
74 |
# FIXME We need a LOCK here |
80 |
# FIXME We need a LOCK here |
75 |
# Not important for now as we have add_items |
81 |
# Not important for now as we have add_items |
76 |
# Note that there are several other places in Koha with this max+1 problem |
82 |
# Note that there are several other places in Koha with this max+1 problem |
77 |
my $max = $self->items->search->_resultset->get_column("user_train_item_id")->max || 0; |
83 |
my $max = $self->items->search->_resultset->get_column("user_train_item_id")->max || 0; |
78 |
my $train_item_rs = $self->_result->add_to_preservation_trains_items( |
84 |
my $train_item_object = Koha::Preservation::Train::Item->new( |
79 |
{ |
85 |
{ |
|
|
86 |
train_id => $self->train_id, |
80 |
item_id => $item->itemnumber, |
87 |
item_id => $item->itemnumber, |
81 |
processing_id => $train_item->{processing_id} || $self->default_processing_id, |
88 |
processing_id => $train_item->{processing_id} || $self->default_processing_id, |
82 |
user_train_item_id => $max + 1, |
89 |
user_train_item_id => $max + 1, |
83 |
added_on => \'NOW()', |
90 |
added_on => \'NOW()', |
84 |
} |
91 |
} |
85 |
); |
92 |
)->store; |
86 |
$item->notforloan( $self->not_for_loan )->store; |
93 |
$item->notforloan( $self->not_for_loan )->store; |
87 |
return Koha::Preservation::Train::Item->_new_from_dbic($train_item_rs); |
94 |
return $train_item_object->get_from_storage; |
88 |
} |
95 |
} |
89 |
|
96 |
|
90 |
=head3 add_items |
97 |
=head3 add_items |