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

(-)a/C4/Reserves.pm (+12 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
=cut
2457
2458
sub ModBiblioForceItemHolds {
2459
    my ( $biblionumber, $newmode ) = @_;
2460
    my $rec = Koha::Database->new()->schema()->resultset('Biblio')->find( $biblionumber );
2461
    return 0 if !$rec;
2462
    my $rv = $rec->update({ force_item_holds => $newmode? 1: 0 });
2463
    return $rv ? 1 : 0;
2464
}
2465
2454
=head1 AUTHOR
2466
=head1 AUTHOR
2455
2467
2456
Koha Development Team <http://koha-community.org/>
2468
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( obj.responseText == '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 (-1 / +49 lines)
Line 0 Link Here
0
- 
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 2 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::Context;
24
use C4::Auth;
25
use C4::Output;
26
use C4::Reserves qw//;
27
28
=head1 DESCRIPTION
29
30
Update force item holds for a specific biblio
31
32
=cut
33
34
my $input = new CGI;
35
my $biblio   = $input->param('biblio');
36
my $mode     = $input->param('mode');
37
38
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
39
    {   template_name   => "acqui/ajax.tt",
40
        query           => $input,
41
        type            => "intranet",
42
        authnotrequired => 0,
43
    }
44
);
45
46
my $rv = C4::Reserves::ModBiblioForceItemHolds( $biblio, $mode );
47
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
48
print $rv//0;
49
#output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 13479