From f32cdb7211705a0950e98897820f3a4a7bc52cd8 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 Signed-off-by: Tomas Cohen Arazi Edit: I added !$branchcode && to the checked condition so we can add multiple libraries back. Signed-off-by: Jonathan Druart --- 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 e506d48789..c540948b89 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 ( !$branchcode && 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 d3361072ae..95200b22ac 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.39.5