Bugzilla – Attachment 71031 Details for
Bug 18887
Introduce new table 'circulation_rules', use for 'max_holds' rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18887: (follow-up) Fix null/empty behavior
Bug-18887-follow-up-Fix-nullempty-behavior.patch (text/plain), 7.04 KB, created by
Jesse Weaver
on 2018-01-29 23:07:02 UTC
(
hide
)
Description:
Bug 18887: (follow-up) Fix null/empty behavior
Filename:
MIME Type:
Creator:
Jesse Weaver
Created:
2018-01-29 23:07:02 UTC
Size:
7.04 KB
patch
obsolete
>From 680631d84c3811e9ca8e00dc1c29e07fe16ccd56 Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <pianohacker@gmail.com> >Date: Wed, 4 Oct 2017 16:50:26 -0600 >Subject: [PATCH] Bug 18887: (follow-up) Fix null/empty behavior > >--- > C4/Reserves.pm | 2 +- > Koha/CirculationRules.pm | 5 ++++- > admin/smart-rules.pl | 18 +++++++++++++++--- > installer/data/mysql/atomicupdate/bug_18887.perl | 4 ++-- > .../intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 7 ++++++- > 5 files changed, 28 insertions(+), 8 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 58c6a87b95..7325eb5ff9 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -416,7 +416,7 @@ sub CanItemBeReserved { > rule_name => 'max_holds', > } > ); >- if ( $rule ) { >+ if ( $rule && defined( $rule->rule_value ) && $rule->rule_value ne '' ) { > my $total_holds_count = Koha::Holds->search( > { > borrowernumber => $borrower->{borrowernumber} >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 8004e95196..054eb00858 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -136,7 +136,6 @@ sub set_rule { > > sub set_rules { > my ( $self, $params ) = @_; >- warn Data::Dumper::Dumper( $params ); > > my $branchcode = $params->{branchcode}; > my $categorycode = $params->{categorycode}; >@@ -164,6 +163,10 @@ sub _type { > return 'CirculationRule'; > } > >+=head3 object_class >+ >+=cut >+ > sub object_class { > return 'Koha::CirculationRule'; > } >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index 4400e01b87..9cc4bb276d 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -226,12 +226,15 @@ elsif ($op eq "set-branch-defaults") { > my $holdallowed = $input->param('holdallowed'); > my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); > my $returnbranch = $input->param('returnbranch'); >+ my $max_holds = $input->param('max_holds'); > $maxissueqty =~ s/\s//g; > $maxissueqty = undef if $maxissueqty !~ /^\d+/; > $maxonsiteissueqty =~ s/\s//g; > $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; > $holdallowed =~ s/\s//g; > $holdallowed = undef if $holdallowed !~ /^\d+/; >+ $max_holds =~ s/\s//g; >+ $max_holds = '' if $max_holds !~ /^\d+/; > > if ($branch eq "*") { > my $sth_search = $dbh->prepare("SELECT count(*) AS total >@@ -267,6 +270,15 @@ elsif ($op eq "set-branch-defaults") { > $sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); > } > } >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $branch, >+ categorycode => '*', >+ itemtype => undef, >+ rule_name => 'max_holds', >+ rule_value => $max_holds, >+ } >+ ); > } > elsif ($op eq "add-branch-cat") { > my $categorycode = $input->param('categorycode'); >@@ -278,7 +290,7 @@ elsif ($op eq "add-branch-cat") { > $maxonsiteissueqty =~ s/\s//g; > $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; > $max_holds =~ s/\s//g; >- $max_holds = undef if $max_holds !~ /^\d+/; >+ $max_holds = '' if $max_holds !~ /^\d+/; > > if ($branch eq "*") { > if ($categorycode eq "*") { >@@ -319,7 +331,7 @@ elsif ($op eq "add-branch-cat") { > my $sth_insert = $dbh->prepare(q| > INSERT INTO default_borrower_circ_rules > (categorycode, maxissueqty, maxonsiteissueqty) >- VALUES (?, ?, ?, ?) >+ VALUES (?, ?, ?) > |); > my $sth_update = $dbh->prepare(q| > UPDATE default_borrower_circ_rules >@@ -337,7 +349,7 @@ elsif ($op eq "add-branch-cat") { > > Koha::CirculationRules->set_rule( > { >- branchcode => undef, >+ branchcode => '*', > categorycode => $categorycode, > itemtype => undef, > rule_name => 'max_holds', >diff --git a/installer/data/mysql/atomicupdate/bug_18887.perl b/installer/data/mysql/atomicupdate/bug_18887.perl >index 38610c9d44..07ee2d357f 100644 >--- a/installer/data/mysql/atomicupdate/bug_18887.perl >+++ b/installer/data/mysql/atomicupdate/bug_18887.perl >@@ -20,12 +20,12 @@ if( CheckVersion( $DBversion ) ) { > > $dbh->do(q{ > INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) >- SELECT branchcode, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules >+ SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules > }); > > $dbh->do(q{ > INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) >- SELECT NULL, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules >+ SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules > }); > > $dbh->do(q{ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index a0d8377126..8f1c415fc8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -350,6 +350,7 @@ > <th> </th> > <th>Total current checkouts allowed</th> > <th>Total current on-site checkouts allowed</th> >+ <th>Maximum total holds allowed (count)</th> > <th>Hold policy</th> > <th>Hold pickup library match</th> > <th>Return policy</th> >@@ -359,6 +360,10 @@ > <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td> > <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td> > <td><input type="text" name="maxonsiteissueqty" size="3" value="[% default_maxonsiteissueqty %]"/></td> >+ <td> >+ [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %] >+ <input name="max_holds" size="3" value="[% rule_value %]" /> >+ </td> > <td> > <select name="holdallowed"> > [% IF ( default_holdallowed_any ) %] >@@ -496,7 +501,7 @@ > </td> > <td> > [% SET rule_value = CirculationRules.Get( branch_cat_rule_loo.branchcode, branch_cat_rule_loo.categorycode, branch_cat_rule_loo.itemtype, 'max_holds' ) %] >- [% IF rule_value %] >+ [% IF rule_value.defined && rule_value != '' %] > [% rule_value %] > [% ELSE %] > Unlimited >-- >2.15.1
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 18887
:
65233
|
65234
|
65235
|
65236
|
65237
|
67620
|
70986
|
70987
|
70988
|
70989
|
70990
|
70991
|
71031
|
71042
|
72218
|
72219
|
72220
|
72221
|
72222
|
72223
|
72224
|
77080
|
77081
|
77082
|
77083
|
77084
|
77085
|
77086
|
77087
|
77207
|
77208
|
77209
|
77210
|
77211
|
77212
|
77213
|
77214
|
77215
|
77218
|
77238
|
77649
|
77650
|
77651
|
77652
|
77653
|
77654
|
77655
|
77656
|
77657
|
77658
|
77659
|
78346
|
78347
|
78348
|
78349
|
78350
|
78351
|
78352
|
78353
|
78354
|
78355
|
78356
|
78674
|
78675
|
78676
|
78677
|
78678
|
78679
|
78680
|
78681
|
78682
|
78683
|
78684
|
78743
|
78744
|
78745
|
78746
|
78747
|
78748
|
78749
|
78750
|
78751
|
78752
|
78753
|
78879
|
79119
|
79626
|
79627
|
79628
|
79629
|
79630
|
79631
|
79632
|
79633
|
79634
|
79635
|
79636
|
79637
|
79638
|
79639
|
79640
|
79641
|
79761
|
79762
|
79763
|
79764
|
79765
|
79766
|
79767
|
79768
|
79769
|
79770
|
79771
|
79772
|
79773
|
79774
|
79775
|
79776
|
79778
|
79891