From 2db46671c4684a08764f8fa2d884256e59cc0b76 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 29 Aug 2016 14:13:05 +0200 Subject: [PATCH] Bug 17217: Allow to reserve first available item from a group of titles (OPAC) Depends on bug 15516 Test plan: 0. Run updatedatabase.pl and misc/devel/update_dbix_class_files.pl 1. Go to OPAC search, display some results, click on some checkboxes and click on 'Place hold' button at the top of the results 2. Check the box with label "Place a hold on the first available..." 3. Check that more options appear (Pickup location, hold dates and notes). 4. Click on 'Place hold' 5. Now go to intranet interface and check in an item of one of the reserved biblios and confirm the hold 6. The hold status should have been changed to Waiting, and all other holds should have been deleted --- .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 117 +++++++++++++++------ opac/opac-reserve.pl | 13 +++ 2 files changed, 99 insertions(+), 31 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 8decae4..631c7d3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -2,6 +2,8 @@ [% USE KohaDates %] [% USE Price %] [% USE ItemTypes %] +[% USE Branches %] + [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Placing a hold [% INCLUDE 'doc-head-close.inc' %] @@ -135,6 +137,49 @@ + +
+
+
    +
  • + + +
  • + [% IF ( reserve_in_future ) %] +
  • + + + [% INCLUDE 'date-format.inc' %] +
  • + [% END %] +
  • + + + [% INCLUDE 'date-format.inc' %] +
  • + [% IF ( OpacHoldNotes ) %] +
  • +
    + + + +
    +
  • + [% END # / IF OpacHoldNotes %] +
+
+
[% FOREACH bibitemloo IN bibitemloop %] @@ -504,17 +549,16 @@ }); $(".date-format").each(function(){ - if($(this).hasClass("to")){ var op = "to"; } - if($(this).hasClass("from")){ var op = "from"; } - var bibNum = $(this).data("biblionumber"); - $(this).html("" + _("Clear date") + ""); - }); - - $(".clear-date").on("click",function(e){ - e.preventDefault(); - var fieldID = this.id.replace("clear",""); - var op = $(this).data("op"); - $("#" + op + fieldID).val(""); + var input = $(this).siblings('input').first(); + var clearDateLink = $('') + .attr('href', '#') + .addClass('clear-date') + .html(_("Clear date")) + .on('click', function(e) { + e.preventDefault(); + input.val(''); + }); + $(this).empty().append(clearDateLink); }); // Replace non-JS single-selection with multi-selection capability. @@ -645,27 +689,38 @@ return true; }); - [% FOREACH bibitemloo IN bibitemloop %] - [% IF ( bibitemloo.holdable ) %] - // http://jqueryui.com/demos/datepicker/#date-range - var dates[% bibitemloo.biblionumber %] = $( "#from[% bibitemloo.biblionumber %], #to[% bibitemloo.biblionumber %]" ).datepicker({ - minDate: 0, - changeMonth: true, - numberOfMonths: 1, - onSelect: function( selectedDate ) { - var option = this.id == "from[% bibitemloo.biblionumber %]" ? "minDate" : "maxDate", - instance = $( this ).data( "datepicker" ); - date = $.datepicker.parseDate( - instance.settings.dateFormat || - $.datepicker._defaults.dateFormat, - selectedDate, instance.settings ); - dates[% bibitemloo.biblionumber %].not( this ).datepicker( "option", option, date ); - } - }); - [% END %] - [% END %] - + $('.hold-options').each(function() { + var dates = $(this).find('.holddatefrom, .holddateto').datepicker({ + minDate: 0, + changeMonth: true, + numberOfMonths: 1, + onSelect: function( selectedDate ) { + var option = $(this).hasClass('holddatefrom') ? "minDate" : "maxDate", + instance = $(this).data('datepicker'), + dateFormat = instance.settings.dateFormat + || $.datepicker._defaults.dateFormat, + date = $.datepicker.parseDate(dateFormat, + selectedDate, instance.settings); + + dates.not(this).datepicker('option', option, date); + } + }); + }); }); // ]]> + + [% END %] diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 93773d9..d2591a2 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -135,6 +135,8 @@ my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) $template->param( choose_branch => $OPACChooseBranch); +my $requestany = $query->param('requestany'); + # # # Build hashes of the requested biblio(item)s and items. @@ -221,6 +223,11 @@ if ( $query->param('place_reserve') ) { &get_out($query, $cookie, $template->output); } + my $reserve_group_id; + if ($requestany) { + $reserve_group_id = AddReserveGroup(); + } + my $failed_holds = 0; while (@selectedItems) { my $biblioNum = shift(@selectedItems); @@ -287,11 +294,17 @@ if ( $query->param('place_reserve') ) { # Here we actually do the reserveration. Stage 3. if ($canreserve) { + if ($requestany) { + $startdate = $query->param('reserve_date'); + $expiration_date = $query->param('expiration_date'); + $notes = $query->param('notes'); + } my $reserve_id = AddReserve( $branch, $borrowernumber, $biblioNum, [$biblioNum], $rank, $startdate, $expiration_date, $notes, $biblioData->{title}, $itemNum, $found, $itemtype, + $reserve_group_id, ); $failed_holds++ unless $reserve_id; ++$reserve_cnt; -- 2.1.4