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

(-)a/C4/Circulation.pm (+60 lines)
Lines 941-949 sub CanBookBeIssued { Link Here
941
            }
941
            }
942
        }
942
        }
943
    }
943
    }
944
945
    ## check for high holds decreasing loan period
946
    my $decrease_loan = C4::Context->preference('decreaseLoanHighHolds');
947
    if ( $decrease_loan && $decrease_loan == 1 ) {
948
        my ( $reserved, $num, $duration, $returndate ) =
949
          checkHighHolds( $item, $borrower );
950
951
        if ( $num >= C4::Context->preference('decreaseLoanHighHoldsValue') ) {
952
            $needsconfirmation{HIGHHOLDS} = {
953
                num_holds  => $num,
954
                duration   => $duration,
955
                returndate => output_pref($returndate),
956
            };
957
        }
958
    }
959
944
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
960
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
945
}
961
}
946
962
963
=head2 CheckHighHolds
964
965
    used when syspref decreaseLoanHighHolds is active. Returns 1 or 0 to define whether the minimum value held in
966
    decreaseLoanHighHoldsValue is exceeded, the total number of outstanding holds, the number of days the loan
967
    has been decreased to (held in syspref decreaseLoanHighHoldsValue), and the new due date
968
969
=cut
970
971
sub checkHighHolds {
972
    my ( $item, $borrower ) = @_;
973
    my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
974
    my $branch = _GetCircControlBranch( $item, $borrower );
975
    my $dbh    = C4::Context->dbh;
976
    my $sth    = $dbh->prepare(
977
'select count(borrowernumber) as num_holds from reserves where biblionumber=?'
978
    );
979
    $sth->execute( $item->{'biblionumber'} );
980
    my ($holds) = $sth->fetchrow_array;
981
    if ($holds) {
982
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
983
984
        my $calendar = Koha::Calendar->new( branchcode => $branch );
985
986
        my $itype =
987
          ( C4::Context->preference('item-level_itypes') )
988
          ? $biblio->{'itype'}
989
          : $biblio->{'itemtype'};
990
        my $orig_due =
991
          C4::Circulation::CalcDateDue( $issuedate, $itype, $branch,
992
            $borrower );
993
994
        my $reduced_datedue =
995
          $calendar->addDate( $issuedate,
996
            C4::Context->preference('decreaseLoanHighHoldsDuration') );
997
998
        if ( DateTime->compare( $reduced_datedue, $orig_due ) == -1 ) {
999
            return ( 1, $holds,
1000
                C4::Context->preference('decreaseLoanHighHoldsDuration'),
1001
                $reduced_datedue );
1002
        }
1003
    }
1004
    return ( 0, 0, 0, undef );
1005
}
1006
947
=head2 AddIssue
1007
=head2 AddIssue
948
1008
949
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
1009
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
(-)a/C4/SIP/ILS/Transaction/Checkout.pm (-3 / +7 lines)
Lines 54-59 sub do_checkout { Link Here
54
	my $shelf          = $self->{item}->hold_shelf;
54
	my $shelf          = $self->{item}->hold_shelf;
55
	my $barcode        = $self->{item}->id;
55
	my $barcode        = $self->{item}->id;
56
	my $patron_barcode = $self->{patron}->id;
56
	my $patron_barcode = $self->{patron}->id;
57
        my $overridden_duedate; # usually passed as undef to AddIssue
57
	$debug and warn "do_checkout: patron (" . $patron_barcode . ")";
58
	$debug and warn "do_checkout: patron (" . $patron_barcode . ")";
58
	my $borrower = $self->{patron}->getmemberdetails_object();
59
	my $borrower = $self->{patron}->getmemberdetails_object();
59
	$debug and warn "do_checkout borrower: . " . Dumper $borrower;
60
	$debug and warn "do_checkout borrower: . " . Dumper $borrower;
Lines 72-78 sub do_checkout { Link Here
72
            $noerror = 0;
73
            $noerror = 0;
73
        }
74
        }
