View | Details | Raw Unified | Return to bug 13479
Collapse All | Expand All

(-)a/C4/Reserves.pm (+15 lines)
Lines 2451-2456 sub CheckBiblioForceItemHolds { Link Here
2451
    return 1 if $rec && $rec->force_item_holds;
2451
    return 1 if $rec && $rec->force_item_holds;
2452
}
2452
}
2453
2453
2454
=head2 ModBiblioForceItemHolds
2455
2456
    This routine updates force_item_holds for a specific biblionumber.
2457
    It returns true if the update seems to be successful.
2458
2459
=cut
2460
2461
sub ModBiblioForceItemHolds {
2462
    my ( $biblionumber, $newmode ) = @_;
2463
    my $rec = Koha::Database->new()->schema()->resultset('Biblio')->find( $biblionumber );
2464
    return if !$rec;
2465
    my $rv = $rec->update({ force_item_holds => $newmode? 1: 0 });
2466
    return 1 if $rv;
2467
}
2468
2454
=head1 AUTHOR
2469
=head1 AUTHOR
2455
2470
2456
Koha Development Team <http://koha-community.org/>
2471
Koha Development Team <http://koha-community.org/>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+44 lines)
Lines 1-3 Link Here
1
[% USE Koha %]
1
[% USE KohaDates %]
2
[% USE KohaDates %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% UNLESS ( multi_hold ) %]
4
[% UNLESS ( multi_hold ) %]
Lines 24-29 $(document).ready(function() { Link Here
24
    [% IF AutoResumeSuspendedHolds %]
25
    [% IF AutoResumeSuspendedHolds %]
25
        $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
26
        $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
26
    [% END %]
27
    [% END %]
28
    [% IF biblioloop && biblioloop.0.forceitemhold %]
29
        [%# we only check the first biblio (0) because we do not show the form for multiple biblios %]
30
        $("#forceitemhold_enabled").toggle();
31
    [% ELSE %]
32
        $("#forceitemhold_disabled").toggle();
33
    [% END %]
27
});
34
});
28
35
29
function check() {
36
function check() {
Lines 98-103 function checkMultiHold() { Link Here
98
    return true;
105
    return true;
99
}
106
}
100
107
108
function UpdateForceItemHold(biblio,mode) {
109
    $(".forceitemholdbtn").prop("disabled",true);
110
    var url = 'update_forceitemholds.pl?biblio=' + biblio+ "&mode=" + mode;
111
    var req = $.ajax({
112
        url: url,
113
        type: "GET",
114
        dataType: "text"
115
    });
116
    req.done( function( data, status, obj ) {
117
        if( data == '1' ) {
118
            $("#forceitemhold_disabled").toggle();
119
            $("#forceitemhold_enabled").toggle();
120
        }
121
        $(".forceitemholdbtn").prop("disabled",false);
122
    });
123
    req.fail( function( obj, status, err ) {
124
        alert('Something went wrong. Please try again later.');
125
        $(".forceitemholdbtn").prop("disabled",false);
126
    });
127
}
128
101
 $(document).ready(function() {
129
 $(document).ready(function() {
102
    $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
130
    $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
103
        var itemnumber = this.value;
131
        var itemnumber = this.value;
Lines 207-212 function checkMultiHold() { Link Here
207
		</div>
235
		</div>
208
  [% END %]
236
  [% END %]
209
237
238
  [% IF !multi_hold && Koha.Preference('OPACItemHolds')=='selectiveforce' %]
239
    <form>
240
      <fieldset class="brief">
241
        <label>Force item holds</label>
242
        <span id="forceitemhold_disabled" style="display:none;">
243
          <div class="hint">Currently, forced item holds for this biblio are disabled in OPAC.</div>
244
          <input type="button" class="forceitemholdbtn" value="Enable" onclick="javascript:return UpdateForceItemHold([% biblioloop.0.biblionumber %],1);" />
245
        </span>
246
        <span id="forceitemhold_enabled" style="display:none;">
247
          <div class="hint">Currently, forced item holds for this biblio are enabled in OPAC.</div>
248
          <input type="button" class="forceitemholdbtn" value="Disable" onclick="javascript:return UpdateForceItemHold([% biblioloop.0.biblionumber %],0);" />
249
        </span>
250
      </fieldset>
251
    </form>
252
  [% END %]
253
210
  [% UNLESS ( multi_hold ) %]
254
  [% UNLESS ( multi_hold ) %]
211
    <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% title |html %]</a></h1>
255
    <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% title |html %]</a></h1>
212
  [% ELSE %]
256
  [% ELSE %]
(-)a/reserve/request.pl (+1 lines)
Lines 582-587 foreach my $biblionumber (@biblionumbers) { Link Here
582
    $biblioloopiter{title} = $dat->{title};
582
    $biblioloopiter{title} = $dat->{title};
583
    $biblioloopiter{rank} = $fixedRank;
583
    $biblioloopiter{rank} = $fixedRank;
584
    $biblioloopiter{reserveloop} = \@reserveloop;
584
    $biblioloopiter{reserveloop} = \@reserveloop;
585
    $biblioloopiter{forceitemhold} = C4::Reserves::CheckBiblioForceItemHolds( $biblionumber );
585
586
586
    if (@reserveloop) {
587
    if (@reserveloop) {
587
        $template->param( reserveloop => \@reserveloop );
588
        $template->param( reserveloop => \@reserveloop );
(-)a/reserve/update_forceitemholds.pl (+47 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2015 Koha Development Team
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI qw ( -utf8 );
23
use C4::Auth;
24
use C4::Reserves qw//;
25
26
=head1 DESCRIPTION
27
28
Update force item holds for a specific biblio
29
30
=cut
31
32
my $input = new CGI;
33
my $biblio   = $input->param('biblio')||0;
34
my $mode     = $input->param('mode');
35
36
#this statement is for authorization
37
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38
    {   template_name   => "acqui/ajax.tt",
39
        query           => $input,
40
        type            => "intranet",
41
        authnotrequired => 0,
42
    }
43
);
44
45
my $rv = C4::Reserves::ModBiblioForceItemHolds( $biblio, $mode );
46
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
47
print $rv//0;
(-)a/t/db_dependent/Reserves.t (-2 / +9 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 57;
20
use Test::More tests => 59;
21
21
22
use MARC::Record;
22
use MARC::Record;
23
use DateTime::Duration;
23
use DateTime::Duration;
Lines 522-527 isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1, Link Here
522
    'For Allow this bib should return false again');
522
    'For Allow this bib should return false again');
523
#End of tests for CheckBiblioForceItemHolds
523
#End of tests for CheckBiblioForceItemHolds
524
524
525
#Tests for ModBiblioForceItemHolds
526
my $temp= C4::Reserves::ModBiblioForceItemHolds( $bibnum, 1);
527
is( $temp, 1, 'Test 1 for ModBiblioForceItemHolds');
528
($temp)= $dbh->selectrow_array("SELECT max(biblionumber) FROM biblio");
529
$temp= C4::Reserves::ModBiblioForceItemHolds( $temp+1, 1);
530
isnt( $temp, 1, 'Test 2 for ModBiblioForceItemHolds');
531
#End of tests for ModBiblioForceItemHolds
532
525
$dbh->rollback;
533
$dbh->rollback;
526
534
527
sub count_hold_print_messages {
535
sub count_hold_print_messages {
528
- 

Return to bug 13479