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

(-)a/C4/Circulation.pm (-7 / +23 lines)
Lines 660-666 sub itemissues { Link Here
660
=head2 CanBookBeIssued
660
=head2 CanBookBeIssued
661
661
662
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
662
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
663
                      $barcode, $duedate, $inprocess, $ignore_reserves );
663
                      $barcode, $duedate, $inprocess, $ignore_reserves, $params );
664
664
665
Check if a book can be issued.
665
Check if a book can be issued.
666
666
Lines 678-683 C<$issuingimpossible> and C<$needsconfirmation> are some hashref. Link Here
678
678
679
=item C<$ignore_reserves> boolean switch
679
=item C<$ignore_reserves> boolean switch
680
680
681
=item C<$params> Hashref of additional parameters
682
683
Available keys:
684
    override_high_holds - Ignore high holds
685
    onsite_checkout     - Checkout is an onsite checkout that will not leave the library
686
681
=back
687
=back
682
688
683
Returns :
689
Returns :
Lines 758-764 sub CanBookBeIssued { Link Here
758
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
764
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
759
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
765
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
760
766
761
    my $onsite_checkout = $params->{onsite_checkout} || 0;
767
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
768
    my $override_high_holds = $params->{override_high_holds} || 0;
762
769
763
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
770
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
764
    my $issue = GetItemIssue($item->{itemnumber});
771
    my $issue = GetItemIssue($item->{itemnumber});
Lines 1074-1084 sub CanBookBeIssued { Link Here
1074
        my $check = checkHighHolds( $item, $borrower );
1081
        my $check = checkHighHolds( $item, $borrower );
1075
1082
1076
        if ( $check->{exceeded} ) {
1083
        if ( $check->{exceeded} ) {
1077
            $needsconfirmation{HIGHHOLDS} = {
1084
            if ($override_high_holds) {
1078
                num_holds  => $check->{outstanding},
1085
                $alerts{HIGHHOLDS} = {
1079
                duration   => $check->{duration},
1086
                    num_holds  => $check->{outstanding},
1080
                returndate => output_pref( $check->{due_date} ),
1087
                    duration   => $check->{duration},
1081
            };
1088
                    returndate => output_pref( $check->{due_date} ),
1089
                };
1090
            }
1091
            else {
1092
                $needsconfirmation{HIGHHOLDS} = {
1093
                    num_holds  => $check->{outstanding},
1094
                    duration   => $check->{duration},
1095
                    returndate => output_pref( $check->{due_date} ),
1096
                };
1097
            }
1082
        }
1098
        }
1083
    }
1099
    }
1084
1100
(-)a/circ/circulation.pl (-2 / +15 lines)
Lines 62-67 my $query = new CGI; Link Here
62
my $sessionID = $query->cookie("CGISESSID") ;
62
my $sessionID = $query->cookie("CGISESSID") ;
63
my $session = get_session($sessionID);
63
my $session = get_session($sessionID);
64
64
65
my $override_high_holds     = $query->param('override_high_holds');
66
my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
67
65
# branch and printer are now defined by the userenv
68
# branch and printer are now defined by the userenv
66
# but first we have to check if someone has tried to change them
69
# but first we have to check if someone has tried to change them
67
70
Lines 332-339 if (@$barcodes) { Link Here
332
  for my $barcode ( @$barcodes ) {
335
  for my $barcode ( @$barcodes ) {
333
    my $template_params = { barcode => $barcode };
336
    my $template_params = { barcode => $barcode };
334
    # always check for blockers on issuing
337
    # always check for blockers on issuing
335
    my ( $error, $question, $alerts ) =
338
    my ( $error, $question, $alerts ) = CanBookBeIssued(
336
    CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess, undef, { onsite_checkout => $onsite_checkout } );
339
        $borrower,
340
        $barcode, $datedue,
341
        $inprocess,
342
        undef,
343
        {
344
            onsite_checkout     => $onsite_checkout,
345
            override_high_holds => $override_high_holds || $override_high_holds_tmp || 0,
346
        }
347
    );
348
337
    my $blocker = $invalidduedate ? 1 : 0;
349
    my $blocker = $invalidduedate ? 1 : 0;
338
350
339
    $template_params->{alert} = $alerts;
351
    $template_params->{alert} = $alerts;
Lines 639-644 $template->param( Link Here
639
    canned_bor_notes_loop     => $canned_notes,
651
    canned_bor_notes_loop     => $canned_notes,
640
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
652
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
641
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
653
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
654
    override_high_holds       => $override_high_holds,
642
);
655
);
643
656
644
output_html_with_http_headers $query, $cookie, $template->output;
657
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-11 / +48 lines)
Lines 207-212 $(document).ready(function() { Link Here
207
    <div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]</div>
207
    <div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]</div>
208
[% END %]
208
[% END %]
209
209
210
[% IF alert.HIGHHOLDS %]
211
    <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>
