From f053ca032b82e513063868a5759984c6fb42fbfa Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 26 Feb 2024 13:50:11 +0000 Subject: [PATCH] Bug 34440: Add lead and trail time to circulation rules Signed-off-by: Paul Derscheid Signed-off-by: Katrin Fischer --- Koha/CirculationRules.pm | 6 + admin/smart-rules.pl | 110 +++++++++++------- installer/onboarding.pl | 2 + .../prog/en/modules/admin/smart-rules.tt | 32 ++++- 4 files changed, 106 insertions(+), 44 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 1d07476875..d558c1e781 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -216,6 +216,12 @@ our $RULE_KINDS = { holds_pickup_period => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, + bookings_lead_period => { + scope => [ 'branchcode', 'itemtype' ], + }, + bookings_trail_period => { + scope => [ 'branchcode', 'itemtype' ], + }, # Not included (deprecated?): # * accountsent # * reservecharge diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 9410c2ed07..6a0895448f 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -138,11 +138,13 @@ elsif ($op eq 'cud-delete-branch-cat') { ); Koha::CirculationRules->set_rules( { - branchcode => undef, - itemtype => undef, - rules => { + branchcode => undef, + itemtype => undef, + rules => { holdallowed => undef, hold_fulfillment_policy => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, returnbranch => undef, } } @@ -174,11 +176,13 @@ elsif ($op eq 'cud-delete-branch-cat') { ); Koha::CirculationRules->set_rules( { - branchcode => $branch, - itemtype => undef, - rules => { + branchcode => $branch, + itemtype => undef, + rules => { holdallowed => undef, hold_fulfillment_policy => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, returnbranch => undef, } } @@ -203,11 +207,13 @@ elsif ($op eq 'cud-delete-branch-item') { if ($itemtype eq "*") { Koha::CirculationRules->set_rules( { - branchcode => undef, - itemtype => undef, - rules => { + branchcode => undef, + itemtype => undef, + rules => { holdallowed => undef, hold_fulfillment_policy => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, returnbranch => undef, } } @@ -215,11 +221,13 @@ elsif ($op eq 'cud-delete-branch-item') { } else { Koha::CirculationRules->set_rules( { - branchcode => undef, - itemtype => $itemtype, - rules => { + branchcode => undef, + itemtype => $itemtype, + rules => { holdallowed => undef, hold_fulfillment_policy => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, returnbranch => undef, } } @@ -228,11 +236,13 @@ elsif ($op eq 'cud-delete-branch-item') { } elsif ($itemtype eq "*") { Koha::CirculationRules->set_rules( { - branchcode => $branch, - itemtype => undef, - rules => { + branchcode => $branch, + itemtype => undef, + rules => { holdallowed => undef, hold_fulfillment_policy => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, returnbranch => undef, } } @@ -240,11 +250,13 @@ elsif ($op eq 'cud-delete-branch-item') { } else { Koha::CirculationRules->set_rules( { - branchcode => $branch, - itemtype => $itemtype, - rules => { + branchcode => $branch, + itemtype => $itemtype, + rules => { holdallowed => undef, hold_fulfillment_policy => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, returnbranch => undef, } } @@ -357,23 +369,27 @@ elsif ( $op eq 'cud-add' ) { } elsif ($op eq "cud-set-branch-defaults") { - my $categorycode = $input->param('categorycode'); - my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') ); + my $categorycode = $input->param('categorycode'); + my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') ); my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty'); $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty); - my $holdallowed = $input->param('holdallowed'); + my $holdallowed = $input->param('holdallowed'); 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 $bookings_lead_period = $input->param('bookings_lead_period'); + my $bookings_trail_period = $input->param('bookings_trail_period'); + my $returnbranch = $input->param('returnbranch'); + my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); if ($branch eq "*") { Koha::CirculationRules->set_rules( { - itemtype => undef, - branchcode => undef, - rules => { + itemtype => undef, + branchcode => undef, + rules => { holdallowed => $holdallowed, hold_fulfillment_policy => $hold_fulfillment_policy, + bookings_lead_period => $bookings_lead_period, + bookings_trail_period => $bookings_trail_period, returnbranch => $returnbranch, } } @@ -391,11 +407,13 @@ elsif ($op eq "cud-set-branch-defaults") { } else { Koha::CirculationRules->set_rules( { - itemtype => undef, - branchcode => $branch, - rules => { + itemtype => undef, + branchcode => $branch, + rules => { holdallowed => $holdallowed, hold_fulfillment_policy => $hold_fulfillment_policy, + bookings_lead_period => $bookings_lead_period, + bookings_trail_period => $bookings_trail_period, returnbranch => $returnbranch, } } @@ -584,17 +602,21 @@ elsif ($op eq "cud-add-branch-item") { my $itemtype = $input->param('itemtype'); my $holdallowed = $input->param('holdallowed'); my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); + my $bookings_lead_period = $input->param('bookings_lead_period'); + my $bookings_trail_period = $input->param('bookings_trail_period'); my $returnbranch = $input->param('returnbranch'); if ($branch eq "*") { if ($itemtype eq "*") { Koha::CirculationRules->set_rules( { - itemtype => undef, - branchcode => undef, - rules => { + itemtype => undef, + branchcode => undef, + rules => { holdallowed => $holdallowed, hold_fulfillment_policy => $hold_fulfillment_policy, + bookings_lead_period => $bookings_lead_period, + bookings_trail_period => $bookings_trail_period, returnbranch => $returnbranch, } } @@ -602,11 +624,13 @@ elsif ($op eq "cud-add-branch-item") { } else { Koha::CirculationRules->set_rules( { - itemtype => $itemtype, - branchcode => undef, - rules => { + itemtype => $itemtype, + branchcode => undef, + rules => { holdallowed => $holdallowed, hold_fulfillment_policy => $hold_fulfillment_policy, + bookings_lead_period => $bookings_lead_period, + bookings_trail_period => $bookings_trail_period, returnbranch => $returnbranch, } } @@ -615,11 +639,13 @@ elsif ($op eq "cud-add-branch-item") { } elsif ($itemtype eq "*") { Koha::CirculationRules->set_rules( { - itemtype => undef, - branchcode => $branch, - rules => { + itemtype => undef, + branchcode => $branch, + rules => { holdallowed => $holdallowed, hold_fulfillment_policy => $hold_fulfillment_policy, + bookings_lead_period => $bookings_lead_period, + bookings_trail_period => $bookings_trail_period, returnbranch => $returnbranch, } } @@ -627,11 +653,13 @@ elsif ($op eq "cud-add-branch-item") { } else { Koha::CirculationRules->set_rules( { - itemtype => $itemtype, - branchcode => $branch, - rules => { + itemtype => $itemtype, + branchcode => $branch, + rules => { holdallowed => $holdallowed, hold_fulfillment_policy => $hold_fulfillment_policy, + bookings_lead_period => $bookings_lead_period, + bookings_trail_period => $bookings_trail_period, returnbranch => $returnbranch, } } diff --git a/installer/onboarding.pl b/installer/onboarding.pl index d5b8bee041..38fe3badf5 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -288,6 +288,8 @@ if ( $step == 5 ) { recall_overdue_fine => undef, recall_shelf_time => undef, holds_pickup_period => undef, + bookings_lead_period => undef, + bookings_trail_period => undef, } }; 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 b3499ba6a4..370bd7b17a 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 @@ -633,6 +633,8 @@ Maximum total holds allowed (count) Hold policy Hold pickup library match + Booking preparation period + Booking precaution period Return policy Actions @@ -641,6 +643,8 @@ [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds', { want_rule => 1 } ) %] [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed', { want_rule => 1 } ) %] [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy', { want_rule => 1 }) %] + [% SET bookings_lead_period = CirculationRules.Search( current_branch, undef, undef, 'bookings_lead_period', { want_rule => 1 }) %] + [% SET bookings_trail_period = CirculationRules.Search( current_branch, undef, undef, 'bookings_trail_period', { want_rule => 1 }) %] [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch', { want_rule => 1 }) %] [% SET default_checkout_hold_and_return_policy = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %] @@ -759,6 +763,12 @@ [% END %] + + + + + + + + + + + +