1 package Koha
::Subscription
::Numberpatterns
;
3 # Copyright 2016 BibLibre Morgane Alonso
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use Koha
::Subscription
::Numberpattern
;
23 use base
qw(Koha::Objects);
27 Koha::SubscriptionNumberpatterns - Koha SubscriptionNumberpattern object set class
40 my ($self, $label) = @_;
42 my $samelabel = Koha
::Subscription
::Numberpatterns
->search({label
=> $label})->next();
45 my $newlabel = $samelabel->label . " ($i)";
46 while (my $othersamelabel = $self->search({label
=> $newlabel})->next()) {
48 $newlabel = $samelabel->label . " ($i)";
55 =head3 new_or_existing
60 my ($self, $params) = @_;
63 if ( $params->{'numbering_pattern'} eq 'mana' ) {
64 foreach (qw
/numberingmethod label1 add1 every1 whenmorethan1 setto1
65 numbering1 label2 add2 every2 whenmorethan2 setto2 numbering2
66 label3 add3 every3 whenmorethan3 setto3 numbering3
/) {
67 $params_np->{$_} = $params->{$_} if $params->{$_};
70 my $existing = Koha
::Subscription
::Numberpatterns
->search($params_np)->next();
76 $params_np->{label
} = Koha
::Subscription
::Numberpatterns
->uniqueLabel($params->{'patternname'});
77 $params_np->{description
} = $params->{'sndescription'};
80 my $subscription_np = Koha
::Subscription
::Numberpattern
->new()->set($params_np)->store();
81 return $subscription_np->id;
84 return $params->{'numbering_pattern'};
92 return 'SubscriptionNumberpattern';
100 return 'Koha::Subscription::Numberpattern';
105 Morgane Alonso <morgane.alonso@biblibre.com>