+ my $makePreviousSerialAvailable = C4::Context->preference('makePreviousSerialAvailable');
+ if ($makePreviousSerialAvailable && $serialids[$i] ne "NEW") {
+ # We already have created the new expected serial at this point, so we get the second previous serial
+ my $previous = GetPreviousSerialid($subscriptionids[$i]);
+ if ($previous) {
+
+ my $serialitem = Koha::Serial::Items->search( {serialid => $previous} )->next;
+ my $itemnumber = $serialitem ? $serialitem->itemnumber : undef;
+ if ($itemnumber) {
+
+ # Getting the itemtype to set from the database
+ my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
+
+ # Changing the status to "available" and the itemtype according to the previousitemtype db field
+ my $item = Koha::Items->find($itemnumber);
+ $item->set(
+ {
+ notforloan => 0,
+ itype => $subscriptioninfos->{'previousitemtype'}
+ }
+ )->store;
+ }
+ }
+ }
+