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

(-)a/C4/Circulation.pm (-7 / +23 lines)
Lines 659-665 sub itemissues { Link Here
659
=head2 CanBookBeIssued
659
=head2 CanBookBeIssued
660
660
661
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
661
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
662
                      $barcode, $duedate, $inprocess, $ignore_reserves );
662
                      $barcode, $duedate, $inprocess, $ignore_reserves, $params );
663
663
664
Check if a book can be issued.
664
Check if a book can be issued.
665
665
Lines 677-682 C<$issuingimpossible> and C<$needsconfirmation> are some hashref. Link Here
677
677
678
=item C<$ignore_reserves> boolean switch
678
=item C<$ignore_reserves> boolean switch
679
679
680
=item C<$params> Hashref of additional parameters
681
682
Available keys:
683
    override_high_holds - Ignore high holds
684
    onsite_checkout     - Checkout is an onsite checkout that will not leave the library
685
680
=back
686
=back
681
687
682
Returns :
688
Returns :
Lines 757-763 sub CanBookBeIssued { Link Here
757
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
763
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
758
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
764
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
759
765
760
    my $onsite_checkout = $params->{onsite_checkout} || 0;
766
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
767
    my $override_high_holds = $params->{override_high_holds} || 0;
761
768
762
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
769
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
763
    my $issue = GetItemIssue($item->{itemnumber});
770
    my $issue = GetItemIssue($item->{itemnumber});
Lines 1073-1083 sub CanBookBeIssued { Link Here
1073
        my $check = checkHighHolds( $item, $borrower );
1080
        my $check = checkHighHolds( $item, $borrower );
1074
1081
1075
        if ( $check->{exceeded} ) {
1082
        if ( $check->{exceeded} ) {
1076
            $needsconfirmation{HIGHHOLDS} = {
1083
            if ($override_high_holds) {
1077
                num_holds  => $check->{outstanding},
1084
                $alerts{HIGHHOLDS} = {
1078
                duration   => $check->{duration},
1085
                    num_holds  => $check->{outstanding},
1079
                returndate => output_pref( $check->{due_date} ),
1086
                    duration   => $check->{duration},
1080
            };
1087
                    returndate => output_pref( $check->{due_date} ),
1088
                };
1089
            }
1090
            else {
1091
                $needsconfirmation{HIGHHOLDS} = {
1092
                    num_holds  => $check->{outstanding},
1093
                    duration   => $check->{duration},
1094
                    returndate => output_pref( $check->{due_date} ),
1095
                };
1096
            }
1081
        }
1097
        }
1082
    }
1098
    }
1083
1099
(-)a/circ/circulation.pl (-2 / +15 lines)
Lines 67-72 my $query = new CGI; Link Here
67
my $sessionID = $query->cookie("CGISESSID") ;
67
my $sessionID = $query->cookie("CGISESSID") ;
68
my $session = get_session($sessionID);
68
my $session = get_session($sessionID);
69
69
70
my $override_high_holds     = $query->param('override_high_holds');
71
my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
72
70
# branch and printer are now defined by the userenv
73
# branch and printer are now defined by the userenv
71
# but first we have to check if someone has tried to change them
74
# but first we have to check if someone has tried to change them
72
75
Lines 335-342 if (@$barcodes) { Link Here
335
  for my $barcode ( @$barcodes ) {
338
  for my $barcode ( @$barcodes ) {
336
    my $template_params = { barcode => $barcode };
339
    my $template_params = { barcode => $barcode };
337
    # always check for blockers on issuing
340
    # always check for blockers on issuing
338
    my ( $error, $question, $alerts ) =
341
    my ( $error, $question, $alerts ) = CanBookBeIssued(
339
    CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess, undef, { onsite_checkout => $onsite_checkout } );
342
        $borrower,
343
        $barcode, $datedue,
344
        $inprocess,
345
        undef,
346
        {
347
            onsite_checkout     => $onsite_checkout,
348
            override_high_holds => $override_high_holds || $override_high_holds_tmp || 0,
349
        }
350
    );
351
340
    my $blocker = $invalidduedate ? 1 : 0;
352
    my $blocker = $invalidduedate ? 1 : 0;
341
353
342
    $template_params->{alert} = $alerts;
354
    $template_params->{alert} = $alerts;
Lines 663-668 $template->param( Link Here
663
    canned_bor_notes_loop     => $canned_notes,
675
    canned_bor_notes_loop     => $canned_notes,
664
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
676
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
665
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
677
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
678
    override_high_holds       => $override_high_holds,
666
);
679
);
667
680
668
output_html_with_http_headers $query, $cookie, $template->output;
681
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-11 / +48 lines)
Lines 212-217 $(document).ready(function() { Link Here
212
    <div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]</div>
212
    <div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]</div>
