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

(-)a/C4/Serials.pm (-14 / +108 lines)
Lines 50-55 use Koha::Subscription::Routinglists; Link Here
50
use Koha::Subscriptions;
50
use Koha::Subscriptions;
51
use Koha::Suggestions;
51
use Koha::Suggestions;
52
use Koha::TemplateUtils qw( process_tt );
52
use Koha::TemplateUtils qw( process_tt );
53
use List::Util qw( first );
54
use Locale::PO;
53
55
54
# Define statuses
56
# Define statuses
55
use constant {
57
use constant {
Lines 108-113 BEGIN { Link Here
108
110
109
        findSerialsByStatus
111
        findSerialsByStatus
110
112
113
        GetSeasonsTranslations
111
    );
114
    );
112
}
115
}
113
116
Lines 861-866 sub GetNextSeq { Link Here
861
        $newinnerloop1 = $subscription->{innerloop1} || 0;
864
        $newinnerloop1 = $subscription->{innerloop1} || 0;
862
        $newinnerloop2 = $subscription->{innerloop2} || 0;
865
        $newinnerloop2 = $subscription->{innerloop2} || 0;
863
        $newinnerloop3 = $subscription->{innerloop3} || 0;
866
        $newinnerloop3 = $subscription->{innerloop3} || 0;
867
        my $translations = $subscription->{translations};
864
        my %calc;
868
        my %calc;
865
869
866
        foreach (qw/X Y Z/) {
870
        foreach (qw/X Y Z/) {
Lines 906-920 sub GetNextSeq { Link Here
906
            }
910
            }
907
        }
911
        }
908
        if ( $calc{'X'} ) {
912
        if ( $calc{'X'} ) {
909
            my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale );
913
            my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale, $translations );
910
            $calculated =~ s/\{X\}/$newlastvalue1string/g;
914
            $calculated =~ s/\{X\}/$newlastvalue1string/g;
911
        }
915
        }
912
        if ( $calc{'Y'} ) {
916
        if ( $calc{'Y'} ) {
913
            my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale );
917
            my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale, $translations );
914
            $calculated =~ s/\{Y\}/$newlastvalue2string/g;
918
            $calculated =~ s/\{Y\}/$newlastvalue2string/g;
915
        }
919
        }
916
        if ( $calc{'Z'} ) {
920
        if ( $calc{'Z'} ) {
917
            my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale );
921
            my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale, $translations );
918
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
922
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
919
        }
923
        }
920
924
Lines 952-972 sub GetSeq { Link Here
952
956
953
    my $locale = $subscription->{locale};
957
    my $locale = $subscription->{locale};
954
958
959
    my $translations = $subscription->{translations};
960
955
    my $calculated = $pattern->{numberingmethod};
961
    my $calculated = $pattern->{numberingmethod};
956
962
957
    my $newlastvalue1 = $subscription->{'lastvalue1'} || 0;
963
    my $newlastvalue1 = $subscription->{'lastvalue1'} || 0;
958
    $newlastvalue1 = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale )
964
    $newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale, $translations) if ($pattern->{numbering1}); # reset counter if needed.
959
        if ( $pattern->{numbering1} );    # reset counter if needed.
960
    $calculated =~ s/\{X\}/$newlastvalue1/g;
965
    $calculated =~ s/\{X\}/$newlastvalue1/g;
961
966
962
    my $newlastvalue2 = $subscription->{'lastvalue2'} || 0;
967
    my $newlastvalue2 = $subscription->{'lastvalue2'} || 0;
963
    $newlastvalue2 = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale )
968
    $newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale, $translations) if ($pattern->{numbering2}); # reset counter if needed.
964
        if ( $pattern->{numbering2} );    # reset counter if needed.
965
    $calculated =~ s/\{Y\}/$newlastvalue2/g;
969
    $calculated =~ s/\{Y\}/$newlastvalue2/g;
966
970
967
    my $newlastvalue3 = $subscription->{'lastvalue3'} || 0;
971
    my $newlastvalue3 = $subscription->{'lastvalue3'} || 0;
968
    $newlastvalue3 = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale )
972
    $newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale, $translations) if ($pattern->{numbering3}); # reset counter if needed.
969
        if ( $pattern->{numbering3} );    # reset counter if needed.
970
    $calculated =~ s/\{Z\}/$newlastvalue3/g;
