From 221669317b1f92b9635fd3905305dd3fe5f55e8b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 1 Mar 2017 13:58:54 +0000 Subject: [PATCH] Bug 15707 - Display error if group title is already used --- admin/library_groups.pl | 25 +++++++++++++--------- .../prog/en/modules/admin/library_groups.tt | 4 ++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/admin/library_groups.pl b/admin/library_groups.pl index e506d48..0bd50b9 100755 --- a/admin/library_groups.pl +++ b/admin/library_groups.pl @@ -48,16 +48,21 @@ if ( $action eq 'add' ) { my $description = $cgi->param('description') || undef; my $branchcode = $cgi->param('branchcode') || undef; - my $group = Koha::Library::Group->new( - { - parent_id => $parent_id, - title => $title, - description => $description, - branchcode => $branchcode, - } - )->store(); - - $template->param( added => $group ); + if ( Koha::Library::Groups->search( { title => $title } )->count() ) { + $template->param( error_duplicate_title => $title ); + } + else { + my $group = Koha::Library::Group->new( + { + parent_id => $parent_id, + title => $title, + description => $description, + branchcode => $branchcode, + } + )->store(); + + $template->param( added => $group ); + } } elsif ( $action eq 'edit' ) { my $id = $cgi->param('id') || undef; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt index d336107..95200b2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt @@ -108,6 +108,10 @@ [% deleted.library | $KohaSpan class = 'name' %] has been removed from group. [% END %] +[% ELSIF error_duplicate_title %] +
+ A group with the title [% error_duplicate_title | $KohaSpan class = 'name' %] already exists. +
[% END %]
-- 2.10.2