213
[% END %]
213
[% END %]
214
214
215
[% IF alert.HIGHHOLDS %]
216
    <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>
217
[% END %]
218
215
[% IF ( NEEDSCONFIRMATION ) %]
219
[% IF ( NEEDSCONFIRMATION ) %]
216
<div class="yui-g">
220
<div class="yui-g">
217
221
Lines 304-310 $(document).ready(function() { Link Here
304
    </li>
308
    </li>
305
[% END %]
309
[% END %]
306
310
307
[% IF  HIGHHOLDS %]
311
[% IF HIGHHOLDS %]
308
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
312
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
309
[% END %]
313
[% END %]
310
314
Lines 319-334 $(document).ready(function() { Link Here
319
</ul>
323
</ul>
320
324
321
[% IF HIGHHOLDS %]
325
[% IF HIGHHOLDS %]
322
	<script language="JavaScript" type="text/javascript">
326
<script language="JavaScript" type="text/javascript">
323
	$(document).ready(function() {
327
$(document).ready(function() {
324
            $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
328
    [% IF !override_high_holds %]
325
            if ('[% duedatespec %]' === '') {
329
        $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
326
                $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
330
        if ('[% duedatespec %]' === '') {
327
            } else {
331
            $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
328
                $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
332
        } else {
329
            }
333
            $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
330
	});
334
        }
331
	</script>
335
    [% END %]
336
337
    $("#override_high_holds_tmp").on( 'change', function() {
338
        if ( this.checked ) {
339
            $("input[name=duedatespec]:hidden").val('');
340
        }
341
    });
342
});
343
</script>
332
[% END %]
344
[% END %]
333
345
334
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
346
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
Lines 337-342 $(document).ready(function() { Link Here
337
349
338
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
350
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
339
351
352
[% IF HIGHHOLDS %]
353
    <p>
354
    <input type="checkbox" name="override_high_holds_tmp" id="override_high_holds_tmp" value="1" />
355
    <label for="override_high_holds_tmp">Don't decrease loan length based on holds</label>
356
    </p>
357
[% END %]
358
340
[% IF ( RESERVED ) %]
359
[% IF ( RESERVED ) %]
341
    <p>
360
    <p>
342
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
361
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
Lines 356-361 $(document).ready(function() { Link Here
356
    <input type="hidden" name="barcode" value="[% barcode |html %]" />
375
    <input type="hidden" name="barcode" value="[% barcode |html %]" />
357
    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
376
    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
358
    <input type="hidden" name="issueconfirmed" value="1" />
377
    <input type="hidden" name="issueconfirmed" value="1" />
378
    <input type="hidden" name="override_high_holds" value="[% override_high_holds %]"/>
359
    [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
379
    [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
360
    [% IF ( INVALID_DATE ) %]
380
    [% IF ( INVALID_DATE ) %]
361
    <p>
381
    <p>
Lines 644-649 No patron matched <span class="ex">[% message %]</span> Link Here
644
            [% END %]
664
            [% END %]
645
665
646
            <label for="auto_renew">Automatic renewal</label>
666
            <label for="auto_renew">Automatic renewal</label>
667
668
            [% IF Koha.Preference('decreaseLoanHighHolds') %]
669
                [% IF NEEDSCONFIRMATION %]
670
                    [% IF override_high_holds %]
671
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled" checked="checked"/>
672
                    [% ELSE %]
673
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled"/>
674
                    [% END %]
675
                [% ELSE %]
676
                    [% IF override_high_holds %]
677
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" checked="checked" />
678
                    [% ELSE %]
679
                        <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" />
680
                    [% END %]
681
                [% END %]
682
                <label for="override_high_holds">Don't decrease loan length based on holds</label>
683
            [% END %]
647
        </div>
684
        </div>
648
    [% END %]
685
    [% END %]
649
686
(-)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