973
    $calculated =~ s/\{Z\}/$newlastvalue3/g;
971
974
972
    my $dt = dt_from_string( $subscription->{firstacquidate} );
975
    my $dt = dt_from_string( $subscription->{firstacquidate} );
Lines 2606-2612 num_type can take : Link Here
2606
=cut
2609
=cut
2607
2610
2608
sub _numeration {
2611
sub _numeration {
2609
    my ( $value, $num_type, $locale ) = @_;
2612
    my ($value, $num_type, $locale, $translations) = @_;
2610
    $value ||= 0;
2613
    $value ||= 0;
2611
    $num_type //= '';
2614
    $num_type //= '';
2612
    $locale ||= 'en';
2615
    $locale ||= 'en';
Lines 2637-2649 sub _numeration { Link Here
2637
            ? $dt->format_cldr("LLLL")
2640
            ? $dt->format_cldr("LLLL")
2638
            : $dt->strftime("%b");
2641
            : $dt->strftime("%b");
2639
    } elsif ( $num_type =~ /^season$/ ) {
2642
    } elsif ( $num_type =~ /^season$/ ) {
2640
        my @seasons = qw( Spring Summer Fall Winter );
2641
        $value  = $value % 4;
2643
        $value  = $value % 4;
2642
        $string = $seasons[$value];
2644
        $string = $translations->{seasons}->[$value];
2643
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2645
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2644
        my @seasonsabrv = qw( Spr Sum Fal Win );
2645
        $value  = $value % 4;
2646
        $value  = $value % 4;
2646
        $string = $seasonsabrv[$value];
2647
        $string = $translations->{seasonsabrv}->[$value];
2647
    } else {
2648
    } else {
2648
        $string = $value;
2649
        $string = $value;
2649
    }
2650
    }
Lines 2713-2718 sub ReopenSubscription { Link Here
2713
    $sth->execute( EXPECTED, $subscriptionid, STOPPED );
2714
    $sth->execute( EXPECTED, $subscriptionid, STOPPED );
2714
}
2715
}
2715
2716
2717
=head2 GetSeasonsTranslations
2718
2719
Provide translations for the seasons and their abbreviations for the specified locale
2720
2721
=cut
2722
2723
sub GetSeasonsTranslations {
2724
    my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_;
2725
    my @seasons        = qw( Spring Summer Fall Winter );
2726
    my @seasonsabrv    = qw( Spr Sum Fal Win );
2727
    my @error_messages = qw();
2728
2729
    my @dirs = (
2730
        C4::Context->config('intranetdir') . '/misc/translator/po',
2731
        C4::Context->config('intranetdir') . '/../../misc/translator/po',
2732
    );
2733
2734
    my $dir = first { -d } @dirs;
2735
2736
    if ($dir) {
2737
        my @po_paths = glob("$dir/$subtag*staff-prog.po");
2738
        if (@po_paths) {
2739
            my $po_path     = $po_paths[0];
2740
            my $po_filename = ( $po_path =~ s/$dir\///gr );
2741
            my $po_data     = Locale::PO->load_file_ashash( $po_path, 'utf8' );
2742
2743
            if ($need_seasons) {
2744
                my $response = _translate( $po_data, @seasons );
2745
                @seasons = @{ $response->{translations} };
2746
                @error_messages =
2747
                    ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } );
2748
            }
2749
2750
            if ($need_seasonsabrv) {
2751
                my $response = _translate( $po_data, @seasonsabrv );
2752
                @seasonsabrv = @{ $response->{translations} };
2753
                @error_messages =
2754
                    ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } );
2755
            }
2756
        } else {
2757
            push(
2758
                @error_messages,
2759
                "No translation file found for $subtag. Ensure that the translation files for $subtag are installed."
2760
            );
2761
        }
2762
    } else {
2763
        push( @error_messages, "The PO directory has not been found. There is a problem in your Koha installation." );
2764
    }
2765
2766
    return { seasons => \@seasons, seasonsabrv => \@seasonsabrv, error_messages => \@error_messages };
