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

(-)a/C4/Serials.pm (-11 / +108 lines)
Lines 48-53 use Koha::Subscription::Histories; Link Here
48
use Koha::Subscriptions;
48
use Koha::Subscriptions;
49
use Koha::Suggestions;
49
use Koha::Suggestions;
50
use Koha::TemplateUtils qw( process_tt );
50
use Koha::TemplateUtils qw( process_tt );
51
use List::Util qw( first );
52
use Locale::PO;
51
53
52
# Define statuses
54
# Define statuses
53
use constant {
55
use constant {
Lines 105-110 BEGIN { Link Here
105
107
106
      findSerialsByStatus
108
      findSerialsByStatus
107
109
110
      GetSeasonsTranslations
108
    );
111
    );
109
}
112
}
110
113
Lines 859-864 sub GetNextSeq { Link Here
859
        $newinnerloop1 = $subscription->{innerloop1} || 0;
862
        $newinnerloop1 = $subscription->{innerloop1} || 0;
860
        $newinnerloop2 = $subscription->{innerloop2} || 0;
863
        $newinnerloop2 = $subscription->{innerloop2} || 0;
861
        $newinnerloop3 = $subscription->{innerloop3} || 0;
864
        $newinnerloop3 = $subscription->{innerloop3} || 0;
865
        my $translations = $subscription->{translations};
862
        my %calc;
866
        my %calc;
863
        foreach(qw/X Y Z/) {
867
        foreach(qw/X Y Z/) {
864
            $calc{$_} = 1 if ($numberingmethod =~ /\{$_\}/);
868
            $calc{$_} = 1 if ($numberingmethod =~ /\{$_\}/);
Lines 897-911 sub GetNextSeq { Link Here
897
            }
901
            }
898
        }
902
        }
899
        if($calc{'X'}) {
903
        if($calc{'X'}) {
900
            my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale );
904
            my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale, $translations );
901
            $calculated =~ s/\{X\}/$newlastvalue1string/g;
905
            $calculated =~ s/\{X\}/$newlastvalue1string/g;
902
        }
906
        }
903
        if($calc{'Y'}) {
907
        if($calc{'Y'}) {
904
            my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale );
908
            my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale, $translations );
905
            $calculated =~ s/\{Y\}/$newlastvalue2string/g;
909
            $calculated =~ s/\{Y\}/$newlastvalue2string/g;
906
        }
910
        }
907
        if($calc{'Z'}) {
911
        if($calc{'Z'}) {
908
            my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale );
912
            my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale, $translations );
909
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
913
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
910
        }
914
        }
911
915
Lines 934-951 sub GetSeq { Link Here
934
938
935
    my $locale = $subscription->{locale};
939
    my $locale = $subscription->{locale};
936
940
941
    my $translations = $subscription->{translations};
942
937
    my $calculated = $pattern->{numberingmethod};
943
    my $calculated = $pattern->{numberingmethod};
938
944
939
    my $newlastvalue1 = $subscription->{'lastvalue1'} || 0;
945
    my $newlastvalue1 = $subscription->{'lastvalue1'} || 0;
940
    $newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale) if ($pattern->{numbering1}); # reset counter if needed.
946
    $newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale, $translations) if ($pattern->{numbering1}); # reset counter if needed.
941
    $calculated =~ s/\{X\}/$newlastvalue1/g;
947
    $calculated =~ s/\{X\}/$newlastvalue1/g;
942
948
943
    my $newlastvalue2 = $subscription->{'lastvalue2'} || 0;
949
    my $newlastvalue2 = $subscription->{'lastvalue2'} || 0;
944
    $newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale) if ($pattern->{numbering2}); # reset counter if needed.
950
    $newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale, $translations) if ($pattern->{numbering2}); # reset counter if needed.
945
    $calculated =~ s/\{Y\}/$newlastvalue2/g;
951
    $calculated =~ s/\{Y\}/$newlastvalue2/g;
946
952
947
    my $newlastvalue3 = $subscription->{'lastvalue3'} || 0;
