4 #written 2/1/00 by chris@katipo.oc.nz
5 # Copyright 2000-2002 Katipo Communications
6 # Parts Copyright 2011 Catalyst IT
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25 script to place reserves/requests
32 use List::MoreUtils qw( uniq );
33 use Date::Calc qw( Date_to_Days );
34 use C4::Output qw( output_html_with_http_headers );
35 use C4::Auth qw( get_template_and_user );
36 use C4::Reserves qw( RevertWaitingStatus AlterPriority ToggleLowestPriority ToggleSuspend CanBookBeReserved GetMaxPatronHoldsForRecord ItemsAnyAvailableAndNotRestricted CanItemBeReserved IsAvailableForItemLevelRequest );
37 use C4::Items qw( get_hostitemnumbers_of );
38 use C4::Koha qw( getitemtypeimagelocation );
39 use C4::Serials qw( CountSubscriptionFromBiblionumber );
40 use C4::Circulation qw( GetTransfers _GetCircControlBranch GetBranchItemRule );
41 use Koha::DateUtils qw( dt_from_string output_pref );
42 use C4::Utils::DataTables::Members;
43 use C4::Search qw( enabled_staff_search_views );
46 use Koha::DateUtils qw( dt_from_string output_pref );
49 use Koha::CirculationRules;
55 use Koha::BackgroundJob::BatchCancelHold;
57 my $dbh = C4::Context->dbh;
59 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
61 template_name => "reserve/request.tt",
64 flagsrequired => { reserveforothers => 'place_holds' },
68 my $showallitems = $input->param('showallitems');
69 my $pickup = $input->param('pickup');
74 { %{ $_->unblessed }, image_location => $_->image_location }
75 } Koha::ItemTypes->search_with_localization->as_list
78 # Select borrowers infos
79 my $findborrower = $input->param('findborrower');
80 $findborrower = '' unless defined $findborrower;
81 $findborrower =~ s|,| |g;
82 my $findclub = $input->param('findclub');
83 $findclub = '' unless defined $findclub && !$findborrower;
84 my $borrowernumber_hold = $input->param('borrowernumber') || '';
85 my $club_hold = $input->param('club')||'';
90 my $exceeded_maxreserves;
91 my $exceeded_holds_per_record;
93 my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
94 my $action = $input->param('action');
97 if ( $action eq 'move' ) {
98 my $where = $input->param('where');
99 my $reserve_id = $input->param('reserve_id');
100 my $prev_priority = $input->param('prev_priority');
101 my $next_priority = $input->param('next_priority');
102 my $first_priority = $input->param('first_priority');
103 my $last_priority = $input->param('last_priority');
104 my $hold_itemnumber = $input->param('itemnumber');
105 if ( $prev_priority == 0 && $next_priority == 1 ) {
106 C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } );
110 $where, $reserve_id, $prev_priority,
111 $next_priority, $first_priority, $last_priority
115 elsif ( $action eq 'cancel' ) {
116 my $reserve_id = $input->param('reserve_id');
117 my $cancellation_reason = $input->param("cancellation-reason");
118 my $hold = Koha::Holds->find($reserve_id);
119 $hold->cancel( { cancellation_reason => $cancellation_reason } ) if $hold;
121 elsif ( $action eq 'setLowestPriority' ) {
122 my $reserve_id = $input->param('reserve_id');
123 ToggleLowestPriority($reserve_id);
125 elsif ( $action eq 'toggleSuspend' ) {
126 my $reserve_id = $input->param('reserve_id');
127 my $suspend_until = $input->param('suspend_until');
128 ToggleSuspend( $reserve_id, $suspend_until );
130 elsif ( $action eq 'cancelBulk' ) {
131 my $cancellation_reason = $input->param("cancellation-reason");
132 my @hold_ids = split ',', $input->param("ids");
134 reason => $cancellation_reason,
135 hold_ids => \@hold_ids,
137 my $job_id = Koha::BackgroundJob::BatchCancelHold->new->enqueue($params);
146 my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
148 $borrowernumber_hold = $patron->borrowernumber;
150 my $dt_params = { iDisplayLength => -1 };
151 my $results = C4::Utils::DataTables::Members::search(
153 searchmember => $findborrower,
154 dt_params => $dt_params,
157 my $borrowers = $results->{patrons};
158 if ( scalar @$borrowers == 1 ) {
159 $borrowernumber_hold = $borrowers->[0]->{borrowernumber};
160 } elsif ( @$borrowers ) {
161 $template->param( borrowers => $borrowers );
163 $messageborrower = "'$findborrower'";
169 my $club = Koha::Clubs->find( { name => $findclub } );
171 $club_hold = $club->id;
173 my @clubs = Koha::Clubs->search( [
174 { name => { like => '%'.$findclub.'%' } },
175 { description => { like => '%'.$findclub.'%' } }
177 if( scalar @clubs == 1 ) {
178 $club_hold = $clubs[0]->id;
180 $template->param( clubs => \@clubs );
182 $messageclub = "'$findclub'";
187 my @biblionumbers = $input->multi_param('biblionumber');
189 my $multi_hold = @biblionumbers > 1;
191 multi_hold => $multi_hold,
194 # If we have the borrowernumber because we've performed an action, then we
195 # don't want to try to place another reserve.
196 if ($borrowernumber_hold && !$action) {
197 my $patron = Koha::Patrons->find( $borrowernumber_hold );
200 # we check the reserves of the user, and if they can reserve a document
201 # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
203 my $reserves_count = $patron->holds->count;
205 my $new_reserves_count = scalar( @biblionumbers );
207 my $maxreserves = C4::Context->preference('maxreserves');
208 $template->param( maxreserves => $maxreserves );
211 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
213 my $new_reserves_allowed =
214 $maxreserves - $reserves_count > 0
215 ? $maxreserves - $reserves_count
218 $exceeded_maxreserves = 1;
220 new_reserves_allowed => $new_reserves_allowed,
221 new_reserves_count => $new_reserves_count,
222 reserves_count => $reserves_count,
223 maxreserves => $maxreserves,
227 # check if the borrower make the reserv in a different branch
228 if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
232 my $amount_outstanding = $patron->account->balance;
235 diffbranch => $diffbranch,
236 messages => $messages,
237 warnings => $warnings,
238 amount_outstanding => $amount_outstanding,
242 if ($club_hold && !$borrowernumber_hold && !$action) {
243 my $club = Koha::Clubs->find($club_hold);
245 my $enrollments = $club->club_enrollments;
247 my $maxreserves = C4::Context->preference('maxreserves');
248 my $new_reserves_count = scalar( @biblionumbers );
252 while(my $enrollment = $enrollments->next) {
253 next if $enrollment->is_canceled;
254 my $member = { patron => $enrollment->patron };
255 my $reserves_count = $enrollment->patron->holds->count;
257 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
259 $member->{new_reserves_allowed} = $maxreserves - $reserves_count > 0
260 ? $maxreserves - $reserves_count
262 $member->{exceeded_maxreserves} = 1;
264 $member->{amount_outstanding} = $enrollment->patron->account->balance;
265 if ( $enrollment->patron->branchcode ne C4::Context->userenv->{'branch'} ) {
266 $member->{diffbranch} = 1;
269 push @members, $member;
274 members => \@members,
275 maxreserves => $maxreserves,
276 new_reserves_count => $new_reserves_count
280 unless ( $club_hold or $borrowernumber_hold ) {
281 $template->param( clubcount => Koha::Clubs->search->count );
285 messageborrower => $messageborrower,
286 messageclub => $messageclub
289 # Load the hold list if
290 # - we are searching for a patron or club and found one
291 # - we are not searching for anything
292 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold )
293 || ( !$findborrower && !$findclub ) )
295 # FIXME launch another time GetMember perhaps until (Joubu: Why?)
296 my $patron = Koha::Patrons->find( $borrowernumber_hold );
298 if ( $patron && $multi_hold ) {
299 my @multi_pickup_locations =
300 Koha::Biblios->search( { biblionumber => \@biblionumbers } )
301 ->pickup_locations( { patron => $patron } )->as_list;
302 $template->param( multi_pickup_locations => \@multi_pickup_locations );
305 my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
309 $wants_check = $patron->wants_check_for_previous_checkout;
311 my $itemdata_enumchron = 0;
312 my $itemdata_ccode = 0;
314 my $no_reserves_allowed = 0;
315 foreach my $biblionumber (@biblionumbers) {
316 next unless $biblionumber =~ m|^\d+$|;
318 my %biblioloopiter = ();
320 my $biblio = Koha::Biblios->find( $biblionumber );
322 $biblioloopiter{noitems} = 1;
323 $template->param('nobiblio' => 1);
328 { # CanBookBeReserved
329 my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
330 if ( $canReserve->{status} eq 'OK' ) {
332 #All is OK and we can continue
334 elsif ( $canReserve->{status} eq 'noReservesAllowed' || $canReserve->{status} eq 'notReservable' ) {
335 $no_reserves_allowed = 1;
337 elsif ( $canReserve->{status} eq 'tooManyReserves' ) {
338 $exceeded_maxreserves = 1;
339 $template->param( maxreserves => $canReserve->{limit} );
341 elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) {
342 $exceeded_holds_per_record = 1;
343 $biblioloopiter{ $canReserve->{status} } = 1;
345 elsif ( $canReserve->{status} eq 'ageRestricted' ) {
346 $template->param( $canReserve->{status} => 1 );
347 $biblioloopiter{ $canReserve->{status} } = 1;
349 elsif ( $canReserve->{status} eq 'alreadypossession' ) {
350 $template->param( $canReserve->{status} => 1);
351 $biblioloopiter{ $canReserve->{status} } = 1;
354 $biblioloopiter{ $canReserve->{status} } = 1;
358 # For multiple holds per record, if a patron has previously placed a hold,
359 # the patron can only place more holds of the same type. That is, if the
360 # patron placed a record level hold, all the holds the patron places must
361 # be record level. If the patron placed an item level hold, all holds
362 # the patron places must be item level
363 my $holds = Koha::Holds->search(
365 borrowernumber => $patron->borrowernumber,
366 biblionumber => $biblionumber,
370 $template->param( force_hold_level => $holds->forced_hold_level() );
372 # For a librarian to be able to place multiple record holds for a patron for a record,
373 # we must find out what the maximum number of holds they can place for the patron is
374 my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
375 my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
376 $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
377 $template->param( max_holds_for_record => $max_holds_for_record );
378 $template->param( remaining_holds_for_record => $remaining_holds_for_record );
381 # adding a fixed value for priority options
382 my $fixedRank = $biblio->holds->count + 1;
384 my @items = $biblio->items->as_list;
386 my @host_items = $biblio->host_items->as_list;
388 push @items, @host_items;
392 # FIXME Then why do we continue?
393 $template->param('noitems' => 1) unless ( $multi_hold );
394 $biblioloopiter{noitems} = 1;
397 if ( $club_hold or $borrowernumber_hold ) {
398 my @available_itemtypes;
399 my $num_available = 0;
400 my $num_override = 0;
402 my $num_alreadyheld = 0;
404 # iterating through all items first to check if any of them available
405 # to pass this value further inside down to IsAvailableForItemLevelRequest to
406 # it's complicated logic to analyse.
407 # (before this loop was inside that sub loop so it was O(n^2) )
408 my $items_any_available;
409 $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblio->biblionumber, patron => $patron })
412 for my $item_object ( @items ) {
414 my $item = $item_object->unblessed;
416 $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
417 if ( $do_check && $wants_check ) {
418 $item->{checked_previously} = $do_check;
420 $biblioloopiter{checked_previously} = $do_check;
422 $template->param( checked_previously => $do_check );
427 $item->{itemtype} = $itemtypes->{ $item_object->effective_itemtype };
429 if($item->{biblionumber} ne $biblio->biblionumber){
430 $item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title;
433 # if the item is currently on loan, we display its return date and
434 # change the background color
435 my $issue = $item_object->checkout;
436 if ( $issue ) { # FIXME must be moved to the template
437 $item->{date_due} = $issue->date_due;
438 $item->{backgroundcolor} = 'onloan';
442 my $holds = $item_object->current_holds;
443 if ( my $first_hold = $holds->next ) {
444 my $p = Koha::Patrons->find( $first_hold->borrowernumber );
446 $item->{backgroundcolor} = 'reserved';
447 $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
448 $item->{ReservedFor} = $p;
449 $item->{ExpectedAtLibrary} = $first_hold->branchcode;
450 $item->{waitingdate} = $first_hold->waitingdate;
453 # Management of the notforloan document
454 if ( $item->{notforloan} ) {
455 $item->{backgroundcolor} = 'other';
458 # Management of lost or long overdue items
459 if ( $item->{itemlost} ) {
460 $item->{backgroundcolor} = 'other';
461 if ($logged_in_patron->category->hidelostitems && !$showallitems) {
467 # Check the transit status
468 my ( $transfertwhen, $transfertfrom, $transfertto ) =
469 GetTransfers($item_object->itemnumber); # FIXME replace with get_transfer
471 if ( defined $transfertwhen && $transfertwhen ne '' ) {
472 $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
473 $item->{transfertfrom} = $transfertfrom;
474 $item->{transfertto} = $transfertto;
475 $item->{nocancel} = 1;
478 # If there is no loan, return and transfer, we show a checkbox.
479 $item->{notforloan} ||= 0;
481 # if independent branches is on we need to check if the person can reserve
482 # for branches they arent logged in to
483 if ( C4::Context->preference("IndependentBranches") ) {
484 if (! C4::Context->preference("canreservefromotherbranches")){
485 # can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve
486 my $userenv = C4::Context->userenv;
487 unless ( C4::Context->IsSuperLibrarian ) {
488 $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
494 my $patron_unblessed = $patron->unblessed;
495 my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
497 my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
499 $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
501 my $can_item_be_reserved = CanItemBeReserved( $patron, $item_object )->{status};
502 $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
504 $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
507 !$item->{cantreserve}
508 && !$exceeded_maxreserves
509 && $can_item_be_reserved eq 'OK'
510 # items_any_available defined outside of the current loop,
511 # so we avoiding loop inside IsAvailableForItemLevelRequest:
512 && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available)
515 # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
516 my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
517 $item->{pickup_locations_count} = $pickup_locations->count;
518 if ( $item->{pickup_locations_count} > 0 ) {
520 $item->{available} = 1;
521 # pass the holding branch for use as default
522 my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next;
523 $item->{default_pickup_location} = $default_pickup_location;
526 $item->{available} = 0;
527 $item->{not_holdable} = "no_valid_pickup_location";
530 push( @available_itemtypes, $item->{itype} );
532 elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
533 # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
534 # with the exception of itemAlreadyOnHold because, you know, the item is already on hold
535 if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) {
536 # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
537 my @pickup_locations = $item_object->pickup_locations({ patron => $patron })->as_list;
538 $item->{pickup_locations_count} = scalar @pickup_locations;
540 if ( @pickup_locations ) {
542 $item->{available} = 1;
544 my $default_pickup_location;
546 # Default to logged-in, if valid
547 if ( C4::Context->userenv->{branch} ) {
548 ($default_pickup_location) = grep { $_->branchcode eq C4::Context->userenv->{branch} } @pickup_locations;
551 $item->{default_pickup_location} = $default_pickup_location;
554 $item->{available} = 0;
555 $item->{not_holdable} = "no_valid_pickup_location";
557 } else { $num_alreadyheld++ }
559 push( @available_itemtypes, $item->{itype} );
562 # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
564 # Show serial enumeration when needed
565 if ($item->{enumchron}) {
566 $itemdata_enumchron = 1;
568 # Show collection when needed
569 if ($item->{ccode}) {
574 push @{ $biblioloopiter{itemloop} }, $item;
577 $biblioloopiter{biblioitem} = $biblio->biblioitem;
579 # While we can't override an alreay held item, we should be able to override the others
580 # Unless all items are already held
581 if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioloopiter{itemloop} } ) ) {
582 # That is, if all items require an override
583 $template->param( override_required => 1 );
584 } elsif ( $num_available == 0 ) {
585 $template->param( none_available => 1 );
586 $biblioloopiter{warn} = 1;
587 $biblioloopiter{none_avail} = 1;
589 $template->param( hiddencount => $hiddencount);
591 @available_itemtypes = uniq( @available_itemtypes );
592 $template->param( available_itemtypes => \@available_itemtypes );
595 # existingreserves building
597 my $always_show_holds = $input->cookie('always_show_holds');
598 $template->param( always_show_holds => $always_show_holds );
599 my $show_holds_now = $input->param('show_holds_now');
600 unless( (defined $always_show_holds && $always_show_holds eq 'DONT') && !$show_holds_now ){
601 my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } )->as_list;
604 my $a_found = $a->found() || '';
605 my $b_found = $a->found() || '';
606 $a_found cmp $b_found;
611 if ( $res->is_found() ) {
612 $reserve{'holdingbranch'} = $res->item()->holdingbranch();
613 $reserve{'biblionumber'} = $res->item()->biblionumber();
614 $reserve{'barcodenumber'} = $res->item()->barcode();
615 $reserve{'wbrcode'} = $res->branchcode();
616 $reserve{'itemnumber'} = $res->itemnumber();
617 $reserve{'wbrname'} = $res->branch()->branchname();
618 $reserve{'atdestination'} = $res->is_at_destination();
619 $reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ;
620 $reserve{'found'} = $res->is_found();
621 $reserve{'inprocessing'} = $res->is_in_processing();
622 $reserve{'intransit'} = $res->is_in_transit();
624 elsif ( $res->priority() > 0 ) {
625 if ( my $item = $res->item() ) {
626 $reserve{'itemnumber'} = $item->id();
627 $reserve{'barcodenumber'} = $item->barcode();
628 $reserve{'item_level_hold'} = 1;
632 $reserve{'expirationdate'} = $res->expirationdate;
633 $reserve{'date'} = $res->reservedate;
634 $reserve{'borrowernumber'} = $res->borrowernumber();
635 $reserve{'biblionumber'} = $res->biblionumber();
636 $reserve{'patron'} = $res->borrower;
637 $reserve{'notes'} = $res->reservenotes();
638 $reserve{'waiting_date'} = $res->waitingdate();
639 $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef;
640 $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef;
641 $reserve{'priority'} = $res->priority();
642 $reserve{'lowestPriority'} = $res->lowestPriority();
643 $reserve{'suspend'} = $res->suspend();
644 $reserve{'suspend_until'} = $res->suspend_until();
645 $reserve{'reserve_id'} = $res->reserve_id();
646 $reserve{itemtype} = $res->itemtype();
647 $reserve{branchcode} = $res->branchcode();
648 $reserve{non_priority} = $res->non_priority();
649 $reserve{object} = $res;
651 push( @reserveloop, \%reserve );
655 # get the time for the form name...
660 fixedRank => $fixedRank,
665 itemdata_enumchron => $itemdata_enumchron,
666 itemdata_ccode => $itemdata_ccode,
668 biblionumber => $biblionumber,
669 findborrower => $findborrower,
672 C4::Search::enabled_staff_search_views,
675 $biblioloopiter{biblionumber} = $biblionumber;
676 $biblioloopiter{title} = $biblio->title;
677 $biblioloopiter{author} = $biblio->author;
678 $biblioloopiter{rank} = $fixedRank;
679 $biblioloopiter{reserveloop} = \@reserveloop;
682 $template->param( reserveloop => \@reserveloop );
686 # Add the valid pickup locations
687 my @pickup_locations = $biblio->pickup_locations({ patron => $patron })->as_list;
688 $biblioloopiter{pickup_locations} = \@pickup_locations;
689 $biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ];
692 push @biblioloop, \%biblioloopiter;
695 $template->param( biblioloop => \@biblioloop );
696 $template->param( no_reserves_allowed => $no_reserves_allowed );
697 $template->param( exceeded_maxreserves => $exceeded_maxreserves );
698 $template->param( exceeded_holds_per_record => $exceeded_holds_per_record );
699 # FIXME: getting just the first bib's result doesn't seem right
700 $template->param( subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumbers[0]));
701 } elsif ( ! $multi_hold ) {
702 my $biblio = Koha::Biblios->find( $biblionumbers[0] );
703 $template->param( biblio => $biblio );
705 $template->param( biblionumbers => \@biblionumbers );
707 # pass the userenv branch if no pickup location selected
708 $template->param( pickup => $pickup || C4::Context->userenv->{branch} );
710 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
711 $template->param( reserve_in_future => 1 );
715 SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
716 AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
717 borrowernumber => $borrowernumber_hold,
721 output_html_with_http_headers $input, $cookie, $template->output;
723 sub sort_borrowerlist {
724 my $borrowerslist = shift;
727 uc( $a->{surname} . $a->{firstname} ) cmp
728 uc( $b->{surname} . $b->{firstname} )