2767
}
2768
2716
=head2 subscriptionCurrentlyOnOrder
2769
=head2 subscriptionCurrentlyOnOrder
2717
2770
2718
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
2771
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
Lines 2803-2808 sub _can_do_on_subscription { Link Here
2803
    return 0;
2856
    return 0;
2804
}
2857
}
2805
2858
2859
=head2 _translate
2860
2861
Provide translations for the given words based on the provided data
2862
2863
=cut
2864
2865
sub _translate {
2866
    my ( $data, @words ) = @_;
2867
2868
    my @translations   = qw();
2869
    my @error_messages = qw();
2870
2871
    for my $word (@words) {
2872
        my $regex       = qr/^"$word"$|\%s$word\%s/;
2873
        my @msgids      = grep /$regex/, keys %{$data};
2874
        my $translation = "";
2875
2876
        while ( ( $translation eq "" ) && ( my $msgid = shift(@msgids) ) ) {
2877
            next unless ( $data->{$msgid}->reference =~ /serials/ );
2878
            my $msgstr = $data->{$msgid}->msgstr;
2879
            my @ids    = split( /\%s/, $msgid );
2880
            my @strs   = split( /\%s/, $msgstr );
2881
2882
            next unless ( scalar @ids == scalar @strs );
2883
2884
            my $idx = first { $ids[$_] eq $word || $ids[$_] eq $msgid } 0 .. $#ids;
2885
            $translation = Locale::PO->dequote( $strs[$idx] ) if ( defined $idx );
2886
        }
2887
2888
        if ( $translation eq "" ) {
2889
            push( @translations,   $word );
2890
            push( @error_messages, "The translation for $word doesn't exist in the file \%s" );
2891
            next;
2892
        }
2893
2894
        push( @translations, $translation );
2895
    }
2896
2897
    return { translations => \@translations, error_messages => \@error_messages };
2898
}
2899
2806
=head2 findSerialsByStatus
2900
=head2 findSerialsByStatus
2807
2901
2808
    @serials = findSerialsByStatus($status, $subscriptionid);
2902
    @serials = findSerialsByStatus($status, $subscriptionid);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt (+10 lines)
Lines 81-87 Link Here
81
        </tbody>
81
        </tbody>
82
    </table>
82
    </table>
83
83
84
[% IF (error_messages) %]
85
    <div class="alert alert-warning">
86
        <h4 class="alert-heading"><i class="bi-exclamation-triangle-fill"></i> Warning</h4>
87
        [% FOREACH error_message IN error_messages %]
88
            <p>[% error_message | html %]</p>
89
        [% END %]
90
    </div>
91
[% END %]
92
84
    <fieldset class="action">
93
    <fieldset class="action">
85
        <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button>
94
        <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button>
86
    </fieldset>
95
    </fieldset>
96
87
[% END %]
97
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-2 / +3 lines)
Lines 394-405 Link Here
394
                                    <option value=""></option>
394
                                    <option value=""></option>
395
                                    [% FOREACH l IN locales %]
395
                                    [% FOREACH l IN locales %]
396
                                        [% IF l.language == locale %]
396
                                        [% IF l.language == locale %]
397
                                            <option value="[% l.language | html %]" selected="selected">[% l.description | html %]</option>
397
                                            <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]" selected="selected">[% l.description | html %]</option>
398
                                        [% ELSE %]
398
                                        [% ELSE %]
399
                                            <option value="[% l.language | html %]">[% l.description | html %]</option>
399
                                            <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]">[% l.description | html %]</option>
400
                                        [% END %]
400
                                        [% END %]
401
                                    [% END %]
401
                                    [% END %]
402
                                </select>
402
                                </select>
403
                                <input type="hidden" id="subtag" name="subtag" value="">
403
                                <div class="hint">If empty, English is used</div>
404
                                <div class="hint">If empty, English is used</div>
404
                            </li>
405
                            </li>
405
                            <li id="more_options">
406
                            <li id="more_options">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt (-2 / +12 lines)
Lines 220-229 Link Here
220
                        <select id="locale" name="locale">
220
                        <select id="locale" name="locale">
221
                            <option value=""></option>
221
                            <option value=""></option>
222
                            [% FOREACH locale IN locales %]
222
                            [% FOREACH locale IN locales %]
223
                                <option value="[% locale.language | html %]">[% locale.description | html %]</option>
223
                                <option value="[% locale.language | html %]" data-subtag="[% locale.subtag | html %]">[% locale.description | html %]</option>
224
                            [% END %]
224
                            [% END %]
225
                        </select>
225
                        </select>
226
                        <span class="hint">If empty, English is used</span>
226
                        <span class="hint">If empty, English is used</span>
