- if (( $basket->{authorisedby}
- && $basket->{authorisedby} eq $loggedinuser
- )
- || haspermission( $uid, { flagsrequired => { acquisition => q{*} } } )
- ) {
- for my $date_field (qw( creationdate closedate)) {
- if ( $basket->{$date_field} ) {
- $basket->{$date_field} =
- format_date( $basket->{$date_field} );
- }
+ my $authorisedby = $basket->{authorisedby};
+ my $basketbranch = ''; # set a blank branch to start with
+ my $member = GetMember( borrowernumber => $authorisedby );
+ if ( $member ) {
+ $basketbranch = $member->{branchcode};
+ }
+
+ if ($userenv->{'flags'} & 1 || #user is superlibrarian
+ (haspermission( $uid, { acquisition => q{*} } ) && #user has acq permissions and
+ ($viewbaskets eq 'all' || #user is allowed to see all baskets
+ ($viewbaskets eq 'branch' && $authorisedby && $userbranch eq $basketbranch) || #basket belongs to user's branch
+ ($basket->{authorisedby} && $viewbaskets eq 'user' && $authorisedby == $loggedinuser) #user created this basket
+ )
+ )
+ ) {
+ foreach (qw(total_items total_biblios expected_items)) {
+ $basket->{$_} ||= 0;
+ }
+ if($member) {
+ $basket->{authorisedby_firstname} = $member->{firstname};
+ $basket->{authorisedby_surname} = $member->{surname};