953
    my $newlastvalue3 = $subscription->{'lastvalue3'} || 0;
948
    $newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale) if ($pattern->{numbering3}); # reset counter if needed.
954
    $newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale, $translations) if ($pattern->{numbering3}); # reset counter if needed.
949
    $calculated =~ s/\{Z\}/$newlastvalue3/g;
955
    $calculated =~ s/\{Z\}/$newlastvalue3/g;
950
    return $calculated;
956
    return $calculated;
951
}
957
}
Lines 2501-2507 num_type can take : Link Here
2501
=cut
2507
=cut
2502
2508
2503
sub _numeration {
2509
sub _numeration {
2504
    my ($value, $num_type, $locale) = @_;
2510
    my ($value, $num_type, $locale, $translations) = @_;
2505
    $value ||= 0;
2511
    $value ||= 0;
2506
    $num_type //= '';
2512
    $num_type //= '';
2507
    $locale ||= 'en';
2513
    $locale ||= 'en';
Lines 2529-2541 sub _numeration { Link Here
2529
            ? $dt->format_cldr( "LLLL" )
2535
            ? $dt->format_cldr( "LLLL" )
2530
            : $dt->strftime("%b");
2536
            : $dt->strftime("%b");
2531
    } elsif ( $num_type =~ /^season$/ ) {
2537
    } elsif ( $num_type =~ /^season$/ ) {
2532
        my @seasons= qw( Spring Summer Fall Winter );
2533
        $value = $value % 4;
2538
        $value = $value % 4;
2534
        $string = $seasons[$value];
2539
        $string = $translations->{seasons}->[$value];
2535
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2540
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2536
        my @seasonsabrv= qw( Spr Sum Fal Win );
2537
        $value = $value % 4;
2541
        $value = $value % 4;
2538
        $string = $seasonsabrv[$value];
2542
        $string = $translations->{seasonsabrv}->[$value];
2539
    } else {
2543
    } else {
2540
        $string = $value;
2544
        $string = $value;
2541
    }
2545
    }
Lines 2597-2602 sub ReopenSubscription { Link Here
2597
    $sth->execute( EXPECTED, $subscriptionid, STOPPED );
2601
    $sth->execute( EXPECTED, $subscriptionid, STOPPED );
2598
}
2602
}
2599
2603
2604
=head2 GetSeasonsTranslations
2605
2606
Provide translations for the seasons and their abbreviations for the specified locale
2607
2608
=cut
2609
2610
sub GetSeasonsTranslations {
2611
    my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_;
2612
    my @seasons        = qw( Spring Summer Fall Winter );
2613
    my @seasonsabrv    = qw( Spr Sum Fal Win );
2614
    my @error_messages = qw();
2615
2616
    my @dirs = (
2617
        C4::Context->config('intranetdir') . '/misc/translator/po',
2618
        C4::Context->config('intranetdir') . '/../../misc/translator/po',
2619
    );
2620
2621
    my $dir = first { -d } @dirs;
2622
2623
    if ($dir) {
2624
        my @po_paths = glob("$dir/$subtag*staff-prog.po");
2625
        if (@po_paths) {
2626
            my $po_path     = $po_paths[0];
2627
            my $po_filename = ( $po_path =~ s/$dir\///gr );
2628
            my $po_data     = Locale::PO->load_file_ashash( $po_path, 'utf8' );
2629
2630
            if ($need_seasons) {
2631
                my $response = _translate( $po_data, @seasons );
2632
                @seasons = @{ $response->{translations} };
2633
                @error_messages =
2634
                    ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } );
2635
            }
2636
2637
            if ($need_seasonsabrv) {
2638
                my $response = _translate( $po_data, @seasonsabrv );
2639
                @seasonsabrv = @{ $response->{translations} };
2640
                @error_messages =
2641
                    ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } );
2642
            }
2643
        } else {
2644
            push(
2645
                @error_messages,
2646
                "No translation file found for $subtag. Ensure that the translation files for $subtag are installed."
2647
            );
2648
        }
2649
    } else {
2650
        push( @error_messages, "The PO directory has not been found. There is a problem in your Koha installation." );
2651
    }