227
                        <input type="hidden" id="subtag" name="subtag" value="">
227
                    </li>
228
                    </li>
228
                </ol>
229
                </ol>
229
                <table>
230
                <table>
Lines 331-336 Link Here
331
    [% INCLUDE 'calendar.inc' %]
332
    [% INCLUDE 'calendar.inc' %]
332
    [% INCLUDE 'datatables.inc' %]
333
    [% INCLUDE 'datatables.inc' %]
333
    <script>
334
    <script>
335
        function setSubtag () {
336
            $("#subtag").val($("#locale").find(':selected').data('subtag'));
337
        }
338
334
        function confirmDelete() {
339
        function confirmDelete() {
335
            return confirm(_("Are you sure you want to delete this numbering pattern?"));
340
            return confirm(_("Are you sure you want to delete this numbering pattern?"));
336
        }
341
        }
Lines 364-370 Link Here
364
                    'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
369
                    'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
365
                    'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
370
                    'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
366
                    'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
371
                    'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
367
                    'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
372
                    'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag'
368
                ];
373
                ];
369
                for(i in ajaxParams) {
374
                for(i in ajaxParams) {
370
                    var param = ajaxParams[i];
375
                    var param = ajaxParams[i];
Lines 405-410 Link Here
405
            $("#test_pattern").on("click",function(){
410
            $("#test_pattern").on("click",function(){
406
                 testPattern();
411
                 testPattern();
407
            });
412
            });
413
            $("#locale").on("change", function() {
414
                setSubtag();
415
            });
416
417
            setSubtag();
408
        });
418
        });
409
    </script>
419
    </script>
410
[% END %]
420
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (+11 lines)
Lines 411-416 function testPredictionPattern() { Link Here
411
        "whenmorethan2",
411
        "whenmorethan2",
412
        "whenmorethan3",
412
        "whenmorethan3",
413
        "locale",
413
        "locale",
414
        "subtag",
414
        "sfdescription",
415
        "sfdescription",
415
        "unitsperissue",
416
        "unitsperissue",
416
        "issuesperunit",
417
        "issuesperunit",
Lines 688-693 function mana_comment_close() { Link Here
688
    $("#new_mana_comment").hide();
689
    $("#new_mana_comment").hide();
689
}
690
}
690
691
692
function setSubtag() {
693
    $("#subtag").val($("#locale").find(':selected').data('subtag'));
694
}
695
691
function showPredictionPatternTest(data) {
696
function showPredictionPatternTest(data) {
692
    $("#displayexample").html(data).show();
697
    $("#displayexample").html(data).show();
693
    $("#page_2 > div").attr("class", "col-sm-6");
698
    $("#page_2 > div").attr("class", "col-sm-6");
Lines 891-894 $(document).ready(function () { Link Here
891
        const display = $(this).val() == "1" ? "flex" : "none";
896
        const display = $(this).val() == "1" ? "flex" : "none";
892
        $(".use_items").css("display", display).find("select").val("");
897
        $(".use_items").css("display", display).find("select").val("");
893
    });
898
    });
899
900
    $("#locale").on("change", function() {
901
        setSubtag();
902
    });
903
904
    setSubtag();
894
});
905
});
(-)a/serials/showpredictionpattern.pl (-1 / +11 lines)
Lines 34-40 use CGI qw ( -utf8 ); Link Here
34
use Date::Calc  qw( Add_Delta_Days Add_Delta_YM Day_of_Week Delta_Days );
34
use Date::Calc  qw( Add_Delta_Days Add_Delta_YM Day_of_Week Delta_Days );
35
use C4::Auth    qw( get_template_and_user );
35
use C4::Auth    qw( get_template_and_user );
36
use C4::Output  qw( output_html_with_http_headers );
36
use C4::Output  qw( output_html_with_http_headers );
37
use C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq );
37
use C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq GetSeasonsTranslations );
38
use C4::Serials::Frequency;
38
use C4::Serials::Frequency;
39
use Koha::DateUtils qw( dt_from_string );
39
use Koha::DateUtils qw( dt_from_string );
40
40
Lines 97-102 $enddate = dt_from_string($enddate)->ymd if $enddate; Link Here
97
$nextacquidate = $nextacquidate ? dt_from_string($nextacquidate)->ymd : $firstacquidate;
97
$nextacquidate = $nextacquidate ? dt_from_string($nextacquidate)->ymd : $firstacquidate;
98
my $date = $nextacquidate;
98
my $date = $nextacquidate;
99
99
100
my $need_seasons     = grep { $_ =~ /^season$/ } %pattern;
101
my $need_seasonsabrv = grep { $_ =~ /^seasonabrv$/ } %pattern;
102
my $subtag           = scalar $input->param('subtag');
103
104
my $translations;
105
$translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $subtag )
106
    if ( $need_seasons || $need_seasonsabrv );
