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

(-)a/C4/Reserves.pm (+17 lines)
Lines 2434-2439 sub IsItemOnHoldAndFound { Link Here
2434
    return $found;
2434
    return $found;
2435
}
2435
}
2436
2436
2437
=head2 CheckBiblioForceItemHolds
2438
2439
    This subroutine returns true if item holds are forced for each biblio
2440
    by OPACItemHolds. If this pref is set to selective, the biblio should
2441
    be found in the designated table.
2442
    In other cases it returns undef.
2443
2444
=cut
2445
2446
sub CheckBiblioForceItemHolds {
2447
    my ( $biblionumber ) = @_;
2448
    return 1 if C4::Context->preference('OPACItemHolds') eq 'force';
2449
    return if C4::Context->preference('OPACItemHolds') ne 'selectiveforce';
2450
    my $rec = Koha::Database->new()->schema()->resultset('Biblio')->find( $biblionumber );
2451
    return 1 if $rec && $rec->force_item_holds;
2452
}
2453
2437
=head1 AUTHOR
2454
=head1 AUTHOR
2438
2455
2439
Koha Development Team <http://koha-community.org/>
2456
Koha Development Team <http://koha-community.org/>
(-)a/Koha/Schema/Result/Biblio.pm (-2 / +9 lines)
Lines 89-94 __PACKAGE__->table("biblio"); Link Here
89
  data_type: 'mediumtext'
89
  data_type: 'mediumtext'
90
  is_nullable: 1
90
  is_nullable: 1
91
91
92
=head2 force_item_holds
93
94
  data_type: 'tinyint'
95
  is_nullable: 1
96
92
=cut
97
=cut
93
98
94
__PACKAGE__->add_columns(
99
__PACKAGE__->add_columns(
Lines 121-126 __PACKAGE__->add_columns( Link Here
121
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 },
126
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 },
122
  "abstract",
127
  "abstract",
123
  { data_type => "mediumtext", is_nullable => 1 },
128
  { data_type => "mediumtext", is_nullable => 1 },
129
  "force_item_holds",
130
  { data_type => "tinyint", is_nullable => 1 },
124
);
131
);
125
132
126
=head1 PRIMARY KEY
133
=head1 PRIMARY KEY
Lines 328-335 Composing rels: L</oai_sets_biblios> -> set Link Here
328
__PACKAGE__->many_to_many("sets", "oai_sets_biblios", "set");
335
__PACKAGE__->many_to_many("sets", "oai_sets_biblios", "set");
329
336
330
337
331
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
338
# Created by DBIx::Class::Schema::Loader v0.07036 @ 2015-03-05 11:43:19
332
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0//8OGf7OteNnwT03g4QsA
339
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E+zNAx8qgwQKSj7JaYyDHg
333
340
334
__PACKAGE__->belongs_to(
341
__PACKAGE__->belongs_to(
335
    "biblioitem",
342
    "biblioitem",
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 262-268 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
262
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'),
262
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'),
263
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
263
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
264
('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'),
264
('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'),
265
('OPACItemHolds','1','0|1|force','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy.','Choice'),
265
('OPACItemHolds','1','0|1|force|selectiveforce','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy. Selectiveforce works on specific biblios.','Choice'),
266
('OpacItemLocation','callnum','callnum|ccode|location','Show the shelving location of items in the opac','Choice'),
266
('OpacItemLocation','callnum','callnum|ccode|location','Show the shelving location of items in the opac','Choice'),
267
('OPACItemsResultsDisplay','0','','If OFF : show only the status of items in result list.If ON : show full location of items (branch+location+callnumber) as in staff interface','YesNo'),
267
('OPACItemsResultsDisplay','0','','If OFF : show only the status of items in result list.If ON : show full location of items (branch+location+callnumber) as in staff interface','YesNo'),
268
('OpacKohaUrl','1',NULL,'Show \'Powered by Koha\' text on OPAC footer.',NULL),
268
('OpacKohaUrl','1',NULL,'Show \'Powered by Koha\' text on OPAC footer.',NULL),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +2 lines)
Lines 499-505 OPAC: Link Here
499
                  no: "Don't allow"
499
                  no: "Don't allow"
500
                  yes: Allow
500
                  yes: Allow
501
                  force: Force
501
                  force: Force
502
            - patrons to place holds on specific items in the OPAC. If this is disabled, users can only put a hold on the next available item. If this is forced, users must put a hold on a specific item.
502
                  selectiveforce: Selectively force
503
            - patrons to place holds on specific items in the OPAC. If this is disabled, users can only put a hold on the next available item. If this is forced, users must put a hold on a specific item. The 'selective force'-option works with a list of biblios with forced item holds.
503
        -
504
        -
504
            - pref: OpacRenewalAllowed
505
            - pref: OpacRenewalAllowed
505
              choices:
506
              choices:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-10 / +12 lines)
Lines 119-125 Link Here
119
                            <div id="bigloop">
119
                            <div id="bigloop">
120
120
121
                                [% FOREACH bibitemloo IN bibitemloop %]
121
                                [% FOREACH bibitemloo IN bibitemloop %]
122
                                    <div class="holdrow">
122
                                    <div class="holdrow" id="holdrow_[% bibitemloo.biblionumber %]">
123
                                        <p>
123
                                        <p>
124
                                            [% IF ( bibitemloo.holdable ) %]
124
                                            [% IF ( bibitemloo.holdable ) %]
125
                                                <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
125
                                                <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
Lines 249-255 Link Here
249
                                                            </li>
249
                                                            </li>
