- }
- if ( $res->{'ResFound'} eq "Reserved" ) {
- my @da = localtime( time() );
- my $todaysdate =
- sprintf( "%0.2d", ( $da[3] + 1 ) ) . "/"
- . sprintf( "%0.2d", ( $da[4] + 1 ) ) . "/"
- . ( $da[5] + 1900 );
-
- if($branch eq $res->{'branchcode'}){
- $template->param(intransit => 0);
- } else {
- $template->param(intransit => 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'}) {
+ $messages->{'WrongTransfer'} = GetBranchName( $messages->{'WrongTransfer'} );
+ $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