107
100
my %subscription = (
108
my %subscription = (
101
    locale             => scalar $input->param('locale')     // '',
109
    locale             => scalar $input->param('locale')     // '',
102
    lastvalue1         => scalar $input->param('lastvalue1') // '',
110
    lastvalue1         => scalar $input->param('lastvalue1') // '',
Lines 108-113 my %subscription = ( Link Here
108
    irregularity       => '',
116
    irregularity       => '',
109
    countissuesperunit => 1,
117
    countissuesperunit => 1,
110
    firstacquidate     => $firstacquidate,
118
    firstacquidate     => $firstacquidate,
119
    translations       => $translations,
111
);
120
);
112
121
113
my $issuenumber;
122
my $issuenumber;
Lines 189-194 while ( $i < 1000 ) { Link Here
189
198
190
$template->param(
199
$template->param(
191
    predictions_loop => \@predictions_loop,
200
    predictions_loop => \@predictions_loop,
201
    error_messages   => \@{ $translations->{error_messages} },
192
);
202
);
193
203
194
if ( $frequency->{unit} and not $custompattern ) {
204
if ( $frequency->{unit} and not $custompattern ) {
(-)a/serials/subscription-add.pl (+1 lines)
Lines 231-236 if ( $op eq 'cud-addsubscription' ) { Link Here
231
        map {
231
        map {
232
            {
232
            {
233
                language    => $_->{iso639_2_code},
233
                language    => $_->{iso639_2_code},
234
                subtag      => $_->{subtag},
234
                description => $_->{language_description} || $_->{language}
235
                description => $_->{language_description} || $_->{language}
235
            }
236
            }
236
        } @{ C4::Languages::getAllLanguages() }
237
        } @{ C4::Languages::getAllLanguages() }
(-)a/serials/subscription-numberpatterns.pl (+1 lines)
Lines 119-124 if ( $op && ( $op eq 'new' || $op eq 'modify' ) ) { Link Here
119
        map {
119
        map {
120
            {
120
            {
121
                language    => $_->{iso639_2_code},
121
                language    => $_->{iso639_2_code},
122
                subtag      => $_->{subtag},
122
                description => $_->{language_description} || $_->{language}
123
                description => $_->{language_description} || $_->{language}
123
            }
124
            }
124
        } @{ C4::Languages::getAllLanguages() }
125
        } @{ C4::Languages::getAllLanguages() }
(-)a/t/db_dependent/Serials.t (-4 / +76 lines)
Lines 6-30 Link Here
6
use Modern::Perl;
6
use Modern::Perl;
7
7
8
use C4::Serials
8
use C4::Serials
9
    qw( getroutinglist updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate );
9
    qw( getroutinglist updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate GetSeasonsTranslations );
10
use C4::Serials::Frequency;
10
use C4::Serials::Frequency;
11
use C4::Serials::Numberpattern;
11
use C4::Serials::Numberpattern;
12
use C4::Biblio  qw( AddBiblio GetMarcFromKohaField );
12
use C4::Biblio  qw( AddBiblio GetMarcFromKohaField );
13
use C4::Budgets qw( AddBudgetPeriod AddBudget );
13
use C4::Budgets qw( AddBudgetPeriod AddBudget );
14
use C4::Context;
14
use C4::Items   qw( AddItemFromMarc );
15
use C4::Items   qw( AddItemFromMarc );
16
use Encode qw( encode );
17
use File::Temp;
15
use Koha::Database;
18
use Koha::Database;
16
use Koha::DateUtils qw( dt_from_string output_pref );
19
use Koha::DateUtils qw( dt_from_string output_pref );
17
use Koha::Acquisition::Booksellers;
20
use Koha::Acquisition::Booksellers;
18
use t::lib::Mocks;
21
use t::lib::Mocks;
19
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
20
use Test::MockModule;
23
use Test::MockModule;
21
use Test::NoWarnings;
22
use Test::More tests => 64;
24
use Test::More tests => 64;
23
25
24
BEGIN {
26
BEGIN {
25
    use_ok(
27
    use_ok(
26
        'C4::Serials',
28
        'C4::Serials',
27
        qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate )
29
        qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate GetSeasonsTranslations )
28
    );
30
    );
29
}
31
}
30
32
Lines 740-746 subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { Link Here
740
742
741
subtest "_numeration" => sub {
743
subtest "_numeration" => sub {
742
744
743
    plan tests => 6;
745
    plan tests => 8;
744
746
745
    my $s = C4::Serials::_numeration( 0, 'monthname', 'cat' );
747
    my $s = C4::Serials::_numeration( 0, 'monthname', 'cat' );
746
    is( $s, "gener" );
748
    is( $s, "gener" );
Lines 755-758 subtest "_numeration" => sub { Link Here
755
    like( $s, qr{^ene\.?} );
757
    like( $s, qr{^ene\.?} );
756
    $s = C4::Serials::_numeration( 0, 'monthabrv', 'fr' );
758
    $s = C4::Serials::_numeration( 0, 'monthabrv', 'fr' );
757
    is( $s, "janv." );
759
    is( $s, "janv." );
760
761
    my $translations = {
762
        seasons     => [ 'Spring', 'Summer', 'Fall', 'Winter' ],
763
        seasonsabrv => [ 'Spr',    'Sum',    'Fal',  'Win' ],
764
    };
765
766
    $s = C4::Serials::_numeration( 0, 'season', 'en', $translations );
767
    is( $s, "Spring" );
768
    $s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations );
769
    is( $s, "Spr" );
770
};
771
772
subtest "GetSeasonsTranslations" => sub {
773
774
    plan tests => 8;
775
776
    my @seasons     = qw( Printemps Été Automne Hiver );
777
    my @seasonsabrv = qw( Pri Été Aut Hiv );
778
779
    my $dir      = C4::Context->config('intranetdir') . '/misc/translator/po/';
780
    my $fh       = File::Temp->new( DIR => $dir, SUFFIX => '-staff-prog.po' );
781
    my $filename = $fh->filename;
782
783
    my $txt = '
784
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
785
#, c-format
786
msgid "Spring"
787
msgstr "Printemps"
788
789
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
790
#, c-format
791
msgid "Summer"
792
msgstr "Été"
793
794
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
795
#, c-format
796
msgid "Fall"
797
msgstr "Automne"
798
799
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
800
#, c-format
801
msgid "Winter"
802
msgstr "Hiver"
803
804
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:208
805
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:210
806
#, c-format
807
msgid "Sum"
808
msgstr "Total"
809
810
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:248
811
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt:43
812
#, c-format
813
msgid ""
814
"%s %sSpring%s %s %sSummer%s %s %sFall%s %s %sWinter%s %s %sSpr%s %s %sSum%s "
815
"%s %sFal%s %s %sWin%s %s %s %s "
816
msgstr ""
817
"%s %sPrintemps%s %s %sÉté%s %s %sAutomne%s %s %sHiver%s %s %sPri%s %s %sÉté"
818
"%s %s %sAut%s %s %sHiv%s %s %s %s "
819
    ';
820
821
    print $fh encode( 'utf-8', $txt );
822
    close($fh);
823
824
    my $translations = GetSeasonsTranslations( 1, 1, $filename =~ s/($dir|-staff-prog.po)//gr );
825
826
    for my $idx ( 0 .. $#{ $translations->{seasons} } ) {
827
        is( $translations->{seasons}->[$idx],     $seasons[$idx] );
828
        is( $translations->{seasonsabrv}->[$idx], $seasonsabrv[$idx] );
829
    }
758
};
830
};
(-)a/t/db_dependent/Serials/GetNextSeq.t (-1 / +1 lines)
Lines 144-149 $subscription = { Link Here
144
    irregularity       => '3;4;6',
144
    irregularity       => '3;4;6',
145
    countissuesperunit => 1,
145
    countissuesperunit => 1,
146
    locale             => 'C',
146
    locale             => 'C',
147
    translations       => { seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ] },
147
};
148
};
148
$pattern = {
149
$pattern = {
149
    add1            => 1, add2          => 0, add3          => 0,
150
    add1            => 1, add2          => 0, add3          => 0,
150
- 

Return to bug 35590