Bugzilla – Attachment 70630 Details for
Bug 15494
Block renewals by arbitrary item values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15494 - Add _items_denied_renewal sub to C4:Circulation::CanBookBeRenewed
Bug-15494---Add-itemsdeniedrenewal-sub-to-C4Circul.patch (text/plain), 2.34 KB, created by
Nick Clemens (kidclamp)
on 2018-01-17 17:58:01 UTC
(
hide
)
Description:
Bug 15494 - Add _items_denied_renewal sub to C4:Circulation::CanBookBeRenewed
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-01-17 17:58:01 UTC
Size:
2.34 KB
patch
obsolete
>From a4f5a7ed6f716e3628f001e6b4a186873523c5e5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 24 May 2017 08:52:27 -0400 >Subject: [PATCH] Bug 15494 - Add _items_denied_renewal sub to > C4:Circulation::CanBookBeRenewed > >--- > C4/Circulation.pm | 38 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 37 insertions(+), 1 deletion(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 2b7722c..5b15aee 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -57,7 +57,7 @@ use Koha::RefundLostItemFeeRules; > use Koha::Account::Lines; > use Koha::Account::Offsets; > use Carp; >-use List::MoreUtils qw( uniq ); >+use List::MoreUtils qw( uniq any ); > use Scalar::Util qw( looks_like_number ); > use Date::Calc qw( > Today >@@ -2603,6 +2603,8 @@ sub CanBookBeRenewed { > my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); > my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); > return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; >+ return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item }); >+ > > $borrowernumber ||= $issue->borrowernumber; > my $patron = Koha::Patrons->find( $borrowernumber ) >@@ -4081,6 +4083,40 @@ sub _CalculateAndUpdateFine { > } > } > >+sub _item_denied_renewal { >+ my ($params) = @_; >+ >+ my $item = $params->{item}; >+ return unless $item; >+ >+ my $yaml = C4::Context->preference('ItemsDeniedRenewal'); >+ my @lines = split /\n/, $yaml; >+ my $denyingrules; >+ foreach my $line (@lines){ >+ my ($field,$array) = split /:/, $line; >+ $array =~ s/[ [\]\r]//g; >+ my @array = split /,/, $array; >+ @array = map { $_ eq 'NULL' ? undef : $_ } @array; >+ @array = map { $_ eq '""' || $_ eq "''" ? undef : $_ } @array; >+ $denyingrules->{$field} = \@array; >+ } >+ return unless $denyingrules; >+ foreach my $field (keys %$denyingrules) { >+ my $val = $item->{$field}; >+ if( !defined $val) { >+ if ( any { !defined $_ } @{$denyingrules->{$field}} ){ >+ return 1; >+ } >+ } elsif (any { $val eq $_ } @{$denyingrules->{$field}}) { >+ # If the results matches the values in the syspref >+ # We return true if match found >+ return 1; >+ } >+ } >+ return 0; >+} >+ >+ > 1; > > __END__ >-- >2.1.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 15494
:
63700
|
63701
|
63702
|
63703
|
67886
|
67887
|
67888
|
67889
|
68146
|
68147
|
68148
|
68149
|
70295
|
70629
|
70630
|
70631
|
70632
|
71129
|
71130
|
71131
|
71132
|
71133
|
71134
|
71135
|
71136
|
71137
|
71138
|
79249
|
79250
|
79251
|
79252
|
79253
|
79254
|
79293
|
80327
|
80328
|
80329
|
80330
|
80331
|
80332
|
80333
|
81411
|
81412
|
81413
|
81414
|
81415
|
81416
|
81417