Bugzilla – Attachment 36921 Details for
Bug 13479
Add option to add/remove biblios from list of books with forced item holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13479: Enable/disable forced item holds on biblio level
Bug-13479-Enabledisable-forced-item-holds-on-bibli.patch (text/plain), 8.05 KB, created by
Marcel de Rooy
on 2015-03-16 10:45:43 UTC
(
hide
)
Description:
Bug 13479: Enable/disable forced item holds on biblio level
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-03-16 10:45:43 UTC
Size:
8.05 KB
patch
obsolete
>From 196ef3896d3251ea127d9ae3fbe6a111e803696a Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 5 Mar 2015 15:24:06 +0100 >Subject: [PATCH] Bug 13479: Enable/disable forced item holds on biblio level >Content-Type: text/plain; charset=utf-8 > >This is a follow-up of report 13478. >If you set OPACItemHolds to 'selectiveforce', you can now enable or disable >forced item holds on biblio level on the Holds tab of the staff detail >page. > >TEST PLAN: >[1] Run the adjusted unit test (t/db_dependent/Reserves.t). >[2] Set OPACItemHolds to Allow. >[3] Check the Holds tab of staff catalog detail. > You should not see the Force item holds-box. >[4] Set OPACItemHolds to Selectively force. >[5] Goto the Holds tab of staff catalog detail. >[6] Enable forced item holds. Check behavior with placing hold in OPAC. >[6] Disable forced item holds. Check behavior with placing hold in OPAC. >--- > C4/Reserves.pm | 15 ++++++ > .../prog/en/modules/reserve/request.tt | 44 ++++++++++++++++++ > reserve/request.pl | 1 + > reserve/update_forceitemholds.pl | 47 ++++++++++++++++++++ > t/db_dependent/Reserves.t | 10 ++++- > 5 files changed, 116 insertions(+), 1 deletions(-) > create mode 100755 reserve/update_forceitemholds.pl > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 476f366..22709a0 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -2451,6 +2451,21 @@ sub CheckBiblioForceItemHolds { > return 1 if $rec && $rec->force_item_holds; > } > >+=head2 ModBiblioForceItemHolds >+ >+ This routine updates force_item_holds for a specific biblionumber. >+ It returns true if the update seems to be successful. >+ >+=cut >+ >+sub ModBiblioForceItemHolds { >+ my ( $biblionumber, $newmode ) = @_; >+ my $rec = Koha::Database->new()->schema()->resultset('Biblio')->find( $biblionumber ); >+ return if !$rec; >+ my $rv = $rec->update({ force_item_holds => $newmode? 1: 0 }); >+ return 1 if $rv; >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index db044b5..45691b3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1,3 +1,4 @@ >+[% USE Koha %] > [% USE KohaDates %] > [% INCLUDE 'doc-head-open.inc' %] > [% UNLESS ( multi_hold ) %] >@@ -24,6 +25,12 @@ $(document).ready(function() { > [% IF AutoResumeSuspendedHolds %] > $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1); > [% END %] >+ [% IF biblioloop && biblioloop.0.forceitemhold %] >+ [%# we only check the first biblio (0) because we do not show the form for multiple biblios %] >+ $("#forceitemhold_enabled").toggle(); >+ [% ELSE %] >+ $("#forceitemhold_disabled").toggle(); >+ [% END %] > }); > > function check() { >@@ -98,6 +105,27 @@ function checkMultiHold() { > return true; > } > >+function UpdateForceItemHold(biblio,mode) { >+ $(".forceitemholdbtn").prop("disabled",true); >+ var url = 'update_forceitemholds.pl?biblio=' + biblio+ "&mode=" + mode; >+ var req = $.ajax({ >+ url: url, >+ type: "GET", >+ dataType: "text" >+ }); >+ req.done( function( data, status, obj ) { >+ if( data == '1' ) { >+ $("#forceitemhold_disabled").toggle(); >+ $("#forceitemhold_enabled").toggle(); >+ } >+ $(".forceitemholdbtn").prop("disabled",false); >+ }); >+ req.fail( function( obj, status, err ) { >+ alert('Something went wrong. Please try again later.'); >+ $(".forceitemholdbtn").prop("disabled",false); >+ }); >+} >+ > $(document).ready(function() { > $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic > var itemnumber = this.value; >@@ -207,6 +235,22 @@ function checkMultiHold() { > </div> > [% END %] > >+ [% IF !multi_hold && Koha.Preference('OPACItemHolds')=='selectiveforce' %] >+ <form> >+ <fieldset class="brief"> >+ <label>Force item holds</label> >+ <span id="forceitemhold_disabled" style="display:none;"> >+ <div class="hint">Currently, forced item holds for this biblio are disabled in OPAC.</div> >+ <input type="button" class="forceitemholdbtn" value="Enable" onclick="javascript:return UpdateForceItemHold([% biblioloop.0.biblionumber %],1);" /> >+ </span> >+ <span id="forceitemhold_enabled" style="display:none;"> >+ <div class="hint">Currently, forced item holds for this biblio are enabled in OPAC.</div> >+ <input type="button" class="forceitemholdbtn" value="Disable" onclick="javascript:return UpdateForceItemHold([% biblioloop.0.biblionumber %],0);" /> >+ </span> >+ </fieldset> >+ </form> >+ [% END %] >+ > [% UNLESS ( multi_hold ) %] > <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% title |html %]</a></h1> > [% ELSE %] >diff --git a/reserve/request.pl b/reserve/request.pl >index ce0e70f..ca0bb89 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -582,6 +582,7 @@ foreach my $biblionumber (@biblionumbers) { > $biblioloopiter{title} = $dat->{title}; > $biblioloopiter{rank} = $fixedRank; > $biblioloopiter{reserveloop} = \@reserveloop; >+ $biblioloopiter{forceitemhold} = C4::Reserves::CheckBiblioForceItemHolds( $biblionumber ); > > if (@reserveloop) { > $template->param( reserveloop => \@reserveloop ); >diff --git a/reserve/update_forceitemholds.pl b/reserve/update_forceitemholds.pl >new file mode 100755 >index 0000000..2ac21dd >--- /dev/null >+++ b/reserve/update_forceitemholds.pl >@@ -0,0 +1,47 @@ >+#!/usr/bin/perl >+ >+# Copyright 2015 Koha Development Team >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI qw ( -utf8 ); >+use C4::Auth; >+use C4::Reserves qw//; >+ >+=head1 DESCRIPTION >+ >+Update force item holds for a specific biblio >+ >+=cut >+ >+my $input = new CGI; >+my $biblio = $input->param('biblio')||0; >+my $mode = $input->param('mode'); >+ >+#this statement is for authorization >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "acqui/ajax.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ } >+); >+ >+my $rv = C4::Reserves::ModBiblioForceItemHolds( $biblio, $mode ); >+print $input->header(-type => 'text/plain', -charset => 'UTF-8'); >+print $rv//0; >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index d4be510..d437a69 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 57; >+use Test::More tests => 59; > > use MARC::Record; > use DateTime::Duration; >@@ -522,6 +522,14 @@ isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1, > 'For Allow this bib should return false again'); > #End of tests for CheckBiblioForceItemHolds > >+#Tests for ModBiblioForceItemHolds >+my $temp= C4::Reserves::ModBiblioForceItemHolds( $bibnum, 1); >+is( $temp, 1, 'Test 1 for ModBiblioForceItemHolds'); >+($temp)= $dbh->selectrow_array("SELECT max(biblionumber) FROM biblio"); >+$temp= C4::Reserves::ModBiblioForceItemHolds( $temp+1, 1); >+isnt( $temp, 1, 'Test 2 for ModBiblioForceItemHolds'); >+#End of tests for ModBiblioForceItemHolds >+ > $dbh->rollback; > > sub count_hold_print_messages { >-- >1.7.7.6
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13479
:
36606
|
36608
| 36921