+$template->param( inputloop => \@inputloop );
+
+my $found = 0;
+my $waiting = 0;
+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 ( $messages->{'WasTransfered'} ) {
+ $template->param(
+ found => 1,
+ transfer => 1,
+ );
+}
+
+if ( $messages->{'NeedsTransfer'} ){
+ $template->param(
+ found => 1,
+ needstransfer => 1,
+ itemnumber => $itemnumber,
+ );
+}
+
+if ( $messages->{'Wrongbranch'} ){
+ $template->param(
+ wrongbranch => 1,
+ );
+}
+
+# case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
+
+if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
+ $template->param(
+ WrongTransfer => 1,
+ TransferWaitingAt => $messages->{'WrongTransfer'},
+ WrongTransferItem => $messages->{'WrongTransferItem'},
+ );
+
+ my $reserve = $messages->{'ResFound'};
+ my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
+ my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
+ my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
+ $template->param(
+ wname => $name,
+ wborfirstname => $borr->{'firstname'},
+ wborsurname => $borr->{'surname'},
+ wbortitle => $borr->{'title'},
+ wborphone => $borr->{'phone'},
+ wboremail => $borr->{'email'},
+ wboraddress => $borr->{'address'},
+ wboraddress2 => $borr->{'address2'},
+ wborcity => $borr->{'city'},
+ wborzip => $borr->{'zipcode'},
+ wborrowernumber => $reserve->{'borrowernumber'},
+ wborcnum => $borr->{'cardnumber'},
+ wtransfertFrom => $userenv_branch,
+ );
+}
+
+#
+# reserve found and item arrived at the expected branch
+#
+if ( $messages->{'ResFound'}) {
+ my $reserve = $messages->{'ResFound'};
+ my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
+ my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
+
+ if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
+ if ( $reserve->{'ResFound'} eq "Waiting" ) {
+ $template->param(
+ waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
+ );
+ } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
+ $template->param(
+ intransit => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
+ transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
+ resbarcode => $barcode,
+ reserved => 1,
+ );
+ }
+
+ # same params for Waiting or Reserved
+ $template->param(
+ found => 1,
+ currentbranch => $branches->{$userenv_branch}->{'branchname'},
+ destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
+ name => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
+ borfirstname => $borr->{'firstname'},
+ borsurname => $borr->{'surname'},
+ bortitle => $borr->{'title'},
+ borphone => $borr->{'phone'},
+ boremail => $borr->{'email'},
+ boraddress => $borr->{'address'},
+ boraddress2 => $borr->{'address2'},
+ borcity => $borr->{'city'},
+ borzip => $borr->{'zipcode'},
+ borcnum => $borr->{'cardnumber'},
+ debarred => $borr->{'debarred'},
+ gonenoaddress => $borr->{'gonenoaddress'},
+ barcode => $barcode,
+ destbranch => $reserve->{'branchcode'},
+ borrowernumber => $reserve->{'borrowernumber'},
+ itemnumber => $reserve->{'itemnumber'},
+ );
+ } # else { ; } # error?
+}