=head2 CanBookBeIssued
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower,
- $barcode, $duedate, $inprocess, $ignore_reserves );
+ $barcode, $duedate, $inprocess, $ignore_reserves, $params );
Check if a book can be issued.
=item C<$ignore_reserves> boolean switch
+=item C<$params> Hashref of additional parameters
+
+Available keys:
+ override_high_holds - Ignore high holds
+ onsite_checkout - Checkout is an onsite checkout that will not leave the library
+
=back
Returns :
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of.
- my $onsite_checkout = $params->{onsite_checkout} || 0;
+ my $onsite_checkout = $params->{onsite_checkout} || 0;
+ my $override_high_holds = $params->{override_high_holds} || 0;
my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
my $issue = GetItemIssue($item->{itemnumber});
my $check = checkHighHolds( $item, $borrower );
if ( $check->{exceeded} ) {
- $needsconfirmation{HIGHHOLDS} = {
- num_holds => $check->{outstanding},
- duration => $check->{duration},
- returndate => output_pref( $check->{due_date} ),
- };
+ if ($override_high_holds) {
+ $alerts{HIGHHOLDS} = {
+ num_holds => $check->{outstanding},
+ duration => $check->{duration},
+ returndate => output_pref( $check->{due_date} ),
+ };
+ }
+ else {
+ $needsconfirmation{HIGHHOLDS} = {
+ num_holds => $check->{outstanding},
+ duration => $check->{duration},
+ returndate => output_pref( $check->{due_date} ),
+ };
+ }
}
}
my $sessionID = $query->cookie("CGISESSID") ;
my $session = get_session($sessionID);
+my $override_high_holds = $query->param('override_high_holds');
+my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
+
# branch and printer are now defined by the userenv
# but first we have to check if someone has tried to change them
for my $barcode ( @$barcodes ) {
my $template_params = { barcode => $barcode };
# always check for blockers on issuing
- my ( $error, $question, $alerts ) =
- CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess, undef, { onsite_checkout => $onsite_checkout } );
+ my ( $error, $question, $alerts ) = CanBookBeIssued(
+ $borrower,
+ $barcode, $datedue,
+ $inprocess,
+ undef,
+ {
+ onsite_checkout => $onsite_checkout,
+ override_high_holds => $override_high_holds || $override_high_holds_tmp || 0,
+ }
+ );
+
my $blocker = $invalidduedate ? 1 : 0;
$template_params->{alert} = $alerts;
debarments => GetDebarments({ borrowernumber => $borrowernumber }),
todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
modifications => Koha::Patron::Modifications->GetModifications({ borrowernumber => $borrowernumber }),
+ override_high_holds => $override_high_holds,
);
output_html_with_http_headers $query, $cookie, $template->output;
<div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]</div>
[% END %]
+[% IF alert.HIGHHOLDS %]
+ <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>
+[% END %]
+
[% IF ( NEEDSCONFIRMATION ) %]
<div class="yui-g">
</li>
[% END %]
-[% IF HIGHHOLDS %]
+[% IF HIGHHOLDS %]
<li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
[% END %]
</ul>
[% IF HIGHHOLDS %]
- <script language="JavaScript" type="text/javascript">
- $(document).ready(function() {
- $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
- if ('[% duedatespec %]' === '') {
- $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
- } else {
- $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
- }
- });
- </script>
+<script language="JavaScript" type="text/javascript">
+$(document).ready(function() {
+ [% IF !override_high_holds %]
+ $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
+ if ('[% duedatespec %]' === '') {
+ $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
+ } else {
+ $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
+ }
+ [% END %]
+
+ $("#override_high_holds_tmp").on( 'change', function() {
+ if ( this.checked ) {
+ $("input[name=duedatespec]:hidden").val('');
+ }
+ });
+});
+</script>
[% END %]
[% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
+[% IF HIGHHOLDS %]
+ <p>
+ <input type="checkbox" name="override_high_holds_tmp" id="override_high_holds_tmp" value="1" />
+ <label for="override_high_holds_tmp">Don't decrease loan length based on holds</label>
+ </p>
+[% END %]
+
[% IF ( RESERVED ) %]
<p>
<input type="checkbox" id="cancelreserve" name="cancelreserve" value="cancel" />
<input type="hidden" name="barcode" value="[% barcode |html %]" />
<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="issueconfirmed" value="1" />
+ <input type="hidden" name="override_high_holds" value="[% override_high_holds %]"/>
[% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
[% IF ( INVALID_DATE ) %]
<p>
[% END %]
<label for="auto_renew">Automatic renewal</label>
+
+ [% IF Koha.Preference('decreaseLoanHighHolds') %]
+ [% IF NEEDSCONFIRMATION %]
+ [% IF override_high_holds %]
+ <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled" checked="checked"/>
+ [% ELSE %]
+ <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" disabled="disabled"/>
+ [% END %]
+ [% ELSE %]
+ [% IF override_high_holds %]
+ <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" checked="checked" />
+ [% ELSE %]
+ <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" />
+ [% END %]
+ [% END %]
+ <label for="override_high_holds">Don't decrease loan length based on holds</label>
+ [% END %]
</div>
[% END %]
use Koha::Hold;
use t::lib::TestBuilder;
-use Test::More tests => 12;
+use Test::More tests => 14;
my $dbh = C4::Context->dbh;
my $schema = Koha::Database->new()->schema();
my @items;
for my $i ( 1 .. 10 ) {
- my $item = Koha::Item->new( { biblionumber => $biblio->id(), biblioitemnumber => $biblioitem->id(), } )->store();
+ my $item = Koha::Item->new(
+ {
+ biblionumber => $biblio->id(),
+ biblioitemnumber => $biblioitem->id(),
+ barcode => $i
+ }
+ )->store();
push( @items, $item );
}
C4::Context->set_preference( 'decreaseLoanHighHoldsControl', 'static' );
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
-my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} };
+my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $item->barcode };
my $patron_hr = { borrower => $patron->id, branchcode => $library->{branchcode} };
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
+C4::Context->set_preference('CircControl', 'PatronLibrary');
+
+my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode );
+ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
+
+( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode, undef, undef, undef, { override_high_holds => 1 } );
+ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
+
$schema->storage->txn_rollback();
1;