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

(-)a/C4/HoldsQueue.pm (-6 / +24 lines)
Lines 30-35 use C4::Circulation; Link Here
30
use C4::Members;
30
use C4::Members;
31
use C4::Biblio;
31
use C4::Biblio;
32
use C4::Dates qw/format_date/;
32
use C4::Dates qw/format_date/;
33
use C4::Calendar;
34
use Koha::Database;
35
use Koha::DateUtils;
33
36
34
use List::Util qw(shuffle);
37
use List::Util qw(shuffle);
35
use List::MoreUtils qw(any);
38
use List::MoreUtils qw(any);
Lines 582-593 sub _trim { Link Here
582
}
585
}
583
586
584
sub load_branches_to_pull_from {
587
sub load_branches_to_pull_from {
585
    my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight")
588
    my @branches_to_use;
586
      or return;
589
587
590
    my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight");
588
    my @branches_to_use = map _trim($_), split /,/, $static_branch_list;
591
    @branches_to_use = map { _trim($_) } split( /,/, $static_branch_list )
589
592
      if $static_branch_list;
590
    @branches_to_use = shuffle(@branches_to_use) if  C4::Context->preference("RandomizeHoldsQueueWeight");
593
594
    @branches_to_use =
595
      Koha::Database->new()->schema()->resultset('Branch')
596
      ->get_column('branchcode')->all()
597
      unless (@branches_to_use);
598
599
    @branches_to_use = shuffle(@branches_to_use)
600
      if C4::Context->preference("RandomizeHoldsQueueWeight");
601
602
    my $today = dt_from_string();
603
    if ( C4::Context->preference('HoldsQueueSkipClosed') ) {
604
        @branches_to_use = grep {
605
            !C4::Calendar->new( branchcode => $_ )
606
              ->isHoliday( $today->day(), $today->month(), $today->year() )
607
        } @branches_to_use;
608
    }
591
609
592
    return \@branches_to_use;
610
    return \@branches_to_use;
593
}
611
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 132-137 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
132
('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'),
132
('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'),
133
('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch\'s items to emphasize. If PatronBranch, emphasize the logged in user\'s library\'s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha\'s Apache configuration file.','Choice'),
133
('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch\'s items to emphasize. If PatronBranch, emphasize the logged in user\'s library\'s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha\'s Apache configuration file.','Choice'),
134
('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'),
134
('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'),
135
('HoldsQueueSkipClosed', '0', NULL, 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo'),
135
('HomeOrHoldingBranch','holdingbranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','Choice'),
136
('HomeOrHoldingBranch','holdingbranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','Choice'),
136
('HomeOrHoldingBranchReturn','homebranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check checking-in items','Choice'),
137
('HomeOrHoldingBranchReturn','homebranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check checking-in items','Choice'),
137
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
138
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 8613-8618 if ( CheckVersion($DBversion) ) { Link Here
8613
    SetVersion($DBversion);
8613
    SetVersion($DBversion);
8614
}
8614
}
8615
8615
8616
$DBversion = '3.17.00.XXX';
8617
if ( CheckVersion($DBversion) ) {
8618
    $dbh->do("
8619
        INSERT INTO systempreferences (variable,value,explanation,type) VALUES
8620
        ('HoldsQueueSkipClosed', '0', 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo')
8621
    ");
8622
    print "Upgrade to $DBversion done (Bug 12803 - Add ability to skip closed libraries when generating the holds queue)\n";
8623
    SetVersion($DBversion);
8624
}
8625
8616
=head1 FUNCTIONS
8626
=head1 FUNCTIONS
8617
8627
8618
=head2 TableExists($table)
8628
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 lines)
Lines 429-438 Circulation: Link Here
429
            - pref: ExpireReservesMaxPickUpDelayCharge
429
            - pref: ExpireReservesMaxPickUpDelayCharge
430
              class: currency
430
              class: currency
431
        -
431
        -
432
            - Satisfy holds from the libraries
432
            - Satisfy holds using items from the libraries
433
            - pref: StaticHoldsQueueWeight
433
            - pref: StaticHoldsQueueWeight
434
              class: multi
434
              class: multi
435
            - (as branchcodes, separated by commas; if empty, uses all libraries)
435
            - (as branchcodes, separated by commas; if empty, uses all libraries)
436
            - when they are
437
            - pref: HoldsQueueSkipClosed
438
              choices:
439
                  yes: open
440
                  no: open or closed
436
            - pref: RandomizeHoldsQueueWeight
441
            - pref: RandomizeHoldsQueueWeight
437
              choices:
442
              choices:
438
                  yes: in random order.
443
                  yes: in random order.
(-)a/t/db_dependent/HoldsQueue.t (-6 / +21 lines)
Lines 8-23 Link Here
8
8
9
use Modern::Perl;
9
use Modern::Perl;
10
10
11
use C4::Context;
11
use Test::More tests => 22;
12
13
use Data::Dumper;
12
use Data::Dumper;
14
13
15
use Test::More tests => 21;
14
use C4::Context;
16
17
18
use C4::Branch;
15
use C4::Branch;
19
use C4::ItemType;
16
use C4::ItemType;
20
use C4::Members;
17
use C4::Members;
18
use Koha::DateUtils;
21
19
22
BEGIN {
20
BEGIN {
23
    use FindBin;
21
    use FindBin;
Lines 298-303 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
298
ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
296
ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
299
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue );
297
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue );
300
298
299
# Test skipping hold picks for closed libraries.
300
# At this point in the test, we have 3 rows in the holds queue
301
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed
302
# and make today a holiday for MPL. When we run it again we should only
303
# have 2 rows in the holds queue
304
C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 );
305
my $today = dt_from_string();
306
C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday(
307
    day         => $today->day(),
308
    month       => $today->month(),
309
    year        => $today->year(),
310
    title       => "$today",
311
    description => "$today",
312
);
313
C4::HoldsQueue::CreateQueue();
314
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
315
ok( @$holds_queue == 2, "Holds not filled with items from closed libraries" );
316
301
# Cleanup
317
# Cleanup
302
$dbh->rollback;
318
$dbh->rollback;
303
319
304
- 

Return to bug 12803