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 287-325 sub _guess_enddate { Link Here
287
}
287
}
288
288
289
sub manage_subscription_numbering_pattern_id {
289
sub manage_subscription_numbering_pattern_id {
290
    my $numberpattern;
290
    my $params;
291
    if ( $query->param('numbering_pattern') eq 'mana' ) {
291
    if ( $query->param('numbering_pattern') eq 'mana' ) {
292
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set(
292
        foreach (qw/numberingmethod label1 add1 every1 whenmorethan1 setto1
293
            {
293
                   numbering1 label2 add2 every2 whenmorethan2 setto2 numbering2
294
                label           => $query->param('patternname'),
294
                   label3 add3 every3 whenmorethan3 setto3 numbering3/) {
295
                description     => $query->param('sndescription'),
295
            $params->{$_} = $query->param($_) if $query->param($_);
296
                numberingmethod => $query->param('numberingmethod'),
296
        }
297
                label1          => $query->param('label1'),
297
298
                add1            => $query->param('add1'),
298
        my $existing = Koha::Subscription::Numberpatterns->search($params)->next();
299
                every1          => $query->param('every1'),
299
300
                whenmorethan1   => $query->param('whenmorethan1'),
300
        if ($existing) {
301
                setto1          => $query->param('setto1'),
301
            return $existing->id;
302
                numbering1      => $query->param('numbering1'),
302
        }
303
                label2          => $query->param('label2'),
303
304
                add2            => $query->param('add2'),
304
        $params->{label} = Koha::Subscription::Numberpattern->uniqueLabel($query->param('patternname'));
305
                every2          => $query->param('every2'),
305
        $params->{description} = $query->param('sndescription');
306
                whenmorethan2   => $query->param('whenmorethan2'),
306
307
                setto2          => $query->param('setto2'),
307
308
                numbering2      => $query->param('numbering2'),
308
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set($params)->store();
309
                label3          => $query->param('label3'),
309
        return $subscription_np->id;
310
                add3            => $query->param('add3'),
311
                every3          => $query->param('every3'),
312
                whenmorethan3   => $query->param('whenmorethan3'),
313
                setto3          => $query->param('setto3'),
314
                numbering3      => $query->param('numbering3'),
315
            }
316
        )->store();
317
        $numberpattern = $subscription_np->id;
318
    }
319
    else {
320
        $numberpattern = $query->param('numbering_pattern');
321
    }
310
    }
322
    return $numberpattern;
311
312
    return $query->param('numbering_pattern');
323
}
313
}
324
314
325
sub manage_subscription_frequencies_id {
315
sub manage_subscription_frequencies_id {
326
- 

Return to bug 17047