From 47b32572d4d9c3195cf52ba02f1b6f845173c173 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Séverine QUEUNE Signed-off-by: Martin Renvoize Bug 24412: (follow-up) QA Following Josef Moravec QA comments : - rewrite Koha::Hold->desk according to Object Oriented Koha Guidelines and use it to fetch desk name in various templates - remove unused Desks.GetName - Check for columns existence in db update Signed-off-by: Martin Renvoize Signed-off-by: Séverine QUEUNE Signed-off-by: Martin Renvoize Bug 24412: (follow-up) QA: useless change Maybe it was a relic of something usefull... anyway not anymore. Signed-off-by: Martin Renvoize Signed-off-by: Séverine QUEUNE Signed-off-by: Martin Renvoize Bug 24412: (follow-up) Fix POD Koha::Desk and not Koha::Library... Signed-off-by: Jonathan Druart --- C4/Reserves.pm | 6 ++--- Koha/Hold.pm | 16 +++++++++++- circ/returns.pl | 5 ++-- ..._24412_Attach_waiting_reserve_to_desk.perl | 25 ++++++++++--------- .../prog/en/includes/holds_table.inc | 2 +- .../prog/en/includes/waiting_holds.inc | 2 +- .../prog/en/modules/catalogue/detail.tt | 2 +- koha-tmpl/intranet-tmpl/prog/js/holds.js | 7 ++++++ .../bootstrap/en/includes/holds-table.inc | 1 + reserve/request.pl | 1 + svc/holds | 1 + 11 files changed, 47 insertions(+), 21 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index f379cec8ae..fbd42f0be4 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1136,7 +1136,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 @@ -1150,7 +1150,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 @@ -1183,7 +1183,7 @@ sub ModReserveAffect { && !$already_on_shelf) { $hold->set_processing(); } else { - $hold->set_waiting(); + $hold->set_waiting($desk_id); _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf; my $transfers = Koha::Item::Transfers->search({ itemnumber => $itemnumber, diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 921906a07b..4bd087d64d 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -175,7 +175,7 @@ sub set_transfer { =cut sub set_waiting { - my ( $self ) = @_; + my ( $self, $desk_id ) = @_; $self->priority(0); @@ -183,6 +183,7 @@ sub set_waiting { my $values = { found => 'W', waitingdate => $today->ymd, + desk_id => $desk_id, }; my $requested_expiration; @@ -365,6 +366,19 @@ sub branch { return $self->{_branch}; } +=head3 desk + +Returns the related Koha::Desk object for this Hold + +=cut + +sub desk { + my $self = shift; + my $desk_rs = $self->_result->desk; + return unless $desk_rs; + return Koha::Desk->_new_from_dbic($desk_rs); +} + =head3 borrower Returns the related Koha::Patron object for this Hold diff --git a/circ/returns.pl b/circ/returns.pl index bd59f6c357..d9a5dc0160 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); @@ -422,7 +423,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/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl b/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl index c743eab7f3..9242ffbd3d 100644 --- a/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl +++ b/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl @@ -1,16 +1,17 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - # you can use $dbh here like: - $dbh->do(q{ -ALTER TABLE reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode, - ADD KEY desk_id (`desk_id`), - ADD CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE CASCADE ON UPDATE CASCADE ; - }); - $dbh->do(q{ -ALTER TABLE old_reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode, - ADD KEY `old_desk_id` (`desk_id`); - }); + if ( !column_exists( 'reserves', 'desk_id' ) ) { + $dbh->do(q{ + ALTER TABLE reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode, + ADD KEY desk_id (`desk_id`), + ADD CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE CASCADE ON UPDATE CASCADE ; + }); + $dbh->do(q{ + ALTER TABLE old_reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode, + ADD KEY `old_desk_id` (`desk_id`); + }); - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug XXXXX - Attach waiting reserve to desk)\n"; + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - Attach waiting reserve to desk)\n"; + } } 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 40b28e3954..2e1a49d683 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -122,7 +122,7 @@ [% IF ( hold.found ) %] [% IF ( hold.atdestination ) %] - 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 %] [% ELSIF (hold.intransit) %] Item being transferred to [% hold.wbrname | html %] [% ELSIF (hold.inprocessing) %] 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 4b294d33e7..a7ef638daa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc @@ -37,7 +37,7 @@ [% END %] [% 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.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => reserveloo.item.location) | html %] [% reserveloo.item.itemcallnumber | html %] [% reserveloo.item.copynumber | html %] 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 1f9d0241dc..5c0f779436 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -461,7 +461,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 ) %], [% hold.desk.desk_name | 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/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js index 3a4e129147..59dcfd893a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js @@ -161,9 +161,16 @@ $(document).ready(function() { if ( oObj.waiting_here ) { data += __("Item is waiting here"); + if (oObj.desk_name) { + data += ", " + __("at %s").format( oObj.desk_name ); + } } else { data += __("Item is waiting"); data += " " + __("at %s").format(oObj.waiting_at); + if (oObj.desk_name) { + data += ", " + __("at %s").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 1be95994cf..b4068f306e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -100,6 +100,7 @@ [% IF ( HOLD.is_at_destination ) %] 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 bb7d91e68b..f631556228 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -658,6 +658,7 @@ foreach my $biblionumber (@biblionumbers) { $reserve{'itemnumber'} = $res->itemnumber(); $reserve{'wbrname'} = $res->branch()->branchname(); $reserve{'atdestination'} = $res->is_at_destination(); + $reserve{'desk_name'} = $res->desk()->desk_name(); $reserve{'found'} = $res->is_found(); $reserve{'inprocessing'} = $res->is_in_processing(); $reserve{'intransit'} = $res->is_in_transit(); diff --git a/svc/holds b/svc/holds index 1a2fc337cb..5a60f3c0e4 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.39.5