Bugzilla – Attachment 28427 Details for
Bug 11577
Automatic renewals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11577: Code and intranet template changes
Bug-11577-Code-and-intranet-template-changes.patch (text/plain), 13.70 KB, created by
Holger Meißner
on 2014-05-22 12:17:24 UTC
(
hide
)
Description:
Bug 11577: Code and intranet template changes
Filename:
MIME Type:
Creator:
Holger Meißner
Created:
2014-05-22 12:17:24 UTC
Size:
13.70 KB
patch
obsolete
>From b8cf34f8dffdad536f0903653f4401d1a3021b3e Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Holger=20Mei=C3=9Fner?= <h.meissner.82@web.de> >Date: Thu, 15 May 2014 16:43:00 +0200 >Subject: [PATCH] Bug 11577: Code and intranet template changes >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds a checkbox for "Automatic renewal" to the checkout page. >CanBookBeRenewed is modified to include two new errors: > >- auto_renew (renewal shouldn't be done manually) >- auto_too_soon (renewal is premature and shouldn't be done manually) > >To test: > >1) Add or edit an issuing rule with "Automatic renewal" and another > one without it. > >2) Issue at least three items: > > - automatic renewal by issuing rule > - automatic renewal by Checkbox on the checkout page > - no automatic renewal > >3) Test the following steps for both: > > Home > Circulation > Checkouts > Home > Patrons > Patron details > >4) Confirm that issues with automatic renewal cannot be renewed manually, > even if there are still renewals left and it's not too soon to renew. > >5) Confirm that "Automatic renewal" and the remaining renewals are > displayed. If no renewals are left "Not renewable" should be displayed. > >6) Confirm that issues without automatic renewal behave as usual. > >Sponsored-by: Hochschule für Gesundheit (hsg), Germany >--- > C4/Circulation.pm | 67 ++++++++++---------- > circ/circulation.pl | 7 +- > .../prog/en/modules/circ/circulation.tt | 19 +++++- > .../prog/en/modules/members/moremember.tt | 5 +- > 4 files changed, 61 insertions(+), 37 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 639956b..d672ce2 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1176,7 +1176,7 @@ AddIssue does the following things : > =cut > > sub AddIssue { >- my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; >+ my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $auto_renew ) = @_; > my $dbh = C4::Context->dbh; > my $barcodecheck=CheckValidBarcode($barcode); > if ($datedue && ref $datedue ne 'DateTime') { >@@ -1242,12 +1242,18 @@ sub AddIssue { > $sth->execute(C4::Context->userenv->{'branch'},$item->{'itemnumber'}); > } > >+ # If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. >+ unless ($auto_renew) { >+ my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch); >+ $auto_renew = $issuingrule->{auto_renew}; >+ } >+ > # Record in the database the fact that the book was issued. > my $sth = > $dbh->prepare( > "INSERT INTO issues >- (borrowernumber, itemnumber,issuedate, date_due, branchcode) >- VALUES (?,?,?,?,?)" >+ (borrowernumber, itemnumber,issuedate, date_due, branchcode, auto_renew) >+ VALUES (?,?,?,?,?,?)" > ); > unless ($datedue) { > my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; >@@ -1260,7 +1266,8 @@ sub AddIssue { > $item->{'itemnumber'}, # itemnumber > $issuedate->strftime('%Y-%m-%d %H:%M:00'), # issuedate > $datedue->strftime('%Y-%m-%d %H:%M:00'), # date_due >- C4::Context->userenv->{'branch'} # branchcode >+ C4::Context->userenv->{'branch'}, # branchcode >+ $auto_renew ? 1 : 0 # automatic renewal > ); > if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart. > CartToShelf( $item->{'itemnumber'} ); >@@ -2553,7 +2560,9 @@ C<$itemnumber> is the number of the item to renew. > > C<$override_limit>, if supplied with a true value, causes > the limit on the number of times that the loan can be renewed >-(as controlled by the item type) to be ignored. >+(as controlled by the item type) to be ignored. Overriding also allows >+to renew sooner than "No renewal before" und to manually renew loans >+that are automatically renewed. > > C<$CanBookBeRenewed> returns a true value if the item may be renewed. The > item must currently be on loan to the specified borrower; renewals >@@ -2565,10 +2574,8 @@ already renewed the loan. $error will contain the reason the renewal can not pro > sub CanBookBeRenewed { > my ( $borrowernumber, $itemnumber, $override_limit ) = @_; > >- my $dbh = C4::Context->dbh; >- my $renews = 1; >- my $renewokay = 1; >- my $error; >+ my $dbh = C4::Context->dbh; >+ my $renews = 1; > > my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); > my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' ); >@@ -2577,42 +2584,36 @@ sub CanBookBeRenewed { > my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) > or return; > >- my $branchcode = _GetCircControlBranch($item, $borrower); >+ my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber); > >- my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); >+ return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found >+ >+ return ( 1, undef ) if $override_limit; >+ >+ my $branchcode = _GetCircControlBranch( $item, $borrower ); >+ my $issuingrule = >+ GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode ); >+ >+ return ( 0, "too_many" ) >+ if $issuingrule->{renewalsallowed} <= $itemissue->{renewals}; > > if ( $issuingrule->{norenewalbefore} ) { > >- # Get current time and add norenewalbefore. If this is smaller than date_due, it's too soon for renewal. >+ # Get current time and add norenewalbefore. >+ # If this is smaller than date_due, it's too soon for renewal. > if ( > DateTime->now( time_zone => C4::Context->tz() )->add( > $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} > ) < $itemissue->{date_due} >- ) >+ ) > { >- $renewokay = 0; >- $error = "too_soon"; >+ return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; >+ return ( 0, "too_soon" ); > } > } > >- if ( $issuingrule->{renewalsallowed} <= $itemissue->{renewals} ) { >- $renewokay = 0; >- $error = "too_many"; >- } >- >- if ( $override_limit ) { >- $renewokay = 1; >- $error = undef; >- } >- >- my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber ); >- >- if ( $resfound ) { # '' when no hold was found >- $renewokay = 0; >- $error = "on_reserve"; >- } >- >- return ( $renewokay, $error ); >+ return ( 0, "auto_renew" ) if $itemissue->{auto_renew}; >+ return ( 1, undef ); > } > > =head2 AddRenewal >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 91851d2..0bce117 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -145,6 +145,10 @@ if ( $barcode ) { > $stickyduedate = $query->param('stickyduedate'); > $duedatespec = $query->param('duedatespec'); > } >+ $session->param('auto_renew', $query->param('auto_renew')); >+} >+else { >+ $session->clear('auto_renew'); > } > > my ($datedue,$invalidduedate); >@@ -355,7 +359,8 @@ if ($barcode) { > } > } > unless($confirm_required) { >- AddIssue( $borrower, $barcode, $datedue, $cancelreserve ); >+ AddIssue( $borrower, $barcode, $datedue, $cancelreserve, undef, undef, $session->param('auto_renew') ); >+ $session->clear('auto_renew'); > $inprocess = 1; > } > } >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 6805126..b33d8c5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -528,6 +528,15 @@ No patron matched <span class="ex">[% message %]</span> > [% END %] > <input type="submit" value="Check Out" /> > >+ <div class="date-select"> >+ [% IF NEEDSCONFIRMATION %] >+ <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled" /> >+ [% ELSE %] >+ <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" /> >+ [% END %] >+ <label for="auto_renew">Automatic renewal</label> >+ </div> >+ > [% IF ( SpecifyDueDate ) %]<div class="date-select"> > <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div> > [% IF ( duedatespec ) %]<input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />[% ELSE %]<input type="text" size="13" id="duedatespec" name="duedatespec" value="" readonly="readonly" /> >@@ -789,7 +798,7 @@ No patron matched <span class="ex">[% message %]</span> > <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" /> > [% END %] > </span> >- [% IF todayissue.renewsallowed && todayissue.renewsleft && !todayissue.renew_error_too_soon %] >+ [% IF todayissue.renewsallowed && todayissue.renewsleft && !todayissue.renew_error_too_soon && !todayissue.renew_error_auto_renew && !todayissue.renew_error_auto_too_soon %] > <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span> > [% END %] > <span class="renewals-disabled"> >@@ -798,6 +807,9 @@ No patron matched <span class="ex">[% message %]</span> > <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% todayissue.biblionumber %]">On hold</a> > [% ELSIF ( todayissue.renew_error_too_many ) %] > Not renewable >+ [% ELSIF ( todayissue.renew_error_auto_renew || todayissue.renew_error_auto_too_soon ) %] >+ Automatic renewal >+ <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span> > [% ELSIF ( todayissue.renew_error_too_soon ) %] > No renewal before [% todayissue.soonestrenewdate %] > <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span> >@@ -886,7 +898,7 @@ No patron matched <span class="ex">[% message %]</span> > <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" /> > [% END %] > </span> >- [% IF previssue.renewsallowed && previssue.renewsleft && !previssue.renew_error_too_soon %] >+ [% IF previssue.renewsallowed && previssue.renewsleft && !previssue.renew_error_too_soon && !previssue.renew_error_auto_renew && !previssue.renew_error_auto_too_soon %] > <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span> > [% END %] > <span class="renewals-disabled"> >@@ -895,6 +907,9 @@ No patron matched <span class="ex">[% message %]</span> > <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% previssue.biblionumber %]">On Hold</a> > [% ELSIF ( previssue.renew_error_too_many ) %] > Not renewable >+ [% ELSIF ( previssue.renew_error_auto_renew || previssue.renew_error_auto_too_soon ) %] >+ Automatic renewal >+ <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span> > [% ELSIF ( previssue.renew_error_too_soon ) %] > No renewal before [% previssue.soonestrenewdate %] > <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 345c728..59caab4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -497,7 +497,7 @@ function validate1(date) { > <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" /> > [% END %] > </span> >- [% IF issueloo.renewsallowed && issueloo.renewsleft && !issueloo.norenew_reason_too_soon %] >+ [% IF issueloo.renewsallowed && issueloo.renewsleft && !issueloo.norenew_reason_too_soon && !issueloo.norenew_reason_auto_renew && !issueloo.norenew_reason_auto_too_soon %] > <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span> > [% END %] > <span class="renewals-disabled"> >@@ -506,6 +506,9 @@ function validate1(date) { > <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% issueloo.biblionumber %]">On Hold</a> > [% ELSIF ( issueloo.norenew_reason_too_many ) %] > Not renewable >+ [% ELSIF ( issueloo.norenew_reason_auto_renew || issueloo.norenew_reason_auto_too_soon ) %] >+ Automatic renewal >+ <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span> > [% ELSIF ( issueloo.norenew_reason_too_soon ) %] > No renewal before [% issueloo.soonestrenewdate %] > <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span> >-- >1.7.10.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 11577
:
28425
|
28426
|
28427
|
28428
|
28429
|
28430
|
28431
|
28432
|
28433
|
28434
|
28454
|
28595
|
28596
|
28597
|
28598
|
28599
|
28600
|
28601
|
28602
|
28603
|
28604
|
29393
|
29394
|
29395
|
29396
|
29397
|
29398
|
29399
|
29400
|
29401
|
29402
|
29966
|
29967
|
29968
|
29969
|
29970
|
29971
|
29972
|
29973
|
29974
|
29975
|
30248
|
30249
|
30250
|
30251
|
30252
|
30253
|
30254
|
30255
|
30256
|
30257
|
30258
|
30692
|
30693
|
30694
|
30695
|
30696
|
30697
|
30698
|
30699
|
30700
|
30701
|
30702
|
31076
|
31077
|
31078
|
31079
|
31080
|
31081
|
31082
|
31083
|
31084
|
31085
|
31086
|
31198
|
31199
|
31200
|
31201
|
31202
|
31203
|
31204
|
31205
|
31206
|
31207
|
31208
|
31209
|
31640
|
31641
|
31642
|
31643
|
31644
|
31645
|
31646
|
31647
|
31648
|
31649
|
31650
|
31651
|
31652
|
31653
|
31654
|
31655
|
31656
|
31657
|
31658
|
31659
|
31660
|
31661
|
31662
|
31663
|
57734