From 0412922b638de0927b93b6a95446b7c822f4f7ae Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Wed, 1 Feb 2017 09:13:17 +0000 Subject: [PATCH] Bug 17047 - Don't create numberpattern if the same exists --- Koha/Subscription/Numberpatterns.pm | 20 +++++++++ .../prog/en/modules/serials/subscription-add.tt | 5 ++- serials/subscription-add.pl | 52 +++++++++------------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Koha/Subscription/Numberpatterns.pm b/Koha/Subscription/Numberpatterns.pm index 1070f43..638e028 100644 --- a/Koha/Subscription/Numberpatterns.pm +++ b/Koha/Subscription/Numberpatterns.pm @@ -32,6 +32,26 @@ Koha::SubscriptionNumberpatterns - Koha SubscriptionNumberpattern object set cla =cut +=head3 uniqeLabel + +=cut + +sub uniqueLabel { + my ($self, $label) = @_; + + my $samelabel = Koha::Subscription::Numberpatterns->search({label => $label})->next(); + if ($samelabel) { + my $i = 2; + my $newlabel = $samelabel->label . " ($i)"; + while (my $othersamelabel = $self->search({label => $newlabel})->next()) { + $i++; + $newlabel = $samelabel->label . " ($i)"; + } + $label = $newlabel; + } + return $label; +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index bddb7f7..46c732e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -331,7 +331,7 @@ function testPredictionPattern() { url:"/cgi-bin/koha/serials/showpredictionpattern.pl", data: ajaxData, success: function(data) { - $("#displayexample").html(data); + $("#displayexample").html(data).show(); patternneedtobetested = 0; } }); @@ -511,6 +511,7 @@ function removeDisabledAttr() { $(document).ready(function() { + $("#displayexample").hide(); $("#mana_search_result").modal("hide"); $("#aqbooksellerid").on('keypress', function(e) { if (e.keyCode == 13) { @@ -1134,7 +1135,7 @@ $(document).ready(function() {