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

(-)a/C4/Circulation.pm (-7 / +16 lines)
Lines 604-610 sub itemissues { Link Here
604
=head2 CanBookBeIssued
604
=head2 CanBookBeIssued
605
605
606
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
606
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
607
                      $barcode, $duedatespec, $inprocess, $ignore_reserves );
607
                      $barcode, $duedatespec, $inprocess, $ignore_reserves, $override_high_holds );
608
608
609
Check if a book can be issued.
609
Check if a book can be issued.
610
610
Lines 696-702 if the borrower borrows to much things Link Here
696
=cut
696
=cut
697
697
698
sub CanBookBeIssued {
698
sub CanBookBeIssued {
699
    my ( $borrower, $barcode, $duedate, $inprocess, $ignore_reserves ) = @_;
699
    my ( $borrower, $barcode, $duedate, $inprocess, $ignore_reserves, $override_high_holds ) = @_;
700
    my %needsconfirmation;    # filled with problems that needs confirmations
700
    my %needsconfirmation;    # filled with problems that needs confirmations
701
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
701
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
702
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
702
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
Lines 1014-1024 sub CanBookBeIssued { Link Here
1014
        my $check = checkHighHolds( $item, $borrower );
1014
        my $check = checkHighHolds( $item, $borrower );
1015
1015
1016
        if ( $check->{exceeded} ) {
1016
        if ( $check->{exceeded} ) {
1017
            $needsconfirmation{HIGHHOLDS} = {
1017
            if ($override_high_holds) {
1018
                num_holds  => $check->{outstanding},
1018
                $alerts{HIGHHOLDS} = {
1019
                duration   => $check->{duration},
1019
                    num_holds  => $check->{outstanding},
1020
                returndate => output_pref( $check->{due_date} ),
1020
                    duration   => $check->{duration},
1021
            };
1021
                    returndate => output_pref( $check->{due_date} ),
1022
                };
1023
            }
1024
            else {
1025
                $needsconfirmation{HIGHHOLDS} = {
1026
                    num_holds  => $check->{outstanding},
1027
                    duration   => $check->{duration},
1028
                    returndate => output_pref( $check->{due_date} ),
1029
                };
1030
            }
1022
        }
1031
        }
1023
    }
1032
    }
1024
1033
(-)a/circ/circulation.pl (-1 / +5 lines)
Lines 65-70 my $query = new CGI; Link Here
65
my $sessionID = $query->cookie("CGISESSID") ;
65
my $sessionID = $query->cookie("CGISESSID") ;
66
my $session = get_session($sessionID);
66
my $session = get_session($sessionID);
67
67
68
my $override_high_holds     = $query->param('override_high_holds');
69
my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
70
68
# branch and printer are now defined by the userenv
71
# branch and printer are now defined by the userenv
69
# but first we have to check if someone has tried to change them
72
# but first we have to check if someone has tried to change them
70
73
Lines 301-307 if ($borrowernumber) { Link Here
301
if ($barcode) {
304
if ($barcode) {
302
    # always check for blockers on issuing
305
    # always check for blockers on issuing
303
    my ( $error, $question, $alerts ) =
306
    my ( $error, $question, $alerts ) =
304
    CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
307
    CanBookBeIssued( $borrower, $barcode, $datedue, $inprocess, undef, $override_high_holds || $override_high_holds_tmp );
305
    my $blocker = $invalidduedate ? 1 : 0;
308
    my $blocker = $invalidduedate ? 1 : 0;
306
309
307
    $template->param( alert => $alerts );
310
    $template->param( alert => $alerts );
Lines 573-578 $template->param( Link Here
573
    canned_bor_notes_loop     => $canned_notes,
576
    canned_bor_notes_loop     => $canned_notes,
574
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
577
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
575
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
578
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
579
    override_high_holds       => $override_high_holds,
576
);
580
);
577
581
578
output_html_with_http_headers $query, $cookie, $template->output;
582
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-6 / +42 lines)
Lines 206-211 $(document).ready(function() { Link Here
206
    <div class="dialog message">The patron has unpaid charges for reserves, rentals etc of [% alert.OTHER_CHARGES %]</div>
206
    <div class="dialog message">The patron has unpaid charges for reserves, rentals etc of [% alert.OTHER_CHARGES %]</div>
207
[% END %]
207
[% END %]
208
208
209
[% IF alert.HIGHHOLDS %]
210
    <div class="dialog message">High demand item. Loan period <i>not</i> shortened to [% alert.HIGHHOLDS.duration %] days (due [% alert.HIGHHOLDS.returndate %]) due to override.</div>
211
[% END %]
212
209
[% IF ( NEEDSCONFIRMATION ) %]
213
[% IF ( NEEDSCONFIRMATION ) %]
210
<div class="yui-g">
214
<div class="yui-g">
211
215
Lines 294-300 $(document).ready(function() { Link Here
294
    </li>
298
    </li>
295
[% END %]
299
[% END %]
296
300
297
[% IF  HIGHHOLDS %]
301
[% IF HIGHHOLDS %]
298
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
302
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
299
[% END %]
303
[% END %]
300
304
Lines 309-319 $(document).ready(function() { Link Here
309
</ul>
313
</ul>
310
314
311
[% IF HIGHHOLDS %]
315
[% IF HIGHHOLDS %]
312
	<script language="JavaScript" type="text/javascript">
316
<script language="JavaScript" type="text/javascript">
313
	$(document).ready(function() {
317
$(document).ready(function() {
314
		$("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
318
    [% IF !override_high_holds %]
315
	});
319
        $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
316
	</script>
320
    [% END %]
321
322
    $("#override_high_holds_tmp").on( 'change', function() {
323
        if ( this.checked ) {
324
            $("input[name=duedatespec]:hidden").val('');
325
        }
326
    });
327
});
328
</script>
317
[% END %]
329
[% END %]
318
330
319
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
331
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
Lines 321-326 $(document).ready(function() { Link Here
321
333
322
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
334
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
323
335
336
[% IF HIGHHOLDS %]
337
    <p>
338
    <input type="checkbox" name="override_high_holds_tmp" id="override_high_holds_tmp" value="1" />
339
    <label for="override_high_holds_tmp">Don't decrease loan length based on holds</label>
340
    </p>
341
[% END %]
342
324
[% IF ( RESERVED ) %]
343
[% IF ( RESERVED ) %]
325
    <p>
344
    <p>
326
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
345
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
Lines 632-637 No patron matched <span class="ex">[% message %]</span> Link Here
632
            <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" />
651
            <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" />
633
        [% END %]
652
        [% END %]
634
        <label for="auto_renew">Automatic renewal</label>
653
        <label for="auto_renew">Automatic renewal</label>
654
655
        [% IF Koha.Preference('decreaseLoanHighHolds') %]
656
            [% IF NEEDSCONFIRMATION %]
657
                [% IF override_high_holds %]
658
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled" checked="checked"/>
659
                [% ELSE %]
660
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled"/>
661
                [% END %]
662
            [% ELSE %]
663
                [% IF override_high_holds %]
664
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" checked="checked" />
665
                [% ELSE %]
666
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" />
667
                [% END %]
668
            [% END %]
669
            <label for="override_high_holds">Don't decrease loan length based on holds</label>
670
        [% END %]
635
    </div>
671
    </div>
636
672
637
    [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %]
673
    [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %]
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-4 / +17 lines)
Lines 27-33 use Koha::Item; Link Here
27
use Koha::Holds;
27
use Koha::Holds;
28
use Koha::Hold;
28
use Koha::Hold;
29
29
30
use Test::More tests => 12;
30
use Test::More tests => 14;
31
31
32
my $dbh    = C4::Context->dbh;
32
my $dbh    = C4::Context->dbh;
33
my $schema = Koha::Database->new()->schema();
33
my $schema = Koha::Database->new()->schema();
Lines 60-66 my $biblioitem = Link Here
60
60
61
my @items;
61
my @items;
62
for my $i ( 1 .. 10 ) {
62
for my $i ( 1 .. 10 ) {
63
    my $item = Koha::Item->new( { biblionumber => $biblio->id(), biblioitemnumber => $biblioitem->id(), } )->store();
63
    my $item = Koha::Item->new(
64
        {
65
            biblionumber     => $biblio->id(),
66
            biblioitemnumber => $biblioitem->id(),
67
            barcode          => $i,
68
        }
69
    )->store();
64
    push( @items, $item );
70
    push( @items, $item );
65
}
71
}
66
72
Lines 88-94 C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 1 ); Link Here
88
C4::Context->set_preference( 'decreaseLoanHighHoldsControl',        'static' );
94
C4::Context->set_preference( 'decreaseLoanHighHoldsControl',        'static' );
89
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
95
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
90
96
91
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => 'MPL', holdingbranch => 'MPL' };
97
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => 'MPL', holdingbranch => 'MPL', barcode => $item->barcode };
92
my $patron_hr = { borrower => $patron->id, branchcode => 'MPL' };
98
my $patron_hr = { borrower => $patron->id, branchcode => 'MPL' };
93
99
94
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
100
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
Lines 147-151 $unholdable->store(); Link Here
147
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
153
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
148
is( $data->{exceeded}, 1, "Should exceed threshold" );
154
is( $data->{exceeded}, 1, "Should exceed threshold" );
149
155
156
C4::Context->set_preference('CircControl', 'PatronLibrary');
157
158
my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode );
159
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
160
161
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode, undef, undef, undef, 1 );
162
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
163
150
$schema->storage->txn_rollback();
164
$schema->storage->txn_rollback();
151
1;
165
1;
152
- 

Return to bug 11565