2652
2653
    return { seasons => \@seasons, seasonsabrv => \@seasonsabrv, error_messages => \@error_messages };
2654
}
2655
2600
=head2 subscriptionCurrentlyOnOrder
2656
=head2 subscriptionCurrentlyOnOrder
2601
2657
2602
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
2658
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
Lines 2691-2696 sub _can_do_on_subscription { Link Here
2691
    return 0;
2747
    return 0;
2692
}
2748
}
2693
2749
2750
=head2 _translate
2751
2752
Provide translations for the given words based on the provided data
2753
2754
=cut
2755
2756
sub _translate {
2757
    my ( $data, @words ) = @_;
2758
2759
    my @translations   = qw();
2760
    my @error_messages = qw();
2761
2762
    for my $word (@words) {
2763
        my $regex       = qr/^"$word"$|\%s$word\%s/;
2764
        my @msgids      = grep /$regex/, keys %{$data};
2765
        my $translation = "";
2766
2767
        while ( ( $translation eq "" ) && ( my $msgid = shift(@msgids) ) ) {
2768
            next unless ( $data->{$msgid}->reference =~ /serials/ );
2769
            my $msgstr = $data->{$msgid}->msgstr;
2770
            my @ids    = split( /\%s/, $msgid );
2771
            my @strs   = split( /\%s/, $msgstr );
2772
2773
            next unless ( scalar @ids == scalar @strs );
2774
2775
            my $idx = first { $ids[$_] eq $word || $ids[$_] eq $msgid } 0 .. $#ids;
2776
            $translation = Locale::PO->dequote( $strs[$idx] ) if ( defined $idx );
2777
        }
2778
2779
        if ( $translation eq "" ) {
2780
            push( @translations,   $word );
2781
            push( @error_messages, "The translation for $word doesn't exist in the file \%s" );
2782
            next;
2783
        }
2784
2785
        push( @translations, $translation );
2786
    }
2787
2788
    return { translations => \@translations, error_messages => \@error_messages };
2789
}
2790
2694
=head2 findSerialsByStatus
2791
=head2 findSerialsByStatus
2695
2792
2696
    @serials = findSerialsByStatus($status, $subscriptionid);
2793
    @serials = findSerialsByStatus($status, $subscriptionid);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt (+9 lines)
Lines 84-89 Link Here
84
  </tbody>
84
  </tbody>
85
</table>
85
</table>
86
86
87
[% IF (error_messages) %]
88
    <div class="alert alert-warning">
89
        <h4 class="alert-heading"><i class="bi-exclamation-triangle-fill"></i> Warning</h4>
90
        [% FOREACH error_message IN error_messages %]
91
            <p>[% error_message | html %]</p>
92
        [% END %]
93
    </div>
94
[% END %]
95
87
<fieldset class="action">
96
<fieldset class="action">
88
    <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button>
97
    <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button>
89
</fieldset>
98
</fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-2 / +3 lines)
Lines 383-394 fieldset.rows table { clear: none; margin: 0; } Link Here
383
                                            <option value=""></option>
383
                                            <option value=""></option>
384
                                            [% FOREACH l IN locales %]
384
                                            [% FOREACH l IN locales %]
385
                                                [% IF l.language == locale %]
385
                                                [% IF l.language == locale %]
386
                                                    <option value="[% l.language | html %]" selected="selected">[% l.description | html %]</option>
386
                                                    <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]" selected="selected">[% l.description | html %]</option>
387
                                                [% ELSE %]
387
                                                [% ELSE %]
388
                                                    <option value="[% l.language | html %]">[% l.description | html %]</option>
388
                                                    <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]">[% l.description | html %]</option>
389
                                                [% END %]
389
                                                [% END %]
390
                                            [% END %]
390
                                            [% END %]
391
                                        </select>
391
                                        </select>
392
                                        <input type="hidden" id="subtag" name="subtag" value="">
392
                                        <div class="hint">If empty, English is used</div>
393
                                        <div class="hint">If empty, English is used</div>
393
                                    </li>