250
                                                        [% END # / IF OpacHoldNotes %]
250
                                                        [% END # / IF OpacHoldNotes %]
251
251
252
                                                        [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %]
252
                                                        [% IF OPACItemHolds %]
253
                                                            <!-- ITEM HOLDS -->
253
                                                            <!-- ITEM HOLDS -->
254
                                                            <li class="lradio place_on_type" style="display:none;">
254
                                                            <li class="lradio place_on_type" style="display:none;">
255
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
255
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
Lines 268-274 Link Here
268
                                                                     />
268
                                                                     />
269
                                                                [% END %]
269
                                                                [% END %]
270
                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
270
                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
271
                                                                [% IF OPACItemHolds == "force" %]
271
                                                                [% IF bibitemloo.force_item_holds %]
272
                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
272
                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
273
                                                                           id="reqspecific_[% bibitemloo.biblionumber %]"
273
                                                                           id="reqspecific_[% bibitemloo.biblionumber %]"
274
                                                                           class="selectspecific"
274
                                                                           class="selectspecific"
Lines 286-292 Link Here
286
                                                        [% END # / IF OPACItemHolds %]
286
                                                        [% END # / IF OPACItemHolds %]
287
                                                    </ul>
287
                                                    </ul>
288
288
289
                                                    [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %]
289
                                                    [% IF OPACItemHolds %]
290
                                                        <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
290
                                                        <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
291
                                                            <caption>Select a specific item:</caption>
291
                                                            <caption>Select a specific item:</caption>
292
                                                            <tr>
292
                                                            <tr>
Lines 466-473 Link Here
466
        // Hides all 'specific copy' table rows on load.
466
        // Hides all 'specific copy' table rows on load.
467
        $(".copiesrow").hide();
467
        $(".copiesrow").hide();
468
468
469
        [% IF OPACItemHolds == 'force' %]
469
        [% FOREACH bibitemloo IN bibitemloop %]
470
          [% FOREACH bibitemloo IN bibitemloop %]
470
          [% IF bibitemloo.force_item_holds %]
471
            [% IF bibitemloo.holdable %]
471
            [% IF bibitemloo.holdable %]
472
              $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
472
              $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
473
              $("#copiesrow_[% bibitemloo.biblionumber %]").show();
473
              $("#copiesrow_[% bibitemloo.biblionumber %]").show();
Lines 529-543 Link Here
529
529
530
        $("#place_on_hdr").show();
530
        $("#place_on_hdr").show();
531
531
532
        [% IF OPACItemHolds == '1' %]
532
        [% FOREACH bibitemloo IN bibitemloop %]
533
            $(".place_on_type").show();
533
          [% IF OPACItemHolds == '1' OR !bibitemloo.force_item_holds %]
534
            $("#holdrow_[% bibitemloo.biblionumber %]").find(".place_on_type").show();
534
            // onload, selectany is checked
535
            // onload, selectany is checked
535
            $(".selectany").attr("checked", "checked");
536
            $("#holdrow_[% bibitemloo.biblionumber %]").find(".selectany").attr("checked", "checked");
537
          [% END %]
536
        [% END %]
538
        [% END %]
537
539
538
        // If the user is *allowed* to choose a specific item
540
        // If the user is *allowed* to choose a specific item
539
        // The first one is preselected
541
        // The first one is preselected
540
        [% IF OPACItemHolds =="1" %]
542
        [% IF OPACItemHolds %]
541
            $("table.copiesrow").each(function(){
543
            $("table.copiesrow").each(function(){
542
                var id = suffixOf($(this).attr("id"), "_");
544
                var id = suffixOf($(this).attr("id"), "_");
543
                select_first_available(id);
545
                select_first_available(id);
(-)a/opac/opac-reserve.pl (+3 lines)
Lines 561-566 foreach my $biblioNum (@biblionumbers) { Link Here
561
561
562
    if( $biblioLoopIter{holdable} ){ $anyholdable++; }
562
    if( $biblioLoopIter{holdable} ){ $anyholdable++; }
563
563
564
    $biblioLoopIter{force_item_holds} =
565
        C4::Reserves::CheckBiblioForceItemHolds( $biblioNum );
566
564
    push @$biblioLoop, \%biblioLoopIter;
567
    push @$biblioLoop, \%biblioLoopIter;
565
}
568
}
566
569
(-)a/t/db_dependent/Reserves.t (-2 / +17 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 53;
20
use Test::More tests => 57;
21
21
22
use MARC::Record;
22
use MARC::Record;
23
use DateTime::Duration;
23
use DateTime::Duration;
Lines 506-511 is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 'OK', "Res Link Here
506
####### EO Bug 13113 <<<
506
####### EO Bug 13113 <<<
507
       ####
507
       ####
508
508
509
#Tests for CheckBiblioForceItemHolds
510
$dbh->do('UPDATE biblio SET force_item_holds=NULL WHERE biblionumber=?',undef,($bibnum));
511
C4::Context->set_preference('OPACItemHolds', 'force');
512
is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
513
    'If OPACItemHolds==force, each bib should force item holds');
514
C4::Context->set_preference('OPACItemHolds', 'selectiveforce');
515
isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
516
    'For selectiveforce this bib should not be found');
517
$dbh->do('UPDATE biblio SET force_item_holds=1 WHERE biblionumber=?',undef,($bibnum));
518
is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
519
    'For selectiveforce this bib should be found now');
520
C4::Context->set_preference('OPACItemHolds', '1');
521
isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
522
    'For Allow this bib should return false again');
523
#End of tests for CheckBiblioForceItemHolds
524
509
$dbh->rollback;
525
$dbh->rollback;
510
526
511
sub count_hold_print_messages {
527
sub count_hold_print_messages {
512
- 

Return to bug 13478