my $reserved = 0;
# new op dev : we check if the document must be returned to his homebranch directly,
-# if the document is transfered, we have warning message .
+# if the document is transferred, we have warning message .
if ( $messages->{'WasTransfered'} ) {
$template->param(
);
}
-# case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
+# case of wrong transfert, if the document wasn't transferred to the right library (according to branchtransfer (tobranch) BDD)
if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
$template->param(
my $reserve = $messages->{'ResFound'};
my $patron = Koha::Patrons->find( $reserve->{borrowernumber} );
my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } );
- if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
+
+ if ( $reserve->{'ResFound'} eq "Reserved" && C4::Context->preference('HoldsAutoFill') ) {
+ my $item = Koha::Items->find( $itemnumber );
+ my $biblio = $item->biblio;
+
+ my $diffBranchSend = ($userenv_branch ne $reserve->{branchcode}) ? $reserve->{branchcode} : undef;
+ ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} );
+ my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
+
+ my $patron = Koha::Patrons->find( $nextreservinfo );
+
+ $template->param(
+ hold_auto_filled => 1,
+ print_slip => C4::Context->preference('HoldsAutoFillPrintSlip'),
+ patron => $patron,
+ borrowernumber => $patron->id,
+ biblionumber => $biblio->id,
+ );
+
+ if ( $messages->{'transfert'} ) {
+ $template->param(
+ itemtitle => $biblio->title,
+ itemnumber => $item->itemnumber,
+ itembiblionumber => $biblio->biblionumber,
+ iteminfo => $biblio->author,
+ diffbranch => 1,
+ );
+ }
+ }
+ elsif ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
if ( $reserve->{'ResFound'} eq "Waiting" ) {
$template->param(
waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
);
}
- # same params for Waiting or Reserved
- $template->param(
- # FIXME The full patron object should be passed to the template
- found => 1,
- patron => $patron,
- barcode => $barcode,
- destbranch => $reserve->{'branchcode'},
- itemnumber => $reserve->{'itemnumber'},
- reservenotes => $reserve->{'reservenotes'},
- reserve_id => $reserve->{reserve_id},
- bormessagepref => $holdmsgpreferences->{'transports'},
- );
} # else { ; } # error?
+
+ # same params for Waiting or Reserved
+ $template->param(
+ found => 1,
+ patron => $patron,
+ barcode => $barcode,
+ destbranch => $reserve->{'branchcode'},
+ itemnumber => $reserve->{'itemnumber'},
+ reservenotes => $reserve->{'reservenotes'},
+ reserve_id => $reserve->{reserve_id},
+ bormessagepref => $holdmsgpreferences->{'transports'},
+ );
}
# Error Messages
}
my $item = Koha::Items->find({ barcode => $bar_code });
+ next unless $item; # FIXME The item has been deleted in the meantime,
+ # we could handle that better displaying a message in the template
my $biblio = $item->biblio;
# FIXME pass $item to the template and we are done here...
$ri{itembiblionumber} = $biblio->biblionumber;
AudioAlerts => C4::Context->preference("AudioAlerts"),
);
-$itemnumber = GetItemnumberFromBarcode( $barcode );
-if ( $itemnumber ) {
+my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!?
+if ( $item_from_barcode ) {
+ $itemnumber = $item_from_barcode->itemnumber;
my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
if ( $holdingBranch and $collectionBranch ) {
$holdingBranch //= '';