View | Details | Raw Unified | Return to bug 17047
Collapse All | Expand All

(-)a/Koha/Subscription/Numberpatterns.pm (+20 lines)
Lines 32-37 Koha::SubscriptionNumberpatterns - Koha SubscriptionNumberpattern object set cla Link Here
32
32
33
=cut
33
=cut
34
34
35
=head3 uniqeLabel
36
37
=cut
38
39
sub uniqueLabel {
40
    my ($self, $label) = @_;
41
42
    my $samelabel = Koha::Subscription::Numberpatterns->search({label => $label})->next();
43
    if ($samelabel) {
44
        my $i = 2;
45
        my $newlabel = $samelabel->label . " ($i)";
46
        while (my $othersamelabel = $self->search({label => $newlabel})->next()) {
47
            $i++;
48
            $newlabel = $samelabel->label . " ($i)";
49
        }
50
        $label = $newlabel;
51
    }
52
    return $label;
53
}
54
35
=head3 type
55
=head3 type
36
56
37
=cut
57
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-2 / +3 lines)
Lines 331-337 function testPredictionPattern() { Link Here
331
        url:"/cgi-bin/koha/serials/showpredictionpattern.pl",
331
        url:"/cgi-bin/koha/serials/showpredictionpattern.pl",
332
        data: ajaxData,
332
        data: ajaxData,
333
        success: function(data) {
333
        success: function(data) {
334
            $("#displayexample").html(data);
334
            $("#displayexample").html(data).show();
335
            patternneedtobetested = 0;
335
            patternneedtobetested = 0;
336
        }
336
        }
337
    });
337
    });
Lines 511-516 function removeDisabledAttr() { Link Here
511
511
512
512
513
$(document).ready(function() {
513
$(document).ready(function() {
514
    $("#displayexample").hide();
514
    $("#mana_search_result").modal("hide");
515
    $("#mana_search_result").modal("hide");
515
    $("#aqbooksellerid").on('keypress', function(e) {
516
    $("#aqbooksellerid").on('keypress', function(e) {
516
        if (e.keyCode == 13) {
517
        if (e.keyCode == 13) {
Lines 1134-1140 $(document).ready(function() { Link Here
1134
</div>
1135
</div>
1135
1136
1136
<div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 90%; left:5%; margin-left: auto; display: none;">
1137
<div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 90%; left:5%; margin-left: auto; display: none;">
1137
    <div class="modal-dialog">
1138
    <div class="modal-dialog modal-lg">
1138
        <div class="modal-content">
1139
        <div class="modal-content">
1139
            <div class="modal-header">
1140
            <div class="modal-header">
1140
                <h3 id="mana_search_result_label"></h3>
1141
                <h3 id="mana_search_result_label"></h3>
(-)a/serials/subscription-add.pl (-32 / +21 lines)
Lines 289-327 sub _guess_enddate { Link Here
289
}
289
}
290
290
291
sub manage_subscription_numbering_pattern_id {
291
sub manage_subscription_numbering_pattern_id {
292
    my $numberpattern;
292
    my $params;
293
    if ( $query->param('numbering_pattern') eq 'mana' ) {
293
    if ( $query->param('numbering_pattern') eq 'mana' ) {
294
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set(
294
        foreach (qw/numberingmethod label1 add1 every1 whenmorethan1 setto1
295
            {
295
                   numbering1 label2 add2 every2 whenmorethan2 setto2 numbering2
296
                label           => $query->param('patternname'),
296
                   label3 add3 every3 whenmorethan3 setto3 numbering3/) {
297
                description     => $query->param('sndescription'),
297
            $params->{$_} = $query->param($_) if $query->param($_);
298
                numberingmethod => $query->param('numberingmethod'),
298
        }
299
                label1          => $query->param('label1'),
299
300
                add1            => $query->param('add1'),
300
        my $existing = Koha::Subscription::Numberpatterns->search($params)->next();
301
                every1          => $query->param('every1'),
301
302
                whenmorethan1   => $query->param('whenmorethan1'),
302
        if ($existing) {
303
                setto1          => $query->param('setto1'),
303
            return $existing->id;
304
                numbering1      => $query->param('numbering1'),
304
        }
305
                label2          => $query->param('label2'),
305
306
                add2            => $query->param('add2'),
306
        $params->{label} = Koha::Subscription::Numberpattern->uniqueLabel($query->param('patternname'));
307
                every2          => $query->param('every2'),
307
        $params->{description} = $query->param('sndescription');
308
                whenmorethan2   => $query->param('whenmorethan2'),
308
309
                setto2          => $query->param('setto2'),
309
310
                numbering2      => $query->param('numbering2'),
310
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set($params)->store();
311
                label3          => $query->param('label3'),
311
        return $subscription_np->id;
312
                add3            => $query->param('add3'),
313
                every3          => $query->param('every3'),
314
                whenmorethan3   => $query->param('whenmorethan3'),
315
                setto3          => $query->param('setto3'),
316
                numbering3      => $query->param('numbering3'),
317
            }
318
        )->store();
319
        $numberpattern = $subscription_np->id;
320
    }
321
    else {
322
        $numberpattern = $query->param('numbering_pattern');
323
    }
312
    }
324
    return $numberpattern;
313
314
    return $query->param('numbering_pattern');
325
}
315
}
326
316
327
sub manage_subscription_frequencies_id {
317
sub manage_subscription_frequencies_id {
328
- 

Return to bug 17047