From 29885d8c30a7354db7e75c882a38c0b348d66725 Mon Sep 17 00:00:00 2001 From: Nicolas Legrand Date: Mon, 13 Jan 2020 17:56:41 +0100 Subject: [PATCH] Bug 24412: Attach waiting reserve to desk When an item is checked in and marked 'Waiting' or already 'Waiting' and there is a desk attached to the session, the item is marked waiting at the current desk of the current library. The information is displayed on the OPAC and on the intranet. The patron can then know at which desk he can retrieve his document. Desk Management (Bug 13881) is now useful. Test plan : 1. apply Bug 24201 2. $KOHA_PATH/installer/data/mysql/updatedatabase.pl 3. Check out some document to someone 4. make another one reserve this document 5. check in the document 6. you can see the document is attach to the current library 7. create some desks and attach one to your session (see Bug 13881 and Bug 24201) 8. cancel the preceding reserve and redo steps 3 to 5 9. you should see the document is waiting at the current library and current desk on: a. the intranet document request page b. the intranet borrower holds tab c. the item list where the document is listed on the bibliographic details d. the borrower's OPAC holds tab. Signed-off-by: Martin Renvoize --- C4/Reserves.pm | 6 +++--- Koha/Hold.pm | 19 ++++++++++++++++++- Koha/Template/Plugin/Desks.pm | 14 ++++++++++++++ circ/returns.pl | 5 +++-- .../prog/en/includes/holds_table.inc | 3 ++- .../prog/en/includes/waiting_holds.inc | 3 ++- .../prog/en/modules/catalogue/detail.tt | 3 ++- .../prog/en/modules/circ/returns.tt | 3 ++- koha-tmpl/intranet-tmpl/prog/js/holds.js | 8 +++++++- .../bootstrap/en/includes/holds-table.inc | 5 ++++- reserve/request.pl | 1 + svc/holds | 1 + 12 files changed, 59 insertions(+), 12 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 2422d4facd..957566dcd4 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1122,7 +1122,7 @@ sub ModReserveStatus { =head2 ModReserveAffect - &ModReserveAffect($itemnumber,$borrowernumber,$diffBranchSend,$reserve_id); + &ModReserveAffect($itemnumber,$borrowernumber,$diffBranchSend,$reserve_id, $desk_id); This function affect an item and a status for a given reserve, either fetched directly by record_id, or by borrowernumber and itemnumber or biblionumber. If only biblionumber @@ -1136,7 +1136,7 @@ take care of the waiting status =cut sub ModReserveAffect { - my ( $itemnumber, $borrowernumber, $transferToDo, $reserve_id ) = @_; + my ( $itemnumber, $borrowernumber, $transferToDo, $reserve_id, $desk_id ) = @_; my $dbh = C4::Context->dbh; # we want to attach $itemnumber to $borrowernumber, find the biblionumber @@ -1161,7 +1161,7 @@ sub ModReserveAffect { my $already_on_shelf = $hold->found && $hold->found eq 'W'; $hold->itemnumber($itemnumber); - $hold->set_waiting($transferToDo); + $hold->set_waiting($transferToDo, $desk_id); if( !$transferToDo ){ _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf; diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 360b43e7b5..fe1745bb61 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -158,7 +158,7 @@ sub delete { =cut sub set_waiting { - my ( $self, $transferToDo ) = @_; + my ( $self, $transferToDo, $desk_id ) = @_; $self->priority(0); @@ -171,8 +171,11 @@ sub set_waiting { my $values = { found => 'W', waitingdate => $today->ymd, + desk_id => $desk_id, }; + if (defined $desk_id) { $values->{'desk_id'} = $desk_id }; + my $requested_expiration; if ($self->expirationdate) { $requested_expiration = dt_from_string($self->expirationdate); @@ -321,6 +324,20 @@ sub branch { return $self->{_branch}; } +=head3 desk + +Returns the related Koha::Library object for this Hold + +=cut + +sub desk { + my ($self) = @_; + + $self->{_desk} ||= Koha::Desks->find( $self->desk_id() ); + + return $self->{_desk}; +} + =head3 borrower Returns the related Koha::Patron object for this Hold diff --git a/Koha/Template/Plugin/Desks.pm b/Koha/Template/Plugin/Desks.pm index 58e100163d..0817948fcd 100644 --- a/Koha/Template/Plugin/Desks.pm +++ b/Koha/Template/Plugin/Desks.pm @@ -36,6 +36,20 @@ got or the current one. =head2 Methods +=head3 GetName + +[% Desk.GetName(desk_id) %] + +return desk name or empty string + +=cut + +sub GetName { + my ( $self, $desk_id ) = @_; + my $d = Koha::Desks->find( $desk_id ); + return (defined $d) ? $d->unblessed->{'desk_name'} : q{}; +} + =head3 GetLoggedInDeskId [% Desks.GetLoggedInDeskId %] diff --git a/circ/returns.pl b/circ/returns.pl index a7556c7b07..3020b849e2 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -71,6 +71,7 @@ my ( $template, $librarian, $cookie, $flags ) = get_template_and_user( my $sessionID = $query->cookie("CGISESSID"); my $session = get_session($sessionID); +my $desk_id = C4::Context->userenv->{"desk_id"} || ''; # Print a reserve slip on this page if ( $query->param('print_slip') ) { @@ -155,7 +156,7 @@ if ( $query->param('reserve_id') ) { my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef; # diffBranchSend tells ModReserveAffect whether document is expected in this library or not, # i.e., whether to apply waiting status - ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id ); + ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id ); } # check if we have other reserves for this document, if we have a return send the message of transfer my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); @@ -415,7 +416,7 @@ if ( $messages->{'ResFound'}) { my $biblio = $item->biblio; my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef; - ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} ); + ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id ); my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber}); $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index febcf4e1a7..9f59621aa5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -1,6 +1,7 @@ [% USE Koha %] [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] [% USE AuthorisedValues %] +[% USE Desks %] [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] @@ -121,7 +122,7 @@ [% IF ( hold.found ) %] [% IF ( hold.atdestination ) %] [% IF ( hold.found ) %] - Item waiting at [% hold.wbrname | html %] since [% hold.waiting_date | $KohaDates %] + Item waiting at [% hold.wbrname | html %][% IF hold.desk_name %], [% hold.desk_name | html %],[% END %] since [% hold.waiting_date | $KohaDates %] [% ELSE %] Waiting to be pulled [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc index 90cb36856a..850368a289 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc @@ -1,4 +1,5 @@ [% USE ItemTypes %] +[% USE Desks %] [% USE AuthorisedValues %]
@@ -38,7 +39,7 @@ [% END %] - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 239f4f5b07..d16e1ac1e0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -4,6 +4,7 @@ [% USE KohaDates %] [% USE AuthorisedValues %] [% USE Branches %] +[% USE Desks %] [% USE Biblio %] [% USE TablesSettings %] [% PROCESS 'i18n.inc' %] @@ -443,7 +444,7 @@ Note that permanent location is a code, and location may be an authval. [% SET hold = item.first_hold %] [% IF hold %] [% IF hold.waitingdate %] - Waiting at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %]. + Waiting at [% Branches.GetName( hold.branchcode ) | html %][% IF ( hold.desk_id ) %], [% Desks.GetName ( hold.desk_id ) | html %][% END %] since [% hold.waitingdate | $KohaDates %]. [% IF canreservefromotherbranches AND ( hold.waitingdate OR hold.priority == 1 ) %] Hold for: [% INCLUDE 'patron-title.inc' patron=hold.borrower hide_patron_infos_if_needed=1 %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 1e1ca7d2ff..e76838289f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -2,6 +2,7 @@ [% USE Asset %] [% USE KohaDates %] [% USE Branches %] +[% USE Desks %] [% USE Koha %] [% USE ItemTypes %] [% USE AuthorisedValues %] @@ -461,7 +462,7 @@ - diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js index 41d47624e0..f056c8a81f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js @@ -159,9 +159,15 @@ $(document).ready(function() { if ( oObj.waiting_here ) { data += ITEM_IS_WAITING_HERE; + if (oObj.desk_name) { + data += ", " + AT.format( oObj.desk_name ); + } } else { data += ITEM_IS_WAITING; - data += " " + AT.format( oObj.waiting_at ); + data += AT.format( oObj.waiting_at ); + if (oObj.desk_name) { + data += ", " + AT.format( oObj.desk_name ); + } } } else if ( oObj.transferred ) { diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc index b28327605f..20c3a56922 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -1,4 +1,5 @@ [% USE Branches %] +[% USE Desks %] [% USE ItemTypes %] [% USE KohaDates %] @@ -105,7 +106,9 @@ [% IF ( HOLD.is_at_destination ) %] [% IF ( HOLD.found ) %] - Item waiting at [% HOLD.branch.branchname | html %] + + Item waiting at [% HOLD.branch.branchname | html %][% IF ( HOLD.desk_id ) %], [% Desks.GetName ( HOLD.desk_id ) | html %],[% END %] + [% IF ( HOLD.waitingdate ) %] since [% HOLD.waitingdate | $KohaDates %] [% IF HOLD.expirationdate %] diff --git a/reserve/request.pl b/reserve/request.pl index 688cb82d97..ea02b67595 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -663,6 +663,7 @@ foreach my $biblionumber (@biblionumbers) { $reserve{'wbrcode'} = $res->branchcode(); $reserve{'itemnumber'} = $res->itemnumber(); $reserve{'wbrname'} = $res->branch()->branchname(); + $reserve{'desk_name'} = $res->desk()->desk_name(); if ( $reserve{'holdingbranch'} eq $reserve{'wbrcode'} ) { diff --git a/svc/holds b/svc/holds index 37254b6407..555298f675 100755 --- a/svc/holds +++ b/svc/holds @@ -97,6 +97,7 @@ while ( my $h = $holds_rs->next() ) { reserve_id => $h->reserve_id(), branchcode => $h->branch()->branchname(), branches => $libraries, + desk_name => $h->desk()->desk_name(), reservedate => $h->reservedate(), expirationdate => $h->expirationdate(), suspend => $h->suspend(), -- 2.20.1
[% Branches.GetName( reserveloo.item.homebranch ) | html %][% Branches.GetName( reserveloo.item.holdingbranch ) | html %][% Branches.GetName( reserveloo.item.holdingbranch ) | html %][% IF (reserveloo.desk_id ) %], [% Desks.GetName (reserveloo.desk_id) | html %][% END %] [% AuthorisedValues.GetByCode('LOC', reserveloo.item.location) | html %] [% reserveloo.item.itemcallnumber | html %] [% reserveloo.item.copynumber | html %]