74
    } else {
75
    } else {
75
        foreach my $confirmation (keys %$needsconfirmation) {
76
        foreach my $confirmation (keys %{$needsconfirmation}) {
76
            if ($confirmation eq 'RENEW_ISSUE'){
77
            if ($confirmation eq 'RENEW_ISSUE'){
77
                $self->screen_msg("Item already checked out to you: renewing item.");
78
                $self->screen_msg("Item already checked out to you: renewing item.");
78
            } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
79
            } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
Lines 87-92 sub do_checkout { Link Here
87
                $self->screen_msg("Item already checked out to another patron.  Please return item for check-in.");
88
                $self->screen_msg("Item already checked out to another patron.  Please return item for check-in.");
88
                $noerror = 0;
89
                $noerror = 0;
89
            } elsif ($confirmation eq 'DEBT') {     # don't do anything, it's the minor debt, and alarms fire elsewhere
90
            } elsif ($confirmation eq 'DEBT') {     # don't do anything, it's the minor debt, and alarms fire elsewhere
91
            } elsif ($confirmation eq 'HIGHHOLDS') {
92
                $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate};
93
                $self->screen_msg('Loan period reduced for high-demand item');
90
            } else {
94
            } else {
91
                $self->screen_msg($needsconfirmation->{$confirmation});
95
                $self->screen_msg($needsconfirmation->{$confirmation});
92
                $noerror = 0;
96
                $noerror = 0;
Lines 118-127 sub do_checkout { Link Here
118
        # TODO: adjust representation in $self->item
122
        # TODO: adjust representation in $self->item
119
    }
123
    }
120
	# can issue
124
	# can issue
121
	$debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, undef, 0)\n"
125
	$debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n"
122
		# . "w/ \$borrower: " . Dumper($borrower)
126
		# . "w/ \$borrower: " . Dumper($borrower)
123
		. "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
127
		. "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
124
	my $due_dt  = AddIssue($borrower, $barcode, undef, 0);
128
	my $due_dt  = AddIssue($borrower, $barcode, $overridden_duedate, 0);
125
    if ($due_dt) {
129
    if ($due_dt) {
126
        $self->{due} = $due_dt->clone();
130
        $self->{due} = $due_dt->clone();
127
    } else {
131
    } else {
(-)a/installer/data/mysql/sysprefs.sql (+3 lines)
Lines 364-369 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( Link Here
364
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
364
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
365
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
365
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
366
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
366
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
367
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('decreaseLoanHighHolds', NULL, '', 'Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue', 'YesNo');
368
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('decreaseLoanHighHoldsValue', NULL, '', 'Specifies a threshold for the minimum number of holds needed to trigger a reduction in loan duration (used with decreaseLoanHighHolds)', 'Integer');
369
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('decreaseLoanHighHoldsDuration', NULL, '', 'Specifies a number of days that a loan is reduced to when used in conjunction with decreaseLoanHighHolds', 'Integer');
367
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
370
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
368
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IssueLostItem', 'alert', 'alert|confirm|nothing', 'Defines what should be done when an attempt is made to issue an item that has been marked as lost.', 'Choice');
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IssueLostItem', 'alert', 'alert|confirm|nothing', 'Defines what should be done when an attempt is made to issue an item that has been marked as lost.', 'Choice');
369
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+16 lines)
Lines 377-382 Circulation: Link Here
377
                  yes: Allow
377
                  yes: Allow
378
                  no: "Don't allow"
378
                  no: "Don't allow"
379
            - holds to be suspended from the OPAC.
379
            - holds to be suspended from the OPAC.
380
        -
381
            - pref: decreaseLoanHighHolds
382
              choices:
383
                  yes: Enable
384
                  no:  "Don't enable"
385
            - the reduction of loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue
386
        -
387
            - A loan should be reduced by  
388
            - pref: decreaseLoanHighHoldsDuration
389
              class: integer
390
            - days, when decreaseLoanHighHoldsValue threshold is reached (if decreaseLoanHighHolds is enabled)
391
        -
392
            - A loan should be reduced by decreaseLoanHighHoldsDuration when 
393
            - pref: decreaseLoanHighHoldsValue
394
              class: integer
395
            - holds have been places (if decreaseLoanHighHolds is enables)
380
    Fines Policy:
396
    Fines Policy:
381
        -
397
        -
382
            - Calculate fines based on days overdue
398
            - Calculate fines based on days overdue
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +11 lines)
Lines 289-296 function validate1(date) { Link Here
289
[% IF ( ITEM_LOST ) %]
289
[% IF ( ITEM_LOST ) %]
290
    <li>This item has been lost with a status of "[% ITEM_LOST %]". Check out anyway?</li>
290
    <li>This item has been lost with a status of "[% ITEM_LOST %]". Check out anyway?</li>
291
[% END %]
291
[% END %]
292
293
[% IF  HIGHHOLDS %]
294
	<li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
295
[% END %]
292
</ul>
296
</ul>
293
297
298
[% IF HIGHHOLDS %]
299
	<script language="JavaScript" type="text/javascript">
300
	$(document).ready(function() {
301
		$("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
302
	});
303
	</script>
304
[% END %]
294
<form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
305
<form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
295
306
296
[% IF ( RESERVED ) %]
307
[% IF ( RESERVED ) %]
297
- 

Return to bug 7751