394
                                    </li>
394
                                    <li id="more_options">
395
                                    <li id="more_options">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt (-2 / +12 lines)
Lines 206-215 Link Here
206
                  <select id="locale" name="locale">
206
                  <select id="locale" name="locale">
207
                      <option value=""></option>
207
                      <option value=""></option>
208
                      [% FOREACH locale IN locales %]
208
                      [% FOREACH locale IN locales %]
209
                        <option value="[% locale.language | html %]">[% locale.description | html %]</option>
209
                        <option value="[% locale.language | html %]" data-subtag="[% locale.subtag | html %]">[% locale.description | html %]</option>
210
                      [% END %]
210
                      [% END %]
211
                    </select>
211
                    </select>
212
                  <span class="hint">If empty, English is used</span>
212
                  <span class="hint">If empty, English is used</span>
213
                  <input type="hidden" id="subtag" name="subtag" value="">
213
                </li>
214
                </li>
214
              </ol>
215
              </ol>
215
              <table>
216
              <table>
Lines 324-329 Link Here
324
    [% INCLUDE 'calendar.inc' %]
325
    [% INCLUDE 'calendar.inc' %]
325
    [% INCLUDE 'datatables.inc' %]
326
    [% INCLUDE 'datatables.inc' %]
326
    <script>
327
    <script>
328
        function setSubtag () {
329
            $("#subtag").val($("#locale").find(':selected').data('subtag'));
330
        }
331
327
        function confirmDelete() {
332
        function confirmDelete() {
328
            return confirm(_("Are you sure you want to delete this numbering pattern?"));
333
            return confirm(_("Are you sure you want to delete this numbering pattern?"));
329
        }
334
        }
Lines 357-363 Link Here
357
                    'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
362
                    'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
358
                    'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
363
                    'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
359
                    'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
364
                    'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
360
                    'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
365
                    'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag'
361
                ];
366
                ];
362
                for(i in ajaxParams) {
367
                for(i in ajaxParams) {
363
                    var param = ajaxParams[i];
368
                    var param = ajaxParams[i];
Lines 400-405 Link Here
400
            $("#test_pattern").on("click",function(){
405
            $("#test_pattern").on("click",function(){
401
                 testPattern();
406
                 testPattern();
402
            });
407
            });
408
            $("#locale").on("change", function() {
409
                setSubtag();
410
            });
411
412
            setSubtag();
403
        });
413
        });
404
    </script>
414
    </script>
405
[% END %]
415
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-1 / +10 lines)
Lines 329-335 function testPredictionPattern() { Link Here
329
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
329
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
330
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
330
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
331
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
331
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
332
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale',
332
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag',
333
        'sfdescription', 'unitsperissue', 'issuesperunit', 'unit'
333
        'sfdescription', 'unitsperissue', 'issuesperunit', 'unit'
334
    ];
334
    ];