212
[% END %]
213
210
[% IF ( NEEDSCONFIRMATION ) %]
214
[% IF ( NEEDSCONFIRMATION ) %]
211
<div class="yui-g">
215
<div class="yui-g">
212
216
Lines 299-305 $(document).ready(function() { Link Here
299
    </li>
303
    </li>
300
[% END %]
304
[% END %]
301
305
302
[% IF  HIGHHOLDS %]
306
[% IF HIGHHOLDS %]
303
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
307
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
304
[% END %]
308
[% END %]
305
309
Lines 314-329 $(document).ready(function() { Link Here
314
</ul>
318
</ul>
315
319
316
[% IF HIGHHOLDS %]
320
[% IF HIGHHOLDS %]
317
	<script language="JavaScript" type="text/javascript">
321
<script language="JavaScript" type="text/javascript">
318
	$(document).ready(function() {
322
$(document).ready(function() {
319
            $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
323
    [% IF !override_high_holds %]
320
            if ('[% duedatespec %]' === '') {
324
        $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
321
                $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
325
        if ('[% duedatespec %]' === '') {
322
            } else {
326
            $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
323
                $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
327
        } else {
324
            }
328
            $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
325
	});
329
        }
326
	</script>
330
    [% END %]
331
332
    $("#override_high_holds_tmp").on( 'change', function() {
333
        if ( this.checked ) {
334
            $("input[name=duedatespec]:hidden").val('');
335
        }
336
    });
337
});
338
</script>
327
[% END %]
339
[% END %]
328
340
329
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
341
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
Lines 332-337 $(document).ready(function() { Link Here
332
344
333
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
345
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
334
346
347
[% IF HIGHHOLDS %]
348
    <p>
349
    <input type="checkbox" name="override_high_holds_tmp" id="override_high_holds_tmp" value="1" />
350
    <label for="override_high_holds_tmp">Don't decrease loan length based on holds</label>
351
    </p>
352
[% END %]
353
335
[% IF ( RESERVED ) %]
354
[% IF ( RESERVED ) %]
336
    <p>
355
    <p>
337
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
356
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
Lines 351-356 $(document).ready(function() { Link Here
351
    <input type="hidden" name="barcode" value="[% barcode |html %]" />
370
    <input type="hidden" name="barcode" value="[% barcode |html %]" />
352
    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
371
    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
353
    <input type="hidden" name="issueconfirmed" value="1" />
372
    <input type="hidden" name="issueconfirmed" value="1" />
373
    <input type="hidden" name="override_high_holds" value="[% override_high_holds %]"/>
354
    [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
374
    [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
355
    [% IF ( INVALID_DATE ) %]
375
    [% IF ( INVALID_DATE ) %]
356
    <p>
376
    <p>
Lines 647-652 No patron matched <span class="ex">[% message %]</span> Link Here
647
            [% END %]
667
            [% END %]
648
668
649
            <label for="auto_renew">Automatic renewal</label>
669
            <label for="auto_renew">Automatic renewal</label>
670
671
            [% IF Koha.Preference('decreaseLoanHighHolds') %]
672
                [% IF NEEDSCONFIRMATION %]
673
                    [% IF override_high_holds %]
674
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled" checked="checked"/>
675
                    [% ELSE %]
676
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled"/>
677
                    [% END %]
678
                [% ELSE %]
679
                    [% IF override_high_holds %]
680
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" checked="checked" />
681
                    [% ELSE %]
682
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" />
683
                    [% END %]
684
                [% END %]
685
                <label for="override_high_holds">Don't decrease loan length based on holds</label>
686
            [% END %]
650
        </div>
687
        </div>
651
    [% END %]
688
    [% END %]
652
689
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-4 / +17 lines)
Lines 26-32 use Koha::Holds; Link Here
26
use Koha::Hold;
26
use Koha::Hold;
27
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
28
28
29
use Test::More tests => 12;
29
use Test::More tests => 14;
30
30
31
my $dbh    = C4::Context->dbh;
31
my $dbh    = C4::Context->dbh;
32
my $schema = Koha::Database->new()->schema();
32
my $schema = Koha::Database->new()->schema();
Lines 63-69 my $biblioitem = Link Here
63
63
64
my @items;
64
my @items;
65
for my $i ( 1 .. 10 ) {
65
for my $i ( 1 .. 10 ) {
66
    my $item = Koha::Item->new( { biblionumber => $biblio->id(), biblioitemnumber => $biblioitem->id(), } )->store();
66
    my $item = Koha::Item->new(
67
        {
68
            biblionumber     => $biblio->id(),
69
            biblioitemnumber => $biblioitem->id(),
70
            barcode          => $i
71
        }
72
    )->store();
67
    push( @items, $item );
73
    push( @items, $item );
68
}
74
}
69
75
Lines 101-107 C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 1 ); Link Here
101
C4::Context->set_preference( 'decreaseLoanHighHoldsControl',        'static' );
107
C4::Context->set_preference( 'decreaseLoanHighHoldsControl',        'static' );
102
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
108
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
103
109
104
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} };
110
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $item->barcode };
105
my $patron_hr = { borrower => $patron->id, branchcode => $library->{branchcode} };
111
my $patron_hr = { borrower => $patron->id, branchcode => $library->{branchcode} };
106
112
107
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
113
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
Lines 160-164 $unholdable->store(); Link Here
160
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
166
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
161
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
167
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
162
168
169
C4::Context->set_preference('CircControl', 'PatronLibrary');
170
171
my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode );
172
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
173
174
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode, undef, undef, undef, { override_high_holds => 1 } );
175
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
176
163
$schema->storage->txn_rollback();
177
$schema->storage->txn_rollback();
164
1;
178
1;
165
- 

Return to bug 11565