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

(-)a/C4/Circulation.pm (-7 / +23 lines)
Lines 657-663 sub itemissues { Link Here
657
=head2 CanBookBeIssued
657
=head2 CanBookBeIssued
658
658
659
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
659
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
660
                      $barcode, $duedatespec, $inprocess, $ignore_reserves );
660
                      $barcode, $duedatespec, $inprocess, $ignore_reserves, $params );
661
661
662
Check if a book can be issued.
662
Check if a book can be issued.
663
663
Lines 674-679 C<$issuingimpossible> and C<$needsconfirmation> are some hashref. Link Here
674
=item C<$inprocess> boolean switch
674
=item C<$inprocess> boolean switch
675
=item C<$ignore_reserves> boolean switch
675
=item C<$ignore_reserves> boolean switch
676
676
677
=item C<$params> Hashref of additional parameters
678
679
Available keys:
680
    override_high_holds - Ignore high holds
681
    onsite_checkout     - Checkout is an onsite checkout that will not leave the library
682
677
=back
683
=back
678
684
679
Returns :
685
Returns :
Lines 754-760 sub CanBookBeIssued { Link Here
754
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
760
    my %issuingimpossible;    # filled with problems that causes the issue to be IMPOSSIBLE
755
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
761
    my %alerts;               # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
756
762
757
    my $onsite_checkout = $params->{onsite_checkout} || 0;
763
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
764
    my $override_high_holds = $params->{override_high_holds} || 0;
758
765
759
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
766
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
760
    my $issue = GetItemIssue($item->{itemnumber});
767
    my $issue = GetItemIssue($item->{itemnumber});
Lines 1068-1078 sub CanBookBeIssued { Link Here
1068
        my $check = checkHighHolds( $item, $borrower );
1075
        my $check = checkHighHolds( $item, $borrower );
1069
1076
1070
        if ( $check->{exceeded} ) {
1077
        if ( $check->{exceeded} ) {
1071
            $needsconfirmation{HIGHHOLDS} = {
1078
            if ($override_high_holds) {
1072
                num_holds  => $check->{outstanding},
1079
                $alerts{HIGHHOLDS} = {
1073
                duration   => $check->{duration},
1080
                    num_holds  => $check->{outstanding},
1074
                returndate => output_pref( $check->{due_date} ),
1081
                    duration   => $check->{duration},
1075
            };
1082
                    returndate => output_pref( $check->{due_date} ),
1083
                };
1084
            }
1085
            else {
1086
                $needsconfirmation{HIGHHOLDS} = {
1087
                    num_holds  => $check->{outstanding},
1088
                    duration   => $check->{duration},
1089
                    returndate => output_pref( $check->{due_date} ),
1090
                };
1091
            }
1076
        }
1092
        }
1077
    }
1093
    }