335
    for(i in ajaxParams) {
335
    for(i in ajaxParams) {
Lines 543-548 function mana_comment_close(){ Link Here
543
    $("#new_mana_comment").hide();
543
    $("#new_mana_comment").hide();
544
}
544
}
545
545
546
function setSubtag () {
547
    $("#subtag").val($("#locale").find(':selected').data('subtag'));
548
}
549
546
function showPredictionPatternTest( data ){
550
function showPredictionPatternTest( data ){
547
    $("#displayexample").html(data).show();
551
    $("#displayexample").html(data).show();
548
    $("#page_2 > div").attr("class","col-xs-6");
552
    $("#page_2 > div").attr("class","col-xs-6");
Lines 744-747 $(document).ready(function() { Link Here
744
        $(".use_items").css('display', display).find("select").val("")
748
        $(".use_items").css('display', display).find("select").val("")
745
    });
749
    });
746
750
751
    $("#locale").on("change", function() {
752
        setSubtag();
753
    });
754
755
    setSubtag();
747
});
756
});
(-)a/serials/showpredictionpattern.pl (-1 / +10 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 ) if ( $need_seasons || $need_seasonsabrv );
106
100
my %subscription = (
107
my %subscription = (
101
    locale      => scalar $input->param('locale') // '',
108
    locale      => scalar $input->param('locale') // '',
102
    lastvalue1      => scalar $input->param('lastvalue1') // '',
109
    lastvalue1      => scalar $input->param('lastvalue1') // '',
Lines 108-113 my %subscription = ( Link Here
108
    irregularity    => '',
115
    irregularity    => '',
109
    countissuesperunit  => 1,
116
    countissuesperunit  => 1,
110
    firstacquidate  => $firstacquidate,
117
    firstacquidate  => $firstacquidate,
118
    translations    => $translations,
111
);
119
);
112
120
113
my $issuenumber;
121
my $issuenumber;
Lines 178-183 while( $i < 1000 ) { Link Here
178
186
179
$template->param(
187
$template->param(
180
    predictions_loop => \@predictions_loop,
188
    predictions_loop => \@predictions_loop,
189
    error_messages   => \@{ $translations->{error_messages} },
181
);
190
);
182
191
183
if ( $frequency->{unit} and not $custompattern ) {
192
if ( $frequency->{unit} and not $custompattern ) {
(-)a/serials/subscription-add.pl (+1 lines)
Lines 225-230 if ($op eq 'addsubscription') { Link Here
225
    my $languages = [ map {
225
    my $languages = [ map {
226
        {
226
        {
227
            language => $_->{iso639_2_code},
227
            language => $_->{iso639_2_code},
228
            subtag      => $_->{subtag},
228
            description => $_->{language_description} || $_->{language}
229
            description => $_->{language_description} || $_->{language}
229
        }
230
        }
230
    } @{ C4::Languages::getAllLanguages() } ];
231
    } @{ C4::Languages::getAllLanguages() } ];
(-)a/serials/subscription-numberpatterns.pl (+1 lines)
Lines 113-118 if($op && ($op eq 'new' || $op eq 'modify')) { Link Here
113
    my $languages = [ map {
113
    my $languages = [ map {
114
        {
114
        {
115
            language => $_->{iso639_2_code},
115
            language => $_->{iso639_2_code},
116
            subtag      => $_->{subtag},
116
            description => $_->{language_description} || $_->{language}
117
            description => $_->{language_description} || $_->{language}
117
        }
118
        }
118
    } @{ C4::Languages::getAllLanguages() } ];
119
    } @{ C4::Languages::getAllLanguages() } ];
(-)a/t/db_dependent/Serials.t (-4 / +77 lines)
Lines 5-25 Link Here
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
7
8
use C4::Serials 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 );
8
use C4::Serials 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 );
9
use C4::Serials::Frequency;
9
use C4::Serials::Frequency;
10
use C4::Serials::Numberpattern;
10
use C4::Serials::Numberpattern;
11
use C4::Biblio qw( AddBiblio GetMarcFromKohaField );
11
use C4::Biblio qw( AddBiblio GetMarcFromKohaField );
12
use C4::Budgets qw( AddBudgetPeriod AddBudget );
12
use C4::Budgets qw( AddBudgetPeriod AddBudget );
13
use C4::Context;
13
use C4::Items qw( AddItemFromMarc );
14
use C4::Items qw( AddItemFromMarc );
15
use Encode qw( encode );
16
use File::Temp;
14
use Koha::Database;
17
use Koha::Database;
15
use Koha::DateUtils qw( dt_from_string output_pref );
18
use Koha::DateUtils qw( dt_from_string output_pref );
16
use Koha::Acquisition::Booksellers;
19
use Koha::Acquisition::Booksellers;
17
use t::lib::Mocks;
20
use t::lib::Mocks;
18
use t::lib::TestBuilder;
21
use t::lib::TestBuilder;
19
use Test::More tests => 54;
22
use Test::More tests => 55;
20
23
21
BEGIN {
24
BEGIN {
22
    use_ok('C4::Serials', 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 ));
25
    use_ok('C4::Serials', 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 ));
23
}
26
}
24
27
25
my $schema = Koha::Database->new->schema;
28
my $schema = Koha::Database->new->schema;
Lines 549-555 subtest "NewSubscription|ModSubscription" => sub { Link Here
549
552
550
subtest "_numeration" => sub {
553
subtest "_numeration" => sub {
551
554
552
    plan tests => 6;
555
    plan tests => 8;
553
556
554
    my $s = C4::Serials::_numeration(0, 'monthname', 'cat');
557
    my $s = C4::Serials::_numeration(0, 'monthname', 'cat');
555
    is( $s, "gener" );
558
    is( $s, "gener" );
Lines 564-567 subtest "_numeration" => sub { Link Here
564
    like( $s, qr{^ene\.?} );
567
    like( $s, qr{^ene\.?} );
565
    $s = C4::Serials::_numeration(0, 'monthabrv', 'fr');
568
    $s = C4::Serials::_numeration(0, 'monthabrv', 'fr');
566
    is( $s, "janv." );
569
    is( $s, "janv." );
570
571
    my $translations = {
572
        seasons     => [ 'Spring', 'Summer', 'Fall', 'Winter' ],
573
        seasonsabrv => [ 'Spr', 'Sum', 'Fal', 'Win' ],
574
    };
575
576
    $s = C4::Serials::_numeration( 0, 'season', 'en', $translations );
577
    is( $s, "Spring" );
578
    $s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations );
579
    is( $s, "Spr" );
580
};
581
582
subtest "GetSeasonsTranslations" => sub {
583
584
    plan tests => 8;
585
586
    my @seasons     = qw( Printemps Été Automne Hiver );
587
    my @seasonsabrv = qw( Pri Été Aut Hiv );
588
589
    my $dir      = C4::Context->config('intranetdir') . '/misc/translator/po/';
590
    my $fh       = File::Temp->new( DIR => $dir, SUFFIX => '-staff-prog.po' );
591
    my $filename = $fh->filename;
592
593
    my $txt = '
594
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
595
#, c-format
596
msgid "Spring"
597
msgstr "Printemps"
598
599
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
600
#, c-format
601
msgid "Summer"
602
msgstr "Été"
603
604
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
605
#, c-format
606
msgid "Fall"
607
msgstr "Automne"
608
609
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
610
#, c-format
611
msgid "Winter"
612
msgstr "Hiver"
613
614
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:208
615
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:210
616
#, c-format
617
msgid "Sum"
618
msgstr "Total"
619
620
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:248
621
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt:43
622
#, c-format
623
msgid ""
624
"%s %sSpring%s %s %sSummer%s %s %sFall%s %s %sWinter%s %s %sSpr%s %s %sSum%s "
625
"%s %sFal%s %s %sWin%s %s %s %s "
626
msgstr ""
627
"%s %sPrintemps%s %s %sÉté%s %s %sAutomne%s %s %sHiver%s %s %sPri%s %s %sÉté"
628
"%s %s %sAut%s %s %sHiv%s %s %s %s "
629
    ';
630
631
    print $fh encode( 'utf-8', $txt );
632
    close($fh);
633
634
    my $translations = GetSeasonsTranslations( 1, 1, $filename =~ s/($dir|-staff-prog.po)//gr );
635
636
    for my $idx ( 0 .. $#{ $translations->{seasons} } ) {
637
        is( $translations->{seasons}->[$idx],     $seasons[$idx] );
638
        is( $translations->{seasonsabrv}->[$idx], $seasonsabrv[$idx] );
639
    }
567
};
640
};
(-)a/t/db_dependent/Serials/GetNextSeq.t (-1 / +1 lines)
Lines 143-148 $subscription = { Link Here
143
    irregularity => '3;4;6',
143
    irregularity => '3;4;6',
144
    countissuesperunit => 1,
144
    countissuesperunit => 1,
145
    locale => 'C',
145
    locale => 'C',
146
    translations => { seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ] },
146
};
147
};
147
$pattern = {
148
$pattern = {
148
             add1 =>  1,          add2 =>  0,          add3 =>  0,
149
             add1 =>  1,          add2 =>  0,          add3 =>  0,
149
- 

Return to bug 35590