From d3f0b0bcb959863c38ea81fe0dbf87b4a546c41c Mon Sep 17 00:00:00 2001 From: Hayley Mapley Date: Tue, 12 Mar 2019 02:23:38 +0000 Subject: [PATCH] Bug 22489: Fixed issue with onboarding tool failing at step 5 When going through the onboarding process, the tool fails on submit of step 5, due to changes made in the database structure and rule definitions. This patch fixes this, adding code that creates a circulation rule where an issuing rule is also created in onboarding.pl. It removes maxissueqty from being sent with params to make an issuing rule, and adds it instead to the params to make a circulation rule, to reflect the changes that have been made in the database. Test plan: 1) Drop and recreate your database 2) Reload the staff client and follow the installer and onboarding process 3) Confirm that the process finishes without errors --- admin/smart-rules.pl | 6 +++++ installer/onboarding.pl | 30 +++++++++++++++++----- .../prog/en/modules/onboarding/onboardingstep5.tt | 11 ++++---- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index e9c1bf121d..9200c04948 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -222,6 +222,10 @@ elsif ($op eq 'add') { Koha::IssuingRule->new()->set($params)->store(); } + warn $bor; + warn $itemtype; + warn $br; + Koha::CirculationRules->set_rules( { categorycode => $bor, @@ -298,6 +302,8 @@ elsif ($op eq "set-branch-defaults") { $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch); } + warn $branch; + warn $categorycode; Koha::CirculationRules->set_rules( { categorycode => undef, diff --git a/installer/onboarding.pl b/installer/onboarding.pl index 1acc420c43..ae729fc628 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -31,6 +31,8 @@ use Koha::Patrons; use Koha::Patron::Categories; use Koha::ItemTypes; use Koha::IssuingRules; +use Koha::CirculationRules; +use Switch; #Setting variables my $input = new CGI; @@ -240,28 +242,44 @@ if ( $step == 5 ) { my $maxissueqty = $input->param('maxissueqty'); my $issuelength = $input->param('issuelength'); my $lengthunit = $input->param('lengthunit'); - my $renewalsallowed = $input->param('renewalsallowed'); + my $renewalsallowed = $input->param('renewalsallowed'); my $renewalperiod = $input->param('renewalperiod'); my $onshelfholds = $input->param('onshelfholds') || 0; $maxissueqty =~ s/\s//g; $maxissueqty = undef if $maxissueqty !~ /^\d+/; $issuelength = $issuelength eq q{} ? undef : $issuelength; - my $params = { + my $issuingruleparams = { branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype, - maxissueqty => $maxissueqty, renewalsallowed => $renewalsallowed, renewalperiod => $renewalperiod, issuelength => $issuelength, lengthunit => $lengthunit, onshelfholds => $onshelfholds, }; + $branchcode = $branchcode if $branchcode ne '*'; + $branchcode = undef if $branchcode eq '*'; + $categorycode = $categorycode if $categorycode ne '*'; + $categorycode = undef if $categorycode eq '*'; + $itemtype = $itemtype if $itemtype ne '*'; + $itemtype = undef if $itemtype eq '*'; + + my $circulationruleparams = { + branchcode => $branchcode, + categorycode => $categorycode, + itemtype => $itemtype, + rule_name => 'patron_maxissueqty', + rule_value => $maxissueqty, + }; - my $issuingrule = Koha::IssuingRule->new($params); + my $issuingrule = Koha::IssuingRule->new($issuingruleparams); eval { $issuingrule->store; }; + my $circulationrule = Koha::CirculationRule->new($circulationruleparams); + eval { $circulationrule->store; }; + unless ($@) { push @messages, { code => 'success_on_insert_circ_rule' }; } @@ -269,8 +287,8 @@ if ( $step == 5 ) { push @messages, { code => 'error_on_insert_circ_rule' }; } } - - $step++ if Koha::IssuingRules->count; + warn Koha::CirculationRules->count; + $step++ if (Koha::IssuingRules->count && Koha::CirculationRules->count); } my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt index d6eb24e7fc..4e8997507c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt @@ -71,12 +71,6 @@ Required
  • - - - Required -
  • - -
  • Required @@ -101,6 +95,11 @@
  • + + + Required +
  • +
  • Required -- 2.11.0