Bugzilla – Attachment 8313 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 loan period on checkout for items with high holds
Bug-7751--Decrease-loan-period-on-checkout-for-ite.patch (text/plain), 5.43 KB, created by
Chris Cormack
on 2012-03-19 21:02:16 UTC
(
hide
)
Description:
Bug 7751 : Decrease loan period on checkout for items with high holds
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2012-03-19 21:02:16 UTC
Size:
5.43 KB
patch
obsolete
>From c784250cdc00ac21db0c1c90250847f06fe35229 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 | 10 +++ > 3 files changed, 84 insertions(+), 0 deletions(-) > create mode 100644 installer/decreaseLoanHighHolds_sysprefs.sql > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 999f617..8bfbfc0 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -913,9 +913,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 1d0e07a..5b9006b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -278,8 +278,18 @@ function refocus(calendar) { > [% IF ( USERBLOCKEDOVERDUE ) %] > <li>Patron has [% USERBLOCKEDOVERDUE %] overdue item(s). 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.5.4
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