@@ -, +, @@ - 'relationship' containing '_bad_data' (generated by the atomicupdate on undef relationships. - 'relationship' values that are not in the borrowerRelationship --- about.pl | 46 +++++++++++++++++++ .../intranet-tmpl/prog/en/modules/about.tt | 19 +++++++- 2 files changed, 64 insertions(+), 1 deletion(-) --- a/about.pl +++ a/about.pl @@ -460,6 +460,52 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; ); } } + +# Guarantor relationships warnings +{ + my $dbh = C4::Context->dbh; + my ($bad_relationships_count) = $dbh->selectall_arrayref(q{ + SELECT COUNT(*) + FROM ( + SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data' + UNION ALL + SELECT relationship FROM borrowers WHERE relationship='_bad_data') a + }); + + $bad_relationships_count = $bad_relationships_count->[0]->[0]; + + my @existing_relationships = $dbh->selectall_array(q{ + SELECT DISTINCT(relationship) + FROM ( + SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL + UNION ALL + SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a + }); + + my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') ); + $valid_relationships{ _bad_data } = 1; # we handle this case in another way + + my @wrong_relationships = grep { !$valid_relationships{ $_->[0] } } @existing_relationships; + + if ( @wrong_relationships or $bad_relationships_count ) { + + $template->param( + warnRelationships => 1, + ); + + if ( @wrong_relationships ) { + $template->param( + wrong_relationships => \@wrong_relationships + ); + } + if ($bad_relationships_count) { + $template->param( + bad_relationships_count => $bad_relationships_count, + ); + } + } +} + my %versions = C4::Context::get_versions(); $template->param( --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -184,7 +184,7 @@
You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.
@@ -229,6 +229,23 @@Your database contained guarantee/guarantor pairs with no defined relationship. They have been set the value '_bad_data' in the [% "borrowers.relationship" | $HtmlTags tag="strong" %] and/or [% "borrower_relationships.relationship" | $HtmlTags tag="strong" %] columns. Fix them manually by recreating those relationships, or have your system's administrator correct the values.
+ [% END %] + + [% IF wrong_relationships %] +The following values have been used for guarantee/guarantor relationships, but do not exist in the 'borrowerRelationship' system preference:
+If the relationship is one you want, please add it to the 'borrowerRelationship' system preference, otherwise have your system's administrator correct the values in [% "borrowers.relationship" | $HtmlTags tag="strong" %] and/or [% "borrower_relationships.relationship" | $HtmlTags tag="strong" %] in the database.
+ [% END %] + [% END %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules %]