From 7d270779f10f19c300fc0bf02d38c11469e846cc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Feb 2022 16:16:19 +0100 Subject: [PATCH] Bug 20615: Add the link of number of times the authority are used in edit mode Currently when show an authority record you can see the count of records linked with that authority, but when edit that authority record the that detail is dissapeared. Applying this patch will have that information also on edit mode of authority. Test plan: 1) Search for an authority that is already connected with at least one record 2) On detail view of an authority you can check that authority is linked with x records. 3) Edit that authority and the information about in how many records that authority is linked is missing. 4) Apply this patch 5) Edit again that authrity and you can find now the count in how many records is used that authority --- authorities/authorities.pl | 5 ++++- .../prog/en/modules/authorities/authorities.tt | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 3b4a5d64be..1c2b3d068c 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -557,13 +557,16 @@ if(!$authtypecode) { $authtypecode = $authid ? Koha::Authorities->find($authid)->authtypecode : ''; } +my $authobj = Koha::Authorities->find($authid); +my $count = $authobj ? $authobj->get_usage_count : 0; + my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "authorities/authorities.tt", query => $input, type => "intranet", flagsrequired => {editauthorities => 1}, }); -$template->param(nonav => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid); +$template->param(nonav => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid, count=>$count); $tagslib = GetTagsLabels(1,$authtypecode); $mandatory_z3950 = GetMandatoryFieldZ3950($authtypecode); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index 71a935a5bc..c9f2ee32cc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -263,7 +263,13 @@ [% END %] - +
+ [% IF count %] + Used in [% count | html %] record(s) + [% ELSE %] + This authority is not used in any records. + [% END %] +