Bugzilla – Attachment 156319 Details for
Bug 8137
Checkout limit for all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8137: (follow-up)
Bug-8137-follow-up.patch (text/plain), 42.13 KB, created by
Thibaud Guillot (thibaud_g)
on 2023-09-28 11:20:23 UTC
(
hide
)
Description:
Bug 8137: (follow-up)
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2023-09-28 11:20:23 UTC
Size:
42.13 KB
patch
obsolete
>From 25ec8f4713b0efefbacfa27314325548c998df82 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Thu, 28 Sep 2023 11:24:47 +0200 >Subject: [PATCH] Bug 8137: (follow-up) > >--- > Koha/CirculationRule.pm | 10 + > Koha/CirculationRules.pm | 30 +- > Koha/Schema/Result/CirculationRule.pm | 11 +- > admin/smart-rules.pl | 29 +- > .../Bug_8137-add-column-has_priority.sql | 7 +- > installer/data/mysql/kohastructure.sql | 11 +- > .../prog/en/modules/admin/smart-rules.tt | 288 +++++++++--------- > t/db_dependent/Circulation/Branch.t | 50 ++- > t/db_dependent/Koha/IssuingRules.t | 22 +- > 9 files changed, 259 insertions(+), 199 deletions(-) > >diff --git a/Koha/CirculationRule.pm b/Koha/CirculationRule.pm >index 29edbe2c42..1c3d9184b1 100644 >--- a/Koha/CirculationRule.pm >+++ b/Koha/CirculationRule.pm >@@ -68,6 +68,16 @@ sub item_type { > return Koha::ItemTypes->_new_from_dbic($rs); > } > >+=head3 priority >+ >+=cut >+ >+sub priority { >+ my ($self) = @_; >+ >+ return $self->has_priority; >+} >+ > =head3 clone > > Clone a circulation rule to another branch >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 52e0771ba2..727fc7e67b 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -65,9 +65,6 @@ our $RULE_KINDS = { > max_holds => { > scope => [ 'branchcode', 'categorycode' ], > }, >- has_priority => { >- scope => [ 'branchcode', 'categorycode' ], >- }, > holdallowed => { > scope => [ 'branchcode', 'itemtype' ], > can_be_blank => 0, >@@ -261,15 +258,12 @@ sub get_effective_rule { > } > > my $order_by = $params->{order_by} >- // { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] }; >+ // { -desc => [ 'has_priority', 'branchcode', 'categorycode', 'itemtype' ] }; > > my $search_params; > $search_params->{rule_name} = $rule_name; >- > $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; >- $search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; >- $search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; >- $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef; >+ $search_params->{has_priority} = 1; > > my $rule = $self->search( > $search_params, >@@ -279,6 +273,20 @@ sub get_effective_rule { > } > )->single; > >+ return $rule if defined $rule; >+ >+ $search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; >+ $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef; >+ $search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; >+ >+ $rule = $self->search( >+ $search_params, >+ { >+ order_by => $order_by, >+ rows => 1, >+ } >+ )->single; >+ > return $rule; > } > >@@ -383,6 +391,7 @@ sub set_rule { > my $branchcode = $params->{branchcode}; > my $categorycode = $params->{categorycode}; > my $itemtype = $params->{itemtype}; >+ my $has_priority = $params->{has_priority}; > my $rule_name = $params->{rule_name}; > my $rule_value = $params->{rule_value}; > my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; >@@ -400,6 +409,7 @@ sub set_rule { > branchcode => $branchcode, > categorycode => $categorycode, > itemtype => $itemtype, >+ has_priority => $has_priority, > } > )->next(); > >@@ -419,6 +429,7 @@ sub set_rule { > branchcode => $branchcode, > categorycode => $categorycode, > itemtype => $itemtype, >+ has_priority => $has_priority, > rule_name => $rule_name, > rule_value => $rule_value, > } >@@ -446,7 +457,8 @@ sub set_rules { > $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; > $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; > $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; >- my $rules = $params->{rules}; >+ $set_params{has_priority} = $params->{has_priority} if exists $params->{has_priority}; >+ my $rules = $params->{rules}; > > my $rule_objects = []; > while ( my ( $rule_name, $rule_value ) = each %$rules ) { >diff --git a/Koha/Schema/Result/CirculationRule.pm b/Koha/Schema/Result/CirculationRule.pm >index 80e6cc2d5a..4284c3894a 100644 >--- a/Koha/Schema/Result/CirculationRule.pm >+++ b/Koha/Schema/Result/CirculationRule.pm >@@ -50,6 +50,11 @@ __PACKAGE__->table("circulation_rules"); > is_nullable: 1 > size: 10 > >+=head2 has_priority >+ >+ data_type: 'integer' >+ is_nullable: 1 >+ > =head2 rule_name > > data_type: 'varchar' >@@ -73,6 +78,8 @@ __PACKAGE__->add_columns( > { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, > "itemtype", > { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, >+ "has_priority", >+ { data_type => "integer", is_nullable => 1, is_boolean => 1 }, > "rule_name", > { data_type => "varchar", is_nullable => 0, size => 32 }, > "rule_value", >@@ -177,8 +184,8 @@ __PACKAGE__->belongs_to( > ); > > >-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QHMqvrtX0ohJe70PHUYZ0Q >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-07-22 13:19:28 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1mg3weVQdfPTJ+jX6X5K+Q > > sub koha_objects_class { > 'Koha::CirculationRules'; >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index 4840d3bd22..a82e5cd24c 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -70,12 +70,15 @@ $cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY ); > if ($op eq 'delete') { > my $itemtype = $input->param('itemtype'); > my $categorycode = $input->param('categorycode'); >+ my $has_priority = $input->param('has_priority') ? 1 : undef; >+ $debug and warn "deleting $1 $2 $branch"; > > Koha::CirculationRules->set_rules( > { > categorycode => $categorycode eq '*' ? undef : $categorycode, > branchcode => $branch eq '*' ? undef : $branch, > itemtype => $itemtype eq '*' ? undef : $itemtype, >+ has_priority => $has_priority, > rules => { > maxissueqty => undef, > maxonsiteissueqty => undef, >@@ -121,12 +124,14 @@ if ($op eq 'delete') { > } > elsif ($op eq 'delete-branch-cat') { > my $categorycode = $input->param('categorycode'); >+ my $has_priority = $input->param('has_priority') ? 1 : undef; > if ($branch eq "*") { > if ($categorycode eq "*") { > Koha::CirculationRules->set_rules( > { > branchcode => undef, > categorycode => undef, >+ has_priority => $has_priority, > rules => { > max_holds => undef, > patron_maxissueqty => undef, >@@ -150,6 +155,7 @@ elsif ($op eq 'delete-branch-cat') { > { > categorycode => $categorycode, > branchcode => undef, >+ has_priority => $has_priority, > rules => { > max_holds => undef, > patron_maxissueqty => undef, >@@ -163,6 +169,7 @@ elsif ($op eq 'delete-branch-cat') { > { > branchcode => $branch, > categorycode => undef, >+ has_priority => $has_priority, > rules => { > max_holds => undef, > patron_maxissueqty => undef, >@@ -186,6 +193,7 @@ elsif ($op eq 'delete-branch-cat') { > { > categorycode => $categorycode, > branchcode => $branch, >+ has_priority => $has_priority, > rules => { > max_holds => undef, > patron_maxissueqty => undef, >@@ -254,7 +262,7 @@ elsif ($op eq 'add') { > my $br = $branch; # branch > my $bor = $input->param('categorycode'); # borrower category > my $itemtype = $input->param('itemtype'); # item type >- my $has_priority = $input->param('has_priority') ? 1 : 0; >+ my $has_priority = $input->param('has_priority') ? 1 : undef; > my $fine = $input->param('fine'); > my $finedays = $input->param('finedays'); > my $maxsuspensiondays = $input->param('maxsuspensiondays') || q{}; >@@ -302,7 +310,6 @@ elsif ($op eq 'add') { > maxissueqty => $maxissueqty, > maxonsiteissueqty => $maxonsiteissueqty, > rentaldiscount => $rentaldiscount, >- has_priority => $has_priority, > fine => $fine, > finedays => $finedays, > maxsuspensiondays => $maxsuspensiondays, >@@ -345,7 +352,7 @@ elsif ($op eq 'add') { > categorycode => $bor eq '*' ? undef : $bor, > itemtype => $itemtype eq '*' ? undef : $itemtype, > branchcode => $br eq '*' ? undef : $br, >- has_priority => $has_priority, >+ has_priority => $has_priority, > rules => $rules, > } > ); >@@ -360,12 +367,14 @@ elsif ($op eq "set-branch-defaults") { > my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); > my $returnbranch = $input->param('returnbranch'); > my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); >+ my $has_priority = $input->param('has_priority') ? 1 : undef; > > if ($branch eq "*") { > Koha::CirculationRules->set_rules( > { > itemtype => undef, > branchcode => undef, >+ has_priority => $has_priority, > rules => { > holdallowed => $holdallowed, > hold_fulfillment_policy => $hold_fulfillment_policy, >@@ -377,9 +386,11 @@ elsif ($op eq "set-branch-defaults") { > { > categorycode => undef, > branchcode => undef, >+ has_priority => $has_priority, > rules => { > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >+ patron_has_priority => $has_priority, > } > } > ); >@@ -388,6 +399,7 @@ elsif ($op eq "set-branch-defaults") { > { > itemtype => undef, > branchcode => $branch, >+ has_priority => $has_priority, > rules => { > holdallowed => $holdallowed, > hold_fulfillment_policy => $hold_fulfillment_policy, >@@ -399,6 +411,7 @@ elsif ($op eq "set-branch-defaults") { > { > categorycode => undef, > branchcode => $branch, >+ has_priority => $has_priority, > rules => { > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >@@ -431,6 +444,7 @@ elsif ($op eq "add-branch-cat") { > { > categorycode => undef, > branchcode => undef, >+ has_priority => $has_priority, > rules => { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, >@@ -444,11 +458,11 @@ elsif ($op eq "add-branch-cat") { > { > categorycode => $categorycode, > branchcode => undef, >+ has_priority => $has_priority, > rules => { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >- has_priority => $has_priority, > } > } > ); >@@ -458,11 +472,11 @@ elsif ($op eq "add-branch-cat") { > { > categorycode => undef, > branchcode => $branch, >+ has_priority => $has_priority, > rules => { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >- has_priority => $has_priority, > } > } > ); >@@ -471,11 +485,11 @@ elsif ($op eq "add-branch-cat") { > { > categorycode => $categorycode, > branchcode => $branch, >+ has_priority => $has_priority, > rules => { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >- has_priority => $has_priority, > } > } > ); >@@ -748,7 +762,8 @@ my $definedbranch = $all_rules->count ? 1 : 0; > my $rules = {}; > while ( my $r = $all_rules->next ) { > $r = $r->unblessed; >- $rules->{ $r->{categorycode} // q{} }->{ $r->{itemtype} // q{} }->{ $r->{rule_name} } = $r->{rule_value}; >+ $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; >+ $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ 'has_priority' } = $r->{has_priority}; > } > > $template->param(show_branch_cat_rule_form => 1); >diff --git a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql >index fc7c42fcc0..a368b4e69e 100644 >--- a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql >+++ b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql >@@ -1,5 +1,2 @@ >-ALTER TABLE default_borrower_circ_rules ADD has_priority INT(1) DEFAULT 0; >-ALTER TABLE default_borrower_circ_rules DROP foreign key borrower_borrower_circ_rules_ibfk_1; >-ALTER TABLE default_borrower_circ_rules DROP primary key; >-ALTER TABLE default_borrower_circ_rules ADD primary key(categorycode, has_priority); >-ALTER TABLE default_borrower_circ_rules ADD CONSTRAINT borrower_borrower_circ_rules_ibfk_1 FOREIGN KEY (categorycode) REFERENCES categories (categorycode) ON DELETE CASCADE ON UPDATE CASCADE; >\ No newline at end of file >+ALTER TABLE circulation_rules ADD has_priority INT(1) DEFAULT NULL AFTER itemtype; >+ALTER TABLE circulation_rules ADD KEY (branchcode , categorycode, itemtype, has_priority); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index add4518807..d6e631fecb 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1801,11 +1801,12 @@ DROP TABLE IF EXISTS `circulation_rules`; > /*!40101 SET character_set_client = utf8 */; > CREATE TABLE `circulation_rules` ( > `id` int(11) NOT NULL AUTO_INCREMENT, >- `branchcode` varchar(10) DEFAULT NULL, >- `categorycode` varchar(10) DEFAULT NULL, >- `itemtype` varchar(10) DEFAULT NULL, >- `rule_name` varchar(32) NOT NULL, >- `rule_value` varchar(32) NOT NULL, >+ `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, >+ `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, >+ `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, >+ `has_priority` tinyint(1) NULL default NULL, >+ `rule_name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL, >+ `rule_value` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`), > KEY `circ_rules_ibfk_2` (`categorycode`), >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 daca8e8ab0..482a42fcb9 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 >@@ -117,94 +117,79 @@ > <th>Note</th> > [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> >- <th>Current on-site checkouts allowed</th> >- <th>Loan period</th> >- <th>Days mode</th> >- <th>Unit</th> >- <th>Hard due date</th> >- <th>Decreased loan period for high holds (day)</th> >- <th>Fine amount</th> >- <th>Fine charging interval</th> >- <th>When to charge</th> >- <th>Fine/suspension grace period</th> >- <th>Overdue fines cap (amount)</th> >- <th>Cap fine at replacement price</th> >- <th>Suspension in days (day)</th> >- <th>Max. suspension duration (day)</th> >- <th>Suspension charging interval</th> >- <th>Renewals allowed (count)</th> >- [% IF Koha.Preference('UnseenRenewals') %] >- <th>Unseen renewals allowed (count)</th> >- [% END %] >- <th>Renewal period</th> >- <th>No renewal before</th> >- <th>Automatic renewal</th> >- <th>No automatic renewal after</th> >- <th>No automatic renewal after (hard limit)</th> >- <th>Holds allowed (total)</th> >- <th>Holds allowed (daily)</th> >- <th>Holds per record (count)</th> >- <th>On shelf holds allowed</th> >- <th>OPAC item level holds</th> >- [% IF Koha.Preference('ArticleRequests') %] >- <th>Article requests</th> >- [% END %] >- <th>Rental discount (%)</th> >- [% IF Koha.Preference('UseRecalls') %] >- <th>Recalls allowed (total)</th> >- <th>Recalls per record (count)</th> >- <th>On shelf recalls allowed</th> >- <th>Recall due date interval (day)</th> >- <th>Recall overdue fine amount</th> >- <th>Recall pickup period (day)</th> >- [% END %] >- <th class="noExport">Actions</th> >- </tr> >- </thead> >- <tbody> >- [% SET row_count = 0 %] >- [% FOREACH c IN categorycodes %] >- [% SET c = '' UNLESS c.defined %] >- [% FOREACH i IN itemtypes %] >- [% SET i = '' UNLESS i.defined %] >- [% SET note = all_rules.$c.$i.note %] >- [% SET maxissueqty = all_rules.$c.$i.maxissueqty %] >- [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %] >- [% SET issuelength = all_rules.$c.$i.issuelength %] >- [% SET daysmode = all_rules.$c.$i.daysmode %] >- [% SET lengthunit = all_rules.$c.$i.lengthunit %] >- [% SET hardduedate = all_rules.$c.$i.hardduedate %] >- [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %] >- [% SET fine = all_rules.$c.$i.fine %] >- [% SET chargeperiod = all_rules.$c.$i.chargeperiod %] >- [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %] >- [% SET firstremind = all_rules.$c.$i.firstremind %] >- [% SET overduefinescap = all_rules.$c.$i.overduefinescap %] >- [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %] >- [% SET finedays = all_rules.$c.$i.finedays %] >- [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %] >- [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %] >- [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %] >- [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %] >- [% SET renewalperiod = all_rules.$c.$i.renewalperiod %] >- [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %] >- [% SET auto_renew = all_rules.$c.$i.auto_renew %] >- [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %] >- [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %] >- [% SET reservesallowed = all_rules.$c.$i.reservesallowed %] >- [% SET holds_per_day = all_rules.$c.$i.holds_per_day %] >- [% SET holds_per_record = all_rules.$c.$i.holds_per_record %] >- [% SET onshelfholds = all_rules.$c.$i.onshelfholds %] >- [% SET opacitemholds = all_rules.$c.$i.opacitemholds %] >- [% SET article_requests = all_rules.$c.$i.article_requests %] >- [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %] >- [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %] >- [% SET recalls_allowed = all_rules.$c.$i.recalls_allowed %] >- [% SET recalls_per_record = all_rules.$c.$i.recalls_per_record %] >- [% SET on_shelf_recalls = all_rules.$c.$i.on_shelf_recalls %] >- [% SET recall_due_date_interval = all_rules.$c.$i.recall_due_date_interval %] >- [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %] >- [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %] >+ <th>Current on-site checkouts allowed</th> >+ <th>Loan period</th> >+ <th>Days mode</th> >+ <th>Unit</th> >+ <th>Hard due date</th> >+ <th>Decreased loan period for high holds (day)</th> >+ <th>Fine amount</th> >+ <th>Fine charging interval</th> >+ <th>When to charge</th> >+ <th>Fine grace period</th> >+ <th>Overdue fines cap (amount)</th> >+ <th>Cap fine at replacement price</th> >+ <th>Suspension in days (day)</th> >+ <th>Max. suspension duration (day)</th> >+ <th>Suspension charging interval</th> >+ <th>Renewals allowed (count)</th> >+ [% IF Koha.Preference('UnseenRenewals') %] >+ <th>Unseen renewals allowed (count)</th> >+ [% END %] >+ <th>Renewal period</th> >+ <th>No renewal before</th> >+ <th>Automatic renewal</th> >+ <th>No automatic renewal after</th> >+ <th>No automatic renewal after (hard limit)</th> >+ <th>Holds allowed (total)</th> >+ <th>Holds allowed (daily)</th> >+ <th>Holds per record (count)</th> >+ <th>On shelf holds allowed</th> >+ <th>OPAC item level holds</th> >+ <th>Article requests</th> >+ <th>Rental discount (%)</th> >+ <th class="noExport">Actions</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% SET row_count = 0 %] >+ [% FOREACH c IN categorycodes %] >+ [% SET c = '' UNLESS c.defined %] >+ [% FOREACH i IN itemtypes %] >+ [% SET i = '' UNLESS i.defined %] >+ [% SET note = all_rules.$c.$i.note %] >+ [% SET has_priority = all_rules.$c.$i.has_priority %] >+ [% SET maxissueqty = all_rules.$c.$i.maxissueqty %] >+ [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %] >+ [% SET issuelength = all_rules.$c.$i.issuelength %] >+ [% SET daysmode = all_rules.$c.$i.daysmode %] >+ [% SET lengthunit = all_rules.$c.$i.lengthunit %] >+ [% SET hardduedate = all_rules.$c.$i.hardduedate %] >+ [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %] >+ [% SET fine = all_rules.$c.$i.fine %] >+ [% SET chargeperiod = all_rules.$c.$i.chargeperiod %] >+ [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %] >+ [% SET firstremind = all_rules.$c.$i.firstremind %] >+ [% SET overduefinescap = all_rules.$c.$i.overduefinescap %] >+ [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %] >+ [% SET finedays = all_rules.$c.$i.finedays %] >+ [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %] >+ [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %] >+ [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %] >+ [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %] >+ [% SET renewalperiod = all_rules.$c.$i.renewalperiod %] >+ [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %] >+ [% SET auto_renew = all_rules.$c.$i.auto_renew %] >+ [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %] >+ [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %] >+ [% SET reservesallowed = all_rules.$c.$i.reservesallowed %] >+ [% SET holds_per_day = all_rules.$c.$i.holds_per_day %] >+ [% SET holds_per_record = all_rules.$c.$i.holds_per_record %] >+ [% SET onshelfholds = all_rules.$c.$i.onshelfholds %] >+ [% SET opacitemholds = all_rules.$c.$i.opacitemholds %] >+ [% SET article_requests = all_rules.$c.$i.article_requests %] >+ [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %] >+ [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %] > > [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time %] > [% IF show_rule %] >@@ -245,7 +230,7 @@ > </td> > [% UNLESS humanbranch %] > <td> >- [% IF rule.has_priority %] >+ [% IF has_priority.defined && has_priority %] > <input type="checkbox" checked="checked" disabled="disabled"/> > [% ELSE %] > <input type="checkbox" disabled="disabled"/> >@@ -766,66 +751,69 @@ > Not set > </option> > >- [% IF returnbranch.rule_value == 'homebranch' %] >- <option value="homebranch" selected="selected"> >- [% ELSE %] >- <option value="homebranch"> >- [% END %] >- Item returns home >- </option> >- [% IF returnbranch.rule_value == 'holdingbranch' %] >- <option value="holdingbranch" selected="selected"> >- [% ELSE %] >- <option value="holdingbranch"> >- [% END %] >- Item returns to issuing library >- </option> >- [% IF returnbranch.rule_value == 'noreturn' %] >- <option value="noreturn" selected="selected"> >- [% ELSE %] >- <option value="noreturn"> >- [% END %] >- Item floats >- </option> >- </select> >- </td> >- <td class="actions"> >- <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button> >- [% IF ( default_checkout_hold_and_return_policy ) %] >- <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&categorycode=*&branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a> >- [% END %] >- </td> >- </tr> >- </table> >- </form> >- </div> >- >- [% IF ( show_branch_cat_rule_form ) %] >- <div id="holds-policy-by-patron-category" class="page-section"> >- <h2>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h2> >- <p>For this library, you can specify the maximum number of loans that >- a patron of a given category can make, regardless of the item type. >- </p> >- <p>If the total amount loanable for a given patron category is left blank, >- no limit applies, except possibly for a limit you define for a specific item type. >- </p> >- <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl"> >- <input type="hidden" name="op" value="add-branch-cat" /> >- <input type="hidden" name="branch" value="[% current_branch | html %]"/> >- <table> >- <tr> >- <th>Patron category</th> >- <th>Total current checkouts allowed</th> >- <th>Total current on-site checkouts allowed</th> >- <th>Total holds allowed</th> >- <th> </th> >- </tr> >- [% FOREACH c IN categorycodes %] >- [% NEXT UNLESS c %] >- [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %] >- [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %] >- [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %] >- >+ [% IF returnbranch == 'homebranch' %] >+ <option value="homebranch" selected="selected"> >+ [% ELSE %] >+ <option value="homebranch"> >+ [% END %] >+ Item returns home >+ </option> >+ [% IF returnbranch == 'holdingbranch' %] >+ <option value="holdingbranch" selected="selected"> >+ [% ELSE %] >+ <option value="holdingbranch"> >+ [% END %] >+ Item returns to issuing library >+ </option> >+ [% IF returnbranch == 'noreturn' %] >+ <option value="noreturn" selected="selected"> >+ [% ELSE %] >+ <option value="noreturn"> >+ [% END %] >+ Item floats >+ </option> >+ </select> >+ </td> >+ <td class="actions"> >+ <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button> >+ <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&categorycode=*&branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a> >+ </td> >+ </tr> >+ </table> >+ </form> >+ </div> >+ [% IF ( show_branch_cat_rule_form ) %] >+ <div id="holds-policy-by-patron-category" class="container"> >+ <h3>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h3> >+ <p>For this library, you can specify the maximum number of loans that >+ a patron of a given category can make, regardless of the item type. >+ </p> >+ <p>If the total amount loanable for a given patron category is left blank, >+ no limit applies, except possibly for a limit you define for a specific item type. >+ </p> >+ <p> >+ <b>Has priority: </b>If checked, the rule will override those for all branches. Else >+ it behaves like a default one: used if no rule exists for the coresponding branch. >+ </p> >+ <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl"> >+ <input type="hidden" name="op" value="add-branch-cat" /> >+ <input type="hidden" name="branch" value="[% current_branch | html %]"/> >+ <table> >+ <tr> >+ <th>Patron category</th> >+ <th>Total current checkouts allowed</th> >+ <th>Total current on-site checkouts allowed</th> >+ <th>Total holds allowed</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] >+ <th> </th> >+ </tr> >+ [% SET i = '' %] >+ [% FOREACH c IN categorycodes %] >+ [% NEXT UNLESS c %] >+ [% SET patron_maxissueqty = all_rules.$c.$i.patron_maxissueqty %] >+ [% SET patron_maxonsiteissueqty = all_rules.$c.$i.patron_maxonsiteissueqty %] >+ [% SET max_holds = all_rules.$c.$i.max_holds %] >+ [% SET has_priority = all_rules.$c.$i.has_priority %] > [% IF ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %] > <tr> > <td> >@@ -858,7 +846,7 @@ > </td> > [% UNLESS humanbranch %] > <td> >- [% IF branch_cat_rule_loo.has_priority %] >+ [% IF has_priority.defined && has_priority %] > <input type="checkbox" checked="checked" disabled/> > [% ELSE %] > <input type="checkbox" disabled/> >diff --git a/t/db_dependent/Circulation/Branch.t b/t/db_dependent/Circulation/Branch.t >index 81ba4331f4..68b6ec100c 100755 >--- a/t/db_dependent/Circulation/Branch.t >+++ b/t/db_dependent/Circulation/Branch.t >@@ -155,7 +155,7 @@ Koha::CirculationRules->set_rules( > patron_maxissueqty => 5, > patron_maxonsiteissueqty => 6, > } >- } >+ } > ); > > >@@ -232,12 +232,16 @@ Koha::CirculationRules->set_rules( > } > ); > >-$query = q| >- INSERT INTO default_borrower_circ_rules >- (categorycode, maxissueqty, maxonsiteissueqty, has_priority) >- VALUES( ?, ?, ?, ? ) >-|; >-$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 0); >+Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => $samplecat->{categorycode}, >+ rules => { >+ patron_maxonsiteissueqty => 3, >+ patron_maxissueqty => 3, >+ } >+ } >+); > > #Test GetBranchBorrowerCircRule > # >@@ -265,22 +269,40 @@ is_deeply( > "GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules" > ); > >-$query = q| >- INSERT INTO default_borrower_circ_rules >- (categorycode, maxissueqty, maxonsiteissueqty, has_priority) >- VALUES( ?, ?, ?, ? ) >-|; >-$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 1); >+ >+Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => $samplecat->{categorycode}, >+ has_priority => 1, >+ rules => { >+ patron_maxonsiteissueqty => 3, >+ patron_maxissueqty => 3, >+ } >+ } >+); > > is_deeply( > GetBranchBorrowerCircRule( > $samplebranch1->{branchcode}, > $samplecat->{categorycode} > ), >- { maxissueqty => 3, maxonsiteissueqty => 3, has_priority => 1 }, >+ { patron_maxissueqty => 3, patron_maxonsiteissueqty => 3 }, > "GetBranchBorrower returns the rule having priority" > ); > >+Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => $samplecat->{categorycode}, >+ has_priority => 0, >+ rules => { >+ patron_maxonsiteissueqty => 3, >+ patron_maxissueqty => 3, >+ } >+ } >+); >+ > #Test GetBranchItemRule > my @lazy_any = ( 'hold_fulfillment_policy' => 'any' ); > is_deeply( >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index d8c7ff4374..5fe97505d9 100755 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -35,6 +35,7 @@ $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new; > >+ > subtest 'get_effective_issuing_rule' => sub { > plan tests => 3; > >@@ -43,30 +44,37 @@ subtest 'get_effective_issuing_rule' => sub { > my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'}; > > subtest 'Priority rule' => sub { >- plan tests => 3; >+ plan tests => 4; > >- Koha::IssuingRules->delete; >+ Koha::CirculationRules->delete; >+ is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.'); > >- ok(Koha::IssuingRule->new({ >+ ok(Koha::CirculationRule->new({ > branchcode => $branchcode, > categorycode => $categorycode, > itemtype => $itemtype, >+ rule_name => 'fine', >+ rule_value => 0, > })->store, "Given I added an issuing rule branchcode => $branchcode,' > .' categorycode => $categorycode, itemtype => $itemtype,"); > >- ok(Koha::IssuingRule->new({ >- branchcode => '*', >+ ok(Koha::CirculationRule->new({ >+ branchcode => undef, > categorycode => $categorycode, > itemtype => $itemtype, > has_priority => 1, >+ rule_name => 'fine', >+ rule_value => 1, > })->store, "Add a priority rule."); > >- my $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ my $rule = Koha::CirculationRules->get_effective_rule({ > branchcode => $branchcode, > categorycode => $categorycode, > itemtype => $itemtype, >+ has_priority => 1, >+ rule_name => 'fine', > }); >- is($rule->has_priority, 1, 'Priority rule should be returned'); >+ is($rule->priority, 1, 'Priority rule should be returned'); > }; > > subtest 'Call with undefined values' => sub { >-- >2.30.2
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 8137
:
9705
|
9706
|
11079
|
64703
|
64704
|
64791
|
64891
|
72831
|
72832
|
107207
|
107208
|
107209
|
107459
|
111368
|
111369
|
111370
|
112640
|
113797
|
113882
|
114531
|
114532
|
114533
|
114534
|
116676
|
116677
|
116678
|
116679
|
116680
|
145476
|
145477
|
145478
|
145479
|
145480
|
152040
|
152041
|
152042
|
152043
|
152044
|
152045
|
156316
|
156317
|
156318
|
156319
|
156320
|
156321
|
156322
|
159712
|
162367
|
167208
|
167923
|
168119
|
169084
|
169696
|
169700
|
169727
|
169927
|
169928
|
170411
|
173605
|
173608
|
175837
|
175838
|
177464