+
+#
+# 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" ) {
+ if ( C4::Context->userenv->{'branch'} eq $reserve->{'branchcode'} ) {
+ $template->param( waiting => 1 );
+ }
+ else {
+ $template->param( waiting => 0 );
+ }
+
+ $template->param(
+ found => 1,
+ 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'},
+ borrowernumber => $reserve->{'borrowernumber'},
+ borcnum => $borr->{'cardnumber'},
+ debarred => $borr->{'debarred'},
+ gonenoaddress => $borr->{'gonenoaddress'},
+ currentbranch => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
+ itemnumber => $reserve->{'itemnumber'},
+ barcode => $barcode,
+ );
+
+ }
+ if ( $reserve->{'ResFound'} eq "Reserved" ) {
+ # my @da = localtime( time() );
+ # my $todaysdate = sprintf( "%0.2d/%0.2d/%0.4d", ( $datearr[3] + 1 ),( $datearr[4] + 1 ),( $datearr[5] + 1900 ) );
+ # FIXME - use Dates obj , locale. AND, why [4]+1 ??
+ if ( C4::Context->userenv->{'branch'} eq $reserve->{'branchcode'} ) {
+ $template->param( intransit => 0 );
+ }
+ else {
+ $template->param( intransit => 1 );
+ }
+
+ $template->param(
+ found => 1,
+ currentbranch => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
+ destbranchname =>
+ $branches->{ $reserve->{'branchcode'} }->{'branchname'},
+ destbranch => $reserve->{'branchcode'},
+ transfertodo => ( C4::Context->userenv->{'branch'} eq $reserve->{'branchcode'} ? 0 : 1 ),
+ reserved => 1,
+ resbarcode => $barcode,
+ # today => $todaysdate,
+ itemnumber => $reserve->{'itemnumber'},
+ borsurname => $borr->{'surname'},
+ bortitle => $borr->{'title'},
+ borfirstname => $borr->{'firstname'},
+ borrowernumber => $reserve->{'borrowernumber'},
+ borcnum => $borr->{'cardnumber'},
+ borphone => $borr->{'phone'},
+ boraddress => $borr->{'address'},
+ boraddress2 => $borr->{'address2'},
+ borsub => $borr->{'suburb'},
+ borcity => $borr->{'city'},
+ borzip => $borr->{'zipcode'},
+ boremail => $borr->{'email'},
+ debarred => $borr->{'debarred'},
+ gonenoaddress => $borr->{'gonenoaddress'},
+ barcode => $barcode
+ );
+ }
+}
+
+# Error Messages
+my @errmsgloop;
+foreach my $code ( keys %$messages ) {
+
+ # warn $code;
+ my %err;
+ my $exit_required_p = 0;
+ if ( $code eq 'BadBarcode' ) {
+ $err{badbarcode} = 1;
+ $err{msg} = $messages->{'BadBarcode'};