From 620ead4445ff873a12d7fcb42e780595ab060dba Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 24 Nov 2008 06:29:58 +0100 Subject: [PATCH] Allow renewal limits to be overridden Originally by Jesse Weaver This patch creates a new system preference, AllowRenewalLimitOverride, that, if YES, allows the renewal limit to be manually overridden. It updates C4::Circulation and reserve/renewscript.pl to obey this. Adapted for 3.0 : Henri-Damien LAURENT Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Circulation.pm | 10 ++- admin/systempreferences.pl | 1 + circ/circulation.pl | 18 +++-- .../prog/en/modules/circ/circulation.tmpl | 77 +++++++++++++------ .../prog/en/modules/members/moremember.tmpl | 10 +++ members/moremember.pl | 5 +- reserve/renewscript.pl | 3 +- 7 files changed, 87 insertions(+), 37 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a1782afa44..9a65c34eb0 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1833,7 +1833,7 @@ END_SQL =head2 CanBookBeRenewed -($ok,$error) = &CanBookBeRenewed($borrowernumber, $itemnumber); +($ok,$error) = &CanBookBeRenewed($borrowernumber, $itemnumber[, $override_limit]); Find out whether a borrowed item may be renewed. @@ -1844,6 +1844,10 @@ has the item on loan. 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. + C<$CanBookBeRenewed> returns a true value iff the item may be renewed. The item must currently be on loan to the specified borrower; renewals must be allowed for the item's type; and the borrower must not have @@ -1854,7 +1858,7 @@ already renewed the loan. $error will contain the reason the renewal can not pro sub CanBookBeRenewed { # check renewal status - my ( $borrowernumber, $itemnumber ) = @_; + my ( $borrowernumber, $itemnumber, $override_limit ) = @_; my $dbh = C4::Context->dbh; my $renews = 1; my $renewokay = 0; @@ -1889,7 +1893,7 @@ sub CanBookBeRenewed { if ( my $data2 = $sth2->fetchrow_hashref ) { $renews = $data2->{'renewalsallowed'}; } - if ( $renews && $renews > $data1->{'renewals'} ) { + if ( ( $renews && $renews > $data1->{'renewals'} ) || $override_limit ) { $renewokay = 1; } else { diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index c81146e4f9..ef53715412 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -135,6 +135,7 @@ my %tabsysprefs; $tabsysprefs{useDaysMode}="Circulation"; $tabsysprefs{ReservesNeedReturns}="Circulation"; $tabsysprefs{CircAutocompl}="Circulation"; + $tabsysprefs{AllowRenewalLimitOverride}="Circulation"; $tabsysprefs{canreservefromotherbranches}="Circulation"; $tabsysprefs{finesMode}="Circulation"; $tabsysprefs{emailLibrarianWhenHoldIsPlaced}="Circulation"; diff --git a/circ/circulation.pl b/circ/circulation.pl index d07b0a6a0a..aec1b29087 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -435,13 +435,14 @@ if ($borrower) { $it->{'itemnumber'}, $borrower->{'borrowernumber'} ); $it->{'charge'} = sprintf("%.2f", $it->{'charge'}); - my $can_renew_error; - ($it->{'can_renew'}, $can_renew_error) = CanBookBeRenewed( + my ($can_renew, $can_renew_error) = CanBookBeRenewed( $borrower->{'borrowernumber'},$it->{'itemnumber'} ); $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error; my ( $restype, $reserves ) = CheckReserves( $it->{'itemnumber'} ); - ( $restype ) and $it->{'can_renew'} = 0; + $it->{'can_renew'} = $can_renew; + $it->{'can_confirm'} = !$can_renew && !$restype; + $it->{'renew_error'} = $restype; $it->{'dd'} = format_date($it->{'date_due'}); $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ; @@ -700,10 +701,11 @@ $template->param( picture => 1 ) if $picture; $template->param( - debt_confirmed => $debt_confirmed, - SpecifyDueDate => C4::Context->preference("SpecifyDueDate"), - CircAutocompl => C4::Context->preference("CircAutocompl"), - dateformat => C4::Context->preference("dateformat"), - DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + debt_confirmed => $debt_confirmed, + SpecifyDueDate => C4::Context->preference("SpecifyDueDate"), + CircAutocompl => C4::Context->preference("CircAutocompl"), + AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"), + dateformat => C4::Context->preference("dateformat"), + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl index e8eccc353d..f2227d85a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl @@ -456,21 +456,34 @@ No patron matched &itemnumber=#item"> - - " checked="checked" style="display: none;" /> - + + " checked="checked" style="display: none;" /> + " checked="checked" /> - + " /> + + + + + + + On Hold + + + Too Many Renewals + + + + - - - On Hold - - - Too Many Renewals - - ">Check In @@ -503,22 +516,34 @@ No patron matched &itemnumber=#item"> - + " checked="checked" style="display: none;" /> - + " checked="checked" /> - + " /> + + + + + + + On Hold + + + Too Many Renewals + + + + - - - On Hold - - - Too Many Renewals - - - ">Check In @@ -532,6 +557,10 @@ No patron matched
+ + + +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl index 73b3f65090..394985b632 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl @@ -403,6 +403,12 @@ if (nodename =="barcodes[]"){ + + + ">On Hold @@ -452,6 +458,10 @@ if (nodename =="barcodes[]"){
+ + + + diff --git a/members/moremember.pl b/members/moremember.pl index b0299f2e9a..03d332365e 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -62,6 +62,7 @@ my $dbh = C4::Context->dbh; my $input = new CGI; $debug or $debug = $input->param('debug') || 0; my $print = $input->param('print'); +my $override_limit = $input->param("override_limit") || 0; my @failedrenews = $input->param('failedrenew'); my @failedreturns = $input->param('failedreturn'); my $error = $input->param('error'); @@ -245,8 +246,9 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $row{'charge'} = sprintf( "%.2f", $charge ); - my ( $renewokay,$renewerror ) = CanBookBeRenewed( $borrowernumber, $issue->[$i]{'itemnumber'}); + my ( $renewokay,$renewerror ) = CanBookBeRenewed( $borrowernumber, $issue->[$i]{'itemnumber'}, $override_limit ); $row{'norenew'} = !$renewokay; + $row{'can_confirm'} = ( !$renewokay && $renewerror ne 'on_reserve' ); $row{"norenew_reason_$renewerror"} = 1 if $renewerror; $row{'renew_failed'} = $renew_failed{ $issue->[$i]{'itemnumber'} }; $row{'return_failed'} = $return_failed{$issue->[$i]{'barcode'}}; @@ -349,6 +351,7 @@ if (C4::Context->preference('ExtendedPatronAttributes')) { $template->param( detailview => 1, + AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"), DHTMLcalendar_dateformat=>C4::Dates->DHTMLcalendar(), roaddetails => $roaddetails, borrowernumber => $borrowernumber, diff --git a/reserve/renewscript.pl b/reserve/renewscript.pl index 48e6076d95..f4b2a6523c 100755 --- a/reserve/renewscript.pl +++ b/reserve/renewscript.pl @@ -75,10 +75,11 @@ if ($input->param('newduedate')){ my $cardnumber = $input->param("cardnumber"); my $borrowernumber = $input->param("borrowernumber"); my $exemptfine = $input->param("exemptfine") || 0; +my $override_limit = $input->param("override_limit") || 0; my $failedrenews; foreach my $itemno (@data) { # check status before renewing issue - my ($renewokay,$error) = CanBookBeRenewed($borrowernumber,$itemno); + my ($renewokay,$error) = CanBookBeRenewed($borrowernumber,$itemno,$override_limit); if ($renewokay){ AddRenewal($borrowernumber,$itemno,$branch,$datedue); } -- 2.39.5