@@ -, +, @@ item types --- C4/Circulation.pm | 13 +- Koha/Schema/Result/Issuingrule.pm | 11 +- admin/smart-rules.pl | 2 +- .../bug_14866-add_decreaseloanholds.sql | 2 +- installer/data/mysql/kohastructure.sql | 11 +- .../prog/en/modules/admin/smart-rules.tt | 239 +++++++++++---------- 6 files changed, 146 insertions(+), 132 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -23,7 +23,6 @@ use strict; #use warnings; FIXME - Bug 2505 use DateTime; use POSIX qw( floor ); -use Koha::DateUtils; use C4::Context; use C4::Stats; use C4::Reserves; @@ -1049,14 +1048,20 @@ sub CanBookBeIssued { # Decrease loan period for item if rule exist in smart-rules.pl # Overrides decreaseLoanHighHoldsValue syspref my $branch = _GetCircControlBranch($item,$borrower); - my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch); - my $issuedate = DateTime->now( time_zone => C4::Context->tz() ); + my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule( + { categorycode => $borrower->{categorycode}, + itemtype => $item->{itype}, + branchcode => $branch + } + ); + my $issuedate = dt_from_string(); my $calendar = Koha::Calendar->new( branchcode => $branch ); + $issuingrule->{decreaseloanholds} = 0 if not defined $issuingrule->{decreaseloanholds}; my $reduced_datedue = $calendar->addDate( $issuedate, $issuingrule->{decreaseloanholds} ); if ( defined($issuingrule->{decreaseloanholds}) ) { $needsconfirmation{HIGHHOLDS} = { - num_holds => $num, + num_holds => $issuingrule->{outstanding}, duration => $issuingrule->{decreaseloanholds}, returndate => output_pref($reduced_datedue), } --- a/Koha/Schema/Result/Issuingrule.pm +++ a/Koha/Schema/Result/Issuingrule.pm @@ -221,6 +221,11 @@ __PACKAGE__->table("issuingrules"); extra: {list => ["no","yes","bib_only","item_only"]} is_nullable: 0 +=head2 decreaseloanholds + + data_type: 'integer' + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -302,6 +307,8 @@ __PACKAGE__->add_columns( extra => { list => ["no", "yes", "bib_only", "item_only"] }, is_nullable => 0, }, + "decreaseloanholds", + { data_type => "integer", is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -321,8 +328,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-12-13 12:44:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VBD8atc/D/6rN0D+aTaSOQ +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-06-07 03:02:31 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wRqrq6dJHXE+ocOQKhnKnA # You can replace this text with custom code or comments, and it will be preserved on regeneration --- a/admin/smart-rules.pl +++ a/admin/smart-rules.pl @@ -160,7 +160,7 @@ elsif ($op eq 'add') { my $article_requests = $input->param('article_requests') || 'no'; my $overduefinescap = $input->param('overduefinescap') || undef; my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on'; - my $decreaseloanholds = $input->param('decreaseloanholds'); + my $decreaseloanholds = $input->param('decreaseloanholds') || undef; $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price"; my $params = { --- a/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql +++ a/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql @@ -1, +1, @@ -ALTER TABLE issuingrules ADD decreaseloanholds INTEGER; +ALTER IGNORE TABLE issuingrules ADD decreaseloanholds INTEGER(11) DEFAULT NULL AFTER `article_requests`; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -858,11 +858,12 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed `holds_per_record` SMALLINT(6) NOT NULL DEFAULT 1, -- How many holds a patron can have on a given bib `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode) - overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine - cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT '0', -- cap the fine based on item's replacement price - onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf - opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold - article_requests enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed, + `overduefinescap` decimal(28,6) default NULL, -- the maximum amount of an overdue fine + `cap_fine_to_replacement_price` BOOLEAN NOT NULL DEFAULT '0', -- cap the fine based on item's replacement price + `onshelfholds` tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf + `opacitemholds` char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold + `article_requests` enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed, + `decreaseloanholds` int(11) default NULL, PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`), KEY `categorycode` (`categorycode`), KEY `itemtype` (`itemtype`) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -97,129 +97,130 @@
- [% FOREACH rule IN rules %] -