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

(-)a/C4/Reserves.pm (+17 lines)
Lines 2440-2445 sub IsItemOnHoldAndFound { Link Here
2440
    return $found;
2440
    return $found;
2441
}
2441
}
2442
2442
2443
=head2 CheckBiblioForceItemHolds
2444
2445
    This subroutine returns true if item holds are forced for each biblio
2446
    by OPACItemHolds. If this pref is set to selective, the biblio should
2447
    be found in the designated table.
2448
    In other cases it returns undef.
2449
2450
=cut
2451
2452
sub CheckBiblioForceItemHolds {
2453
    my ( $biblionumber ) = @_;
2454
    return 1 if C4::Context->preference('OPACItemHolds') eq 'force';
2455
    return if C4::Context->preference('OPACItemHolds') ne 'selectiveforce';
2456
    my $rs = Koha::Database->new()->schema()->resultset('BiblioForceItemHold');
2457
    return 1 if $rs->find( $biblionumber );
2458
}
2459
2443
=head1 AUTHOR
2460
=head1 AUTHOR
2444
2461
2445
Koha Development Team <http://koha-community.org/>
2462
Koha Development Team <http://koha-community.org/>
(-)a/Koha/Schema/Result/BiblioForceItemHold.pm (+53 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::BiblioForceItemHold;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::BiblioForceItemHold
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<biblio_force_item_holds>
19
20
=cut
21
22
__PACKAGE__->table("biblio_force_item_holds");
23
24
=head1 ACCESSORS
25
26
=head2 biblionumber
27
28
  data_type: 'integer'
29
  is_nullable: 0
30
31
=cut
32
33
__PACKAGE__->add_columns("biblionumber", { data_type => "integer", is_nullable => 0 });
34
35
=head1 PRIMARY KEY
36
37
=over 4
38
39
=item * L</biblionumber>
40
41
=back
42
43
=cut
44
45
__PACKAGE__->set_primary_key("biblionumber");
46
47
48
# Created by DBIx::Class::Schema::Loader v0.07036 @ 2014-12-18 10:00:44
49
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fJDe98uyvYlbqjrElzM/rQ
50
51
52
# You can replace this text with custom code or comments, and it will be preserved on regeneration
53
1;
(-)a/installer/data/mysql/kohastructure.sql (+10 lines)
Lines 132-137 CREATE TABLE `biblio` ( -- table that stores bibliographic information Link Here
132
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
132
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
133
133
134
--
134
--
135
-- Table structure for table `biblio_force_item_holds`
136
--
137
138
DROP TABLE IF EXISTS `biblio_force_item_holds`;
139
CREATE TABLE `biblio_force_item_holds` ( -- biblios with forced item holds
140
  `biblionumber` int NOT NULL, -- primary key
141
  PRIMARY KEY  (`biblionumber`)
142
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
143
144
--
135
-- Table structure for table `biblio_framework`
145
-- Table structure for table `biblio_framework`
136
--
146
--
137
147
(-)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/installer/data/mysql/updatedatabase.pl (+15 lines)
Lines 9585-9590 if ( CheckVersion($DBversion) ) { Link Here
9585
    SetVersion ($DBversion);
9585
    SetVersion ($DBversion);
9586
}
9586
}
9587
9587
9588
9589
$DBversion = "3.19.00.XXX";
9590
if ( CheckVersion($DBversion) ) {
9591
    $dbh->do(qq|
9592
        CREATE TABLE biblio_force_item_holds
9593
        (biblionumber int NOT NULL PRIMARY KEY);
9594
    |);
9595
    $dbh->do(qq|
9596
        UPDATE systempreferences SET explanation = '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.'
9597
        WHERE variable = 'OPACItemHolds';
9598
    |);
9599
    print "Upgrade to $DBversion done (Update OPACItemHolds description)\n";
9600
    SetVersion ($DBversion);
9601
}
9602
9588
=head1 FUNCTIONS
9603
=head1 FUNCTIONS
9589
9604
9590
=head2 TableExists($table)
9605
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +2 lines)
Lines 494-500 OPAC: Link Here
494
                  no: "Don't allow"
494
                  no: "Don't allow"
495
                  yes: Allow
495
                  yes: Allow
496
                  force: Force
496
                  force: Force
497
            - 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.
497
                  selectiveforce: Selectively force
498
            - 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.
498
        -
499
        -
499
            - pref: OpacRenewalAllowed
500
            - pref: OpacRenewalAllowed
500
              choices:
501
              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 243-249 Link Here
243
                                                            </li>
243
                                                            </li>
244
                                                        [% END # / IF OpacHoldNotes %]
244
                                                        [% END # / IF OpacHoldNotes %]
245
245
246
                                                        [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %]
246
                                                        [% IF OPACItemHolds %]
247
                                                            <!-- ITEM HOLDS -->
247
                                                            <!-- ITEM HOLDS -->
248
                                                            <li class="lradio place_on_type" style="display:none;">
248
                                                            <li class="lradio place_on_type" style="display:none;">
249
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
249
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
Lines 262-268 Link Here
262
                                                                     />
262
                                                                     />
263
                                                                [% END %]
263
                                                                [% END %]
264
                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
264
                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
265
                                                                [% IF OPACItemHolds == "force" %]
265
                                                                [% IF bibitemloo.force_item_holds %]
266
                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
266
                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
267
                                                                           id="reqspecific_[% bibitemloo.biblionumber %]"
267
                                                                           id="reqspecific_[% bibitemloo.biblionumber %]"
268
                                                                           class="selectspecific"
268
                                                                           class="selectspecific"
Lines 280-286 Link Here
280
                                                        [% END # / IF OPACItemHolds %]
280
                                                        [% END # / IF OPACItemHolds %]
281
                                                    </ul>
281
                                                    </ul>
282
282
283
                                                    [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %]
283
                                                    [% IF OPACItemHolds %]
284
                                                        <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
284
                                                        <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
285
                                                            <caption>Select a specific item:</caption>
285
                                                            <caption>Select a specific item:</caption>
286
                                                            <tr>
286
                                                            <tr>
Lines 460-467 Link Here
460
        // Hides all 'specific copy' table rows on load.
460
        // Hides all 'specific copy' table rows on load.
461
        $(".copiesrow").hide();
461
        $(".copiesrow").hide();
462
462
463
        [% IF OPACItemHolds == 'force' %]
463
        [% FOREACH bibitemloo IN bibitemloop %]
464
          [% FOREACH bibitemloo IN bibitemloop %]
464
          [% IF bibitemloo.force_item_holds %]
465
            [% IF bibitemloo.holdable %]
465
            [% IF bibitemloo.holdable %]
466
              $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
466
              $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
467
              $("#copiesrow_[% bibitemloo.biblionumber %]").show();
467
              $("#copiesrow_[% bibitemloo.biblionumber %]").show();
Lines 523-537 Link Here
523
523
524
        $("#place_on_hdr").show();
524
        $("#place_on_hdr").show();
525
525
526
        [% IF OPACItemHolds == '1' %]
526
        [% FOREACH bibitemloo IN bibitemloop %]
527
            $(".place_on_type").show();
527
          [% IF OPACItemHolds == '1' OR !bibitemloo.force_item_holds %]
528
            $("#holdrow_[% bibitemloo.biblionumber %]").find(".place_on_type").show();
528
            // onload, selectany is checked
529
            // onload, selectany is checked
529
            $(".selectany").attr("checked", "checked");
530
            $("#holdrow_[% bibitemloo.biblionumber %]").find(".selectany").attr("checked", "checked");
531
          [% END %]
530
        [% END %]
532
        [% END %]
531
533
532
        // If the user is *allowed* to choose a specific item
534
        // If the user is *allowed* to choose a specific item
533
        // The first one is preselected
535
        // The first one is preselected
534
        [% IF OPACItemHolds =="1" %]
536
        [% IF OPACItemHolds %]
535
            $("table.copiesrow").each(function(){
537
            $("table.copiesrow").each(function(){
536
                var id = suffixOf($(this).attr("id"), "_");
538
                var id = suffixOf($(this).attr("id"), "_");
537
                select_first_available(id);
539
                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 / +18 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('DELETE FROM biblio_force_item_holds');
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('INSERT INTO biblio_force_item_holds (biblionumber) VALUES (?)',
518
    undef, ( $bibnum ) );
519
is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
520
    'For selectiveforce this bib should be found now');
521
C4::Context->set_preference('OPACItemHolds', '1');
522
isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
523
    'For Allow this bib should return false again');
524
#End of tests for CheckBiblioForceItemHolds
525
509
$dbh->rollback;
526
$dbh->rollback;
510
527
511
sub count_hold_print_messages {
528
sub count_hold_print_messages {
512
- 

Return to bug 13478