Bugzilla – Attachment 9810 Details for
Bug 7751
Decrease loan period on items with a high number of holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7751 : Decrease Loans for Items with Highholds
Bug-7751-Highhilds.patch (text/plain), 12.53 KB, created by
Martin Renvoize (ashimema)
on 2012-05-29 07:36:48 UTC
(
hide
)
Description:
Bug 7751 : Decrease Loans for Items with Highholds
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2012-05-29 07:36:48 UTC
Size:
12.53 KB
patch
obsolete
>From c03f495e7dccb462eb3832ac515539f9aa717579 Mon Sep 17 00:00:00 2001 >From: Mark Gavillet <mark.gavillet@ptfs-europe.com> >Date: Wed, 4 May 2011 12:41:41 +0100 >Subject: [PATCH] Bug 7751 : Decrease loan period on checkout for items with high holds > >--- > C4/Circulation.pm | 63 ++++++++++++++++++++ > installer/decreaseLoanHighHolds_sysprefs.sql | 11 ++++ > .../prog/en/modules/circ/circulation.tt | 11 ++++ > 3 files changed, 85 insertions(+), 0 deletions(-) > create mode 100644 installer/decreaseLoanHighHolds_sysprefs.sql > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c26de76..670bd3d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -927,9 +927,72 @@ sub CanBookBeIssued { > } > } > } >+ >+ ## check for high holds decreasing loan period >+ if (C4::Context->preference("decreaseLoanHighHolds") == 1) >+ { >+ my ($reserved,$num,$duration,$returndate)=checkHighHolds($item,$borrower); >+ #print "reserved: $reserved\n".Dumper($num); >+ if ($num>=C4::Context->preference("decreaseLoanHighHoldsValue")) >+ { >+ $needsconfirmation{HIGHHOLDS} = 1; >+ $needsconfirmation{'num_holds'} = $num; >+ $needsconfirmation{'duration'} = $duration; >+ $needsconfirmation{'returndate'} = format_date($returndate); >+ } >+ } >+ > return ( \%issuingimpossible, \%needsconfirmation ); > } > >+=head2 CheckHighHolds >+ >+ used when syspref decreaseLoanHighHolds is active. Returns 1 or 0 to define whether the minimum value held in >+ decreaseLoanHighHoldsValue is exceeded, the total number of outstanding holds, the number of days the loan >+ has been decreased to (held in syspref decreaseLoanHighHoldsValue), and the new due date >+ >+=cut >+ >+sub checkHighHolds { >+ my ($item,$borrower) = @_; >+ my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); >+ my $branch = _GetCircControlBranch($item,$borrower); >+ my $dbh = C4::Context->dbh; >+ my $sth; >+ $sth = $dbh->prepare("select count(borrowernumber) as num_holds from reserves where biblionumber=?"); >+ $sth->execute($item->{'biblionumber'}); >+ my $holds = $sth->fetchrow_array; >+ if ($holds>0) >+ { >+ my $issuedate = strftime( "%Y-%m-%d", localtime ); >+ my $startdate=C4::Dates->new( $issuedate, 'iso' ); >+ my $calendar = C4::Calendar->new( branchcode => $branch ); >+ >+ my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; >+ my $due = C4::Circulation::CalcDateDue( C4::Dates->new( $issuedate, 'iso' ), $itype, $branch, $borrower ); >+ my $normaldue = sprintf("%04d-%02d-%02d",($due->{'dmy_arrayref'}[5]+1900),($due->{'dmy_arrayref'}[4]+1), >+ $due->{'dmy_arrayref'}[3]); >+ >+ my $datedue = $calendar->addDate($startdate, C4::Context->preference("decreaseLoanHighHoldsDuration")); >+ my $returndate = sprintf("%04d-%02d-%02d",($datedue->{'dmy_arrayref'}[5]+1900),($datedue->{'dmy_arrayref'}[4]+1), >+ $datedue->{'dmy_arrayref'}[3]); >+ >+ my $daysBetween = $calendar->daysBetween($datedue, $due); >+ if ($daysBetween>0) >+ { >+ return (1,$holds,C4::Context->preference("decreaseLoanHighHoldsDuration"),$returndate); >+ } >+ else >+ { >+ return (0,0,0,0); >+ } >+ } >+ else >+ { >+ return (0,0,0,0); >+ } >+} >+ > =head2 AddIssue > > &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate]) >diff --git a/installer/decreaseLoanHighHolds_sysprefs.sql b/installer/decreaseLoanHighHolds_sysprefs.sql >new file mode 100644 >index 0000000..dcf0bd0 >--- /dev/null >+++ b/installer/decreaseLoanHighHolds_sysprefs.sql >@@ -0,0 +1,11 @@ >+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'); >+ >+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'); >+ >+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'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 1bceb0c..cf75962 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -284,8 +284,19 @@ function refocus(calendar) { > [% IF ( ITEM_LOST ) %] > <li>This item has been lost with a status of "[% ITEM_LOST %]". Check out anyway?</li> > [% END %] >+ >+[% IF ( HIGHHOLDS ) %] >+ <li>High demand item. Loan period shortened to [% duration %] days (due [% returndate %]). Check out anyway?</li> >+[% END %] > </ul> > >+[% IF ( HIGHHOLDS ) %] >+ <script language="JavaScript" type="text/javascript"> >+ $(document).ready(function() { >+ $("input[name=duedatespec]:hidden").val('[% returndate %]'); >+ }); >+ </script> >+[% END %] > <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off"> > > [% IF ( RESERVED ) %] >-- >1.7.2.5 > > >From 1f2edbfb788f977e155d1957302596174812d170 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Wed, 29 Jun 2011 17:25:49 +0100 >Subject: [PATCH] Bug 7751 : HIGHHOLDS should be a single datastructure > >Data returned with HIGHHOLDS was being returned on the same >level as the flag so that it might be interpreted as further >items requiring confirmation. >Instead of HIGHHOLDS being returned as a flag return it as a >data structure containing that data. Change template to >reflect this > >Conflicts: > > C4/Circulation.pm >--- > C4/Circulation.pm | 9 +++++---- > .../prog/en/modules/circ/circulation.tt | 8 ++++---- > 2 files changed, 9 insertions(+), 8 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 670bd3d..b57455e 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -935,10 +935,11 @@ sub CanBookBeIssued { > #print "reserved: $reserved\n".Dumper($num); > if ($num>=C4::Context->preference("decreaseLoanHighHoldsValue")) > { >- $needsconfirmation{HIGHHOLDS} = 1; >- $needsconfirmation{'num_holds'} = $num; >- $needsconfirmation{'duration'} = $duration; >- $needsconfirmation{'returndate'} = format_date($returndate); >+ $needsconfirmation{HIGHHOLDS} = { >+ num_holds => $num, >+ duration => $duration, >+ returndate => format_date($returndate), >+ }; > } > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index cf75962..39153fa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -285,15 +285,15 @@ function refocus(calendar) { > <li>This item has been lost with a status of "[% ITEM_LOST %]". Check out anyway?</li> > [% END %] > >-[% IF ( HIGHHOLDS ) %] >- <li>High demand item. Loan period shortened to [% duration %] days (due [% returndate %]). Check out anyway?</li> >+[% IF HIGHHOLDS %] >+ <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li> > [% END %] > </ul> > >-[% IF ( HIGHHOLDS ) %] >+[% IF HIGHHOLDS %] > <script language="JavaScript" type="text/javascript"> > $(document).ready(function() { >- $("input[name=duedatespec]:hidden").val('[% returndate %]'); >+ $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]'); > }); > </script> > [% END %] >-- >1.7.2.5 > > >From f5a5b92d4bd349ed437299a05301a0f4d2b83804 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Mon, 27 Jun 2011 12:15:50 +0100 >Subject: [PATCH] Bug 7751 : Self Check should recognize Reduced Loan Periods > >Staffs Reduced Loan feature returns the reduced >due date as 'needs confirm' Self Check should apply it as >due date when adding the issue > >Conflicts: > > C4/SIP/ILS/Transaction/Checkout.pm >--- > C4/SIP/ILS/Transaction/Checkout.pm | 10 +++++++--- > 1 files changed, 7 insertions(+), 3 deletions(-) > >diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm >index d483e16..6cc3437 100644 >--- a/C4/SIP/ILS/Transaction/Checkout.pm >+++ b/C4/SIP/ILS/Transaction/Checkout.pm >@@ -55,6 +55,7 @@ sub do_checkout { > my $shelf = $self->{item}->hold_shelf; > my $barcode = $self->{item}->id; > my $patron_barcode = $self->{patron}->id; >+ my $overridden_duedate; # usually passed as undef to AddIssue > $debug and warn "do_checkout: patron (" . $patron_barcode . ")"; > my $borrower = $self->{patron}->getmemberdetails_object(); > $debug and warn "do_checkout borrower: . " . Dumper $borrower; >@@ -73,7 +74,7 @@ sub do_checkout { > $noerror = 0; > } > } else { >- foreach my $confirmation (keys %$needsconfirmation) { >+ foreach my $confirmation (keys %{$needsconfirmation}) { > if ($confirmation eq 'RENEW_ISSUE'){ > $self->screen_msg("Item already checked out to you: renewing item."); > } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') { >@@ -88,6 +89,9 @@ sub do_checkout { > $self->screen_msg("Item already checked out to another patron. Please return item for check-in."); > $noerror = 0; > } elsif ($confirmation eq 'DEBT') { # don't do anything, it's the minor debt, and alarms fire elsewhere >+ } elsif ($confirmation eq 'HIGHHOLDS') { >+ $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate}; >+ $self->screen_msg('Loan period reduced for high-demand item'); > } else { > $self->screen_msg($needsconfirmation->{$confirmation}); > $noerror = 0; >@@ -119,10 +123,10 @@ sub do_checkout { > # TODO: adjust representation in $self->item > } > # can issue >- $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, undef, 0)\n" >+ $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n" > # . "w/ \$borrower: " . Dumper($borrower) > . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv); >- my $due_dt = AddIssue($borrower, $barcode, undef, 0); >+ my $due_dt = AddIssue($borrower, $barcode, $overridden_duedate, 0); > if ($due_dt) { > $self->{due} = $due_dt->clone(); > } else { >-- >1.7.2.5 > > >From 3f95cd14d57e64adce80307babd3b9b5d33a1147 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 28 May 2012 16:33:35 +0100 >Subject: [PATCH] Bug 7751 : Added sysprefs to circulation.pref (removed from "Local use") > >--- > .../en/modules/admin/preferences/circulation.pref | 16 ++++++++++++++++ > 1 files changed, 16 insertions(+), 0 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 471aa0e..fc60c4c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -350,6 +350,22 @@ Circulation: > yes: Allow > no: "Don't allow" > - suspended holds to be automatically resumed by a set date. >+ - >+ - pref: decreaseLoanHighHolds >+ choices: >+ yes: Enable >+ no: "Don't enable" >+ - the reduction of loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue >+ - >+ - A loan should be reduced by >+ - pref: decreaseLoanHighHoldsDuration >+ class: integer >+ - days, when decreaseLoanHighHoldsValue threshold is reached (if decreaseLoanHighHolds is enabled) >+ - >+ - A loan should be reduced by decreaseLoanHighHoldsDuration when >+ - pref: decreaseLoanHighHoldsValue >+ class: integer >+ - holds have been places (if decreaseLoanHighHolds is enables) > Fines Policy: > - > - Calculate fines based on days overdue >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7751
:
8313
|
8314
|
8315
|
9801
|
9803
|
9804
|
9810
|
9811
|
9812
|
9834
|
10040
|
10199
|
10204
|
11477
|
11672
|
11676
|
12337
|
12345
|
12528
|
12643
|
12786
|
12787
|
12802
|
12803