1078
1094
(-)a/circ/circulation.pl (-2 / +16 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
warn "OVER: $override_high_holds";
70
my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
71
68
# branch and printer are now defined by the userenv
72
# branch and printer are now defined by the userenv
69
# but first we have to check if someone has tried to change them
73
# but first we have to check if someone has tried to change them
70
74
Lines 300-307 if ($borrowernumber) { Link Here
300
#
304
#
301
if ($barcode) {
305
if ($barcode) {
302
    # always check for blockers on issuing
306
    # always check for blockers on issuing
303
    my ( $error, $question, $alerts ) =
307
    my ( $error, $question, $alerts ) = CanBookBeIssued(
304
    CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess, undef, { onsite_checkout => $onsite_checkout } );
308
        $borrower,
309
        $barcode, $datedue,
310
        $inprocess,
311
        undef,
312
        {
313
            onsite_checkout     => $onsite_checkout,
314
            override_high_holds => $override_high_holds || $override_high_holds_tmp || 0,
315
        }
316
    );
317
305
    my $blocker = $invalidduedate ? 1 : 0;
318
    my $blocker = $invalidduedate ? 1 : 0;
306
319
307
    $template->param( alert => $alerts );
320
    $template->param( alert => $alerts );
Lines 573-578 $template->param( Link Here
573
    canned_bor_notes_loop     => $canned_notes,
586
    canned_bor_notes_loop     => $canned_notes,
574
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
587
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
575
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
588
    todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
589
    override_high_holds       => $override_high_holds,
576
);
590
);
577
591
578
output_html_with_http_headers $query, $cookie, $template->output;
592
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-6 / +43 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 298-304 $(document).ready(function() { Link Here
298
    </li>
302
    </li>
299
[% END %]
303
[% END %]
300
304
301
[% IF  HIGHHOLDS %]
305
[% IF HIGHHOLDS %]
302
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
306
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
303
[% END %]
307
[% END %]
304
308
Lines 313-323 $(document).ready(function() { Link Here
313
</ul>
317
</ul>
314
318
315
[% IF HIGHHOLDS %]
319
[% IF HIGHHOLDS %]
316
	<script language="JavaScript" type="text/javascript">
320
<script language="JavaScript" type="text/javascript">
317
	$(document).ready(function() {
321
$(document).ready(function() {
318
		$("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
322
    [% IF !override_high_holds %]
319
	});
323
        $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
320
	</script>
324
    [% END %]
325
326
    $("#override_high_holds_tmp").on( 'change', function() {
327
        if ( this.checked ) {
328
            $("input[name=duedatespec]:hidden").val('');
329
        }
330
    });
331
});
332
</script>
321
[% END %]
333
[% END %]
322
334
323
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
335
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
Lines 325-330 $(document).ready(function() { Link Here
325
337
326
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
338
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
327
339
340
[% IF HIGHHOLDS %]
341
    <p>
342
    <input type="checkbox" name="override_high_holds_tmp" id="override_high_holds_tmp" value="1" />
343
    <label for="override_high_holds_tmp">Don't decrease loan length based on holds</label>
344
    </p>
345
[% END %]
346
328
[% IF ( RESERVED ) %]
347
[% IF ( RESERVED ) %]
329
    <p>
348
    <p>
330
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
349
    <input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
Lines 344-349 $(document).ready(function() { Link Here
344
    <input type="hidden" name="barcode" value="[% barcode |html %]" />
363
    <input type="hidden" name="barcode" value="[% barcode |html %]" />
345
    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
364
    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
346
    <input type="hidden" name="issueconfirmed" value="1" />
365
    <input type="hidden" name="issueconfirmed" value="1" />
366
    <input type="hidden" name="override_high_holds" value="[% override_high_holds %]"/>
347
    [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
367
    [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
348
    [% IF ( INVALID_DATE ) %]
368
    [% IF ( INVALID_DATE ) %]
349
    <p>
369
    <p>
Lines 636-641 No patron matched <span class="ex">[% message %]</span> Link Here
636
            <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" />
656
            <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" />
637
        [% END %]
657
        [% END %]
638
        <label for="auto_renew">Automatic renewal</label>
658
        <label for="auto_renew">Automatic renewal</label>
659
660
        [% IF Koha.Preference('decreaseLoanHighHolds') %]
661
            [% IF NEEDSCONFIRMATION %]
662
                [% IF override_high_holds %]
663
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled" checked="checked"/>
664
                [% ELSE %]
665
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled"/>
666
                [% END %]
667
            [% ELSE %]
668
                [% IF override_high_holds %]
669
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" checked="checked" />
670
                [% ELSE %]
671
                    <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" />
672
                [% END %]
673
            [% END %]
674
            <label for="override_high_holds">Don't decrease loan length based on holds</label>
675
        [% END %]
639
    </div>
676
    </div>
640
677
641
    [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %]
678
    [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %]
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-5 / +18 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 101-107 C4::Context->set_preference( 'decreaseLoanHighHoldsControl', 'dynamic' ); Link Here
101
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
107
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
102
is( $data->{exceeded}, 0, "Should not exceed threshold" );
108
is( $data->{exceeded}, 0, "Should not exceed threshold" );
103
109
104
for my $i ( 5 .. 10 ) {
110
for my $i ( 5 .. 11 ) {
105
    my $patron = $patrons[$i];
111
    my $patron = $patrons[$i];
106
    my $hold   = Koha::Hold->new(
112
    my $hold   = Koha::Hold->new(
107
        {
113
        {
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, { override_high_holds => 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