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

(-)a/C4/Serials.pm (-43 / +143 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 76-110 BEGIN { Link Here
76
    require Exporter;
78
    require Exporter;
77
    @ISA    = qw(Exporter);
79
    @ISA    = qw(Exporter);
78
    @EXPORT_OK = qw(
80
    @EXPORT_OK = qw(
79
      NewSubscription    ModSubscription    DelSubscription
81
        NewSubscription    ModSubscription    DelSubscription
80
      GetSubscription    CountSubscriptionFromBiblionumber      GetSubscriptionsFromBiblionumber
82
        GetSubscription    CountSubscriptionFromBiblionumber      GetSubscriptionsFromBiblionumber
81
      SearchSubscriptions
83
        SearchSubscriptions
82
      GetFullSubscriptionsFromBiblionumber   GetFullSubscription ModSubscriptionHistory
84
        GetFullSubscriptionsFromBiblionumber   GetFullSubscription ModSubscriptionHistory
83
      HasSubscriptionStrictlyExpired HasSubscriptionExpired GetExpirationDate abouttoexpire
85
        HasSubscriptionStrictlyExpired HasSubscriptionExpired GetExpirationDate abouttoexpire
84
      GetFictiveIssueNumber
86
        GetFictiveIssueNumber
85
      GetSubscriptionHistoryFromSubscriptionId
87
        GetSubscriptionHistoryFromSubscriptionId
86
88
87
      GetNextSeq GetSeq NewIssue           GetSerials
89
        GetNextSeq GetSeq NewIssue           GetSerials
88
      GetLatestSerials   ModSerialStatus    GetNextDate
90
        GetLatestSerials   ModSerialStatus    GetNextDate
89
      CloseSubscription ReopenSubscription
91
        CloseSubscription ReopenSubscription
90
      subscriptionCurrentlyOnOrder
92
        subscriptionCurrentlyOnOrder
91
      can_claim_subscription can_edit_subscription can_show_subscription
93
        can_claim_subscription can_edit_subscription can_show_subscription
92
      GetSerials2
94
        GetSerials2
93
      GetSubscriptionLength ReNewSubscription  GetLateOrMissingIssues
95
        GetSubscriptionLength ReNewSubscription  GetLateOrMissingIssues
94
      GetSerialInformation                   AddItem2Serial
96
        GetSerialInformation                   AddItem2Serial
95
      PrepareSerialsData GetNextExpected    ModNextExpected
97
        PrepareSerialsData GetNextExpected    ModNextExpected
96
      GetSubscriptionIrregularities
98
        GetSubscriptionIrregularities
97
      GetPreviousSerialid
99
        GetPreviousSerialid
98
100
99
      GetSuppliersWithLateIssues
101
        GetSuppliersWithLateIssues
100
      getroutinglist     delroutingmember   addroutingmember
102
        getroutinglist     delroutingmember   addroutingmember
101
      reorder_members
103
        reorder_members
102
      check_routing updateClaim
104
        check_routing updateClaim
103
      CountIssues
105
        CountIssues
104
      HasItems
106
        HasItems
105
107
106
      findSerialsByStatus
108
        findSerialsByStatus
107
109
110
        GetSeasonsTranslations
108
    );
111
    );
109
}
112
}
110
113
Lines 851-857 sub GetNextSeq { Link Here
851
    my $numberingmethod = $pattern->{numberingmethod};
854
    my $numberingmethod = $pattern->{numberingmethod};
852
    my $calculated = "";
855
    my $calculated = "";
853
    if ($numberingmethod) {
856
    if ($numberingmethod) {
854
        $calculated    = $numberingmethod;
857
        $calculated = $numberingmethod;
855
        my $locale = $subscription->{locale};
858
        my $locale = $subscription->{locale};
856
        $newlastvalue1 = $subscription->{lastvalue1} || 0;
859
        $newlastvalue1 = $subscription->{lastvalue1} || 0;
857
        $newlastvalue2 = $subscription->{lastvalue2} || 0;
860
        $newlastvalue2 = $subscription->{lastvalue2} || 0;
Lines 859-865 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};
866
862
        my %calc;
867
        my %calc;
868
863
        foreach(qw/X Y Z/) {
869
        foreach(qw/X Y Z/) {
864
            $calc{$_} = 1 if ($numberingmethod =~ /\{$_\}/);
870
            $calc{$_} = 1 if ($numberingmethod =~ /\{$_\}/);
865
        }
871
        }
Lines 897-911 sub GetNextSeq { Link Here
897
            }
903
            }
898
        }
904
        }
899
        if($calc{'X'}) {
905
        if($calc{'X'}) {
900
            my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale );
906
            my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale, $translations );
901
            $calculated =~ s/\{X\}/$newlastvalue1string/g;
907
            $calculated =~ s/\{X\}/$newlastvalue1string/g;
902
        }
908
        }
903
        if($calc{'Y'}) {
909
        if($calc{'Y'}) {
904
            my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale );
910
            my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale, $translations );
905
            $calculated =~ s/\{Y\}/$newlastvalue2string/g;
911
            $calculated =~ s/\{Y\}/$newlastvalue2string/g;
906
        }
912
        }
907
        if($calc{'Z'}) {
913
        if($calc{'Z'}) {
908
            my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale );
914
            my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale, $translations );
909
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
915
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
910
        }
916
        }
911
917
Lines 934-951 sub GetSeq { Link Here
934
940
935
    my $locale = $subscription->{locale};
941
    my $locale = $subscription->{locale};
936
942
943
    my $translations = $subscription->{translations};
944
937
    my $calculated = $pattern->{numberingmethod};
945
    my $calculated = $pattern->{numberingmethod};
938
946
939
    my $newlastvalue1 = $subscription->{'lastvalue1'} || 0;
947
    my $newlastvalue1 = $subscription->{'lastvalue1'} || 0;
940
    $newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale) if ($pattern->{numbering1}); # reset counter if needed.
948
949
    $newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale, $translations) if ($pattern->{numbering1}); # reset counter if needed.
941
    $calculated =~ s/\{X\}/$newlastvalue1/g;
950
    $calculated =~ s/\{X\}/$newlastvalue1/g;
942
951
943
    my $newlastvalue2 = $subscription->{'lastvalue2'} || 0;
952
    my $newlastvalue2 = $subscription->{'lastvalue2'} || 0;
944
    $newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale) if ($pattern->{numbering2}); # reset counter if needed.
953
    $newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale, $translations) if ($pattern->{numbering2}); # reset counter if needed.
945
    $calculated =~ s/\{Y\}/$newlastvalue2/g;
954
    $calculated =~ s/\{Y\}/$newlastvalue2/g;
946
955
947
    my $newlastvalue3 = $subscription->{'lastvalue3'} || 0;
956
    my $newlastvalue3 = $subscription->{'lastvalue3'} || 0;
948
    $newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale) if ($pattern->{numbering3}); # reset counter if needed.
957
    $newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale, $translations) if ($pattern->{numbering3}); # reset counter if needed.
949
    $calculated =~ s/\{Z\}/$newlastvalue3/g;
958
    $calculated =~ s/\{Z\}/$newlastvalue3/g;
950
    return $calculated;
959
    return $calculated;
951
}
960
}
Lines 2501-2507 num_type can take : Link Here
2501
=cut
2510
=cut
2502
2511
2503
sub _numeration {
2512
sub _numeration {
2504
    my ($value, $num_type, $locale) = @_;
2513
    my ( $value, $num_type, $locale, $translations ) = @_;
2505
    $value ||= 0;
2514
    $value ||= 0;
2506
    $num_type //= '';
2515
    $num_type //= '';
2507
    $locale ||= 'en';
2516
    $locale ||= 'en';
Lines 2529-2541 sub _numeration { Link Here
2529
            ? $dt->format_cldr( "LLLL" )
2538
            ? $dt->format_cldr( "LLLL" )
2530
            : $dt->strftime("%b");
2539
            : $dt->strftime("%b");
2531
    } elsif ( $num_type =~ /^season$/ ) {
2540
    } elsif ( $num_type =~ /^season$/ ) {
2532
        my @seasons= qw( Spring Summer Fall Winter );
2541
        $value  = $value % 4;
2533
        $value = $value % 4;
2542
        $string = $translations->{seasons}->[$value];
2534
        $string = $seasons[$value];
2535
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2543
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2536
        my @seasonsabrv= qw( Spr Sum Fal Win );
2544
        $value  = $value % 4;
2537
        $value = $value % 4;
2545
        $string = $translations->{seasonsabrv}->[$value];
2538
        $string = $seasonsabrv[$value];
2539
    } else {
2546
    } else {
2540
        $string = $value;
2547
        $string = $value;
2541
    }
2548
    }
Lines 2597-2602 sub ReopenSubscription { Link Here
2597
    $sth->execute( EXPECTED, $subscriptionid, STOPPED );
2604
    $sth->execute( EXPECTED, $subscriptionid, STOPPED );
2598
}
2605
}
2599
2606
2607
=head2 GetSeasonsTranslations
2608
2609
Provide translations for the seasons and their abbreviations for the specified locale
2610
2611
=cut
2612
2613
sub GetSeasonsTranslations {
2614
    my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_;
2615
    my @seasons        = qw( Spring Summer Fall Winter );
2616
    my @seasonsabrv    = qw( Spr Sum Fal Win );
2617
    my @error_messages = qw();
2618
2619
    my @dirs = (
2620
        C4::Context->config('intranetdir') . '/misc/translator/po',
2621
        C4::Context->config('intranetdir') . '/../../misc/translator/po',
2622
    );
2623
2624
    my $dir = first { -d } @dirs;
2625
2626
    if ($dir) {
2627
        my @po_paths = glob("$dir/$subtag*staff-prog.po");
2628
        if (@po_paths) {
2629
            my $po_path     = $po_paths[0];
2630
            my $po_filename = ( $po_path =~ s/$dir\///gr );
2631
            my $po_data     = Locale::PO->load_file_ashash( $po_path, 'utf8' );
2632
2633
            if ($need_seasons) {
2634
                my $response = _translate( $po_data, @seasons );
2635
                @seasons = @{ $response->{translations} };
2636
                @error_messages =
2637
                    ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } );
2638
            }
2639
2640
            if ($need_seasonsabrv) {
2641
                my $response = _translate( $po_data, @seasonsabrv );
2642
                @seasonsabrv = @{ $response->{translations} };
2643
                @error_messages =
2644
                    ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } );
2645
            }
2646
        } else {
2647
            push(
2648
                @error_messages,
2649
                "No translation file found for $subtag. Ensure that the translation files for $subtag are installed."
2650
            );
2651
        }
2652
    } else {
2653
        push( @error_messages, "The PO directory has not been found. There is a problem in your Koha installation." );
2654
    }
2655
2656
    return { seasons => \@seasons, seasonsabrv => \@seasonsabrv, error_messages => \@error_messages };
2657
}
2658
2600
=head2 subscriptionCurrentlyOnOrder
2659
=head2 subscriptionCurrentlyOnOrder
2601
2660
2602
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
2661
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
Lines 2691-2696 sub _can_do_on_subscription { Link Here
2691
    return 0;
2750
    return 0;
2692
}
2751
}
2693
2752
2753
=head2 _translate
2754
2755
Provide translations for the given words based on the provided data
2756
2757
=cut
2758
2759
sub _translate {
2760
    my ( $data, @words ) = @_;
2761
2762
    my @translations   = qw();
2763
    my @error_messages = qw();
2764
2765
    for my $word (@words) {
2766
        my $regex       = qr/^"$word"$|\%s$word\%s/;
2767
        my @msgids      = grep /$regex/, keys %{$data};
2768
        my $translation = "";
2769
2770
        while ( ( $translation eq "" ) && ( my $msgid = shift(@msgids) ) ) {
2771
            next unless ( $data->{$msgid}->reference =~ /serials/ );
2772
            my $msgstr = $data->{$msgid}->msgstr;
2773
            my @ids    = split( /\%s/, $msgid );
2774
            my @strs   = split( /\%s/, $msgstr );
2775
2776
            next unless ( scalar @ids == scalar @strs );
2777
2778
            my $idx = first { $ids[$_] eq $word || $ids[$_] eq $msgid } 0 .. $#ids;
2779
            $translation = Locale::PO->dequote( $strs[$idx] ) if ( defined $idx );
2780
        }
2781
2782
        if ( $translation eq "" ) {
2783
            push( @translations,   $word );
2784
            push( @error_messages, "The translation for $word doesn't exist in the file \%s" );
2785
            next;
2786
        }
2787
2788
        push( @translations, $translation );
2789
    }
2790
2791
    return { translations => \@translations, error_messages => \@error_messages };
2792
}
2793
2694
=head2 findSerialsByStatus
2794
=head2 findSerialsByStatus
2695
2795
2696
    @serials = findSerialsByStatus($status, $subscriptionid);
2796
    @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 (-11 / +20 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-113 $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') // '',
103
    lastvalue2      => scalar $input->param('lastvalue2') // '',
110
    lastvalue2 => scalar $input->param('lastvalue2') // '',
104
    lastvalue3      => scalar $input->param('lastvalue3') // '',
111
    lastvalue3 => scalar $input->param('lastvalue3') // '',
105
    innerloop1      => scalar $input->param('innerloop1') // '',
112
    innerloop1 => scalar $input->param('innerloop1') // '',
106
    innerloop2      => scalar $input->param('innerloop2') // '',
113
    innerloop2 => scalar $input->param('innerloop2') // '',
107
    innerloop3      => scalar $input->param('innerloop3') // '',
114
    innerloop3 => scalar $input->param('innerloop3') // '',
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 (-6 / +9 lines)
Lines 222-233 if ($op eq 'addsubscription') { Link Here
222
    }
222
    }
223
    $template->param(numberpatterns => \@numberpatternloop);
223
    $template->param(numberpatterns => \@numberpatternloop);
224
224
225
    my $languages = [ map {
225
    my $languages = [
226
        {
226
        map {
227
            language => $_->{iso639_2_code},
227
            {
228
            description => $_->{language_description} || $_->{language}
228
                language    => $_->{iso639_2_code},
229
        }
229
                subtag      => $_->{subtag},
230
    } @{ C4::Languages::getAllLanguages() } ];
230
                description => $_->{language_description} || $_->{language}
231
            }
232
        } @{ C4::Languages::getAllLanguages() }
233
    ];
231
234
232
    $template->param( locales => $languages );
235
    $template->param( locales => $languages );
233
236
(-)a/serials/subscription-numberpatterns.pl (-6 / +9 lines)
Lines 110-121 if($op && ($op eq 'new' || $op eq 'modify')) { Link Here
110
        }
110
        }
111
    }
111
    }
112
    my @frequencies = GetSubscriptionFrequencies();
112
    my @frequencies = GetSubscriptionFrequencies();
113
    my $languages = [ map {
113
    my $languages   = [
114
        {
114
        map {
115
            language => $_->{iso639_2_code},
115
            {
116
            description => $_->{language_description} || $_->{language}
116
                language    => $_->{iso639_2_code},
117
        }
117
                subtag      => $_->{subtag},
118
    } @{ C4::Languages::getAllLanguages() } ];
118
                description => $_->{language_description} || $_->{language}
119
            }
120
        } @{ C4::Languages::getAllLanguages() }
121
    ];
119
122
120
    $template->param(
123
    $template->param(
121
        $op => 1,
124
        $op => 1,
(-)a/t/db_dependent/Serials.t (-5 / +81 lines)
Lines 4-25 Link Here
4
# Add more tests here!!!
4
# Add more tests here!!!
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
7
use C4::Serials
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
    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(
26
        '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 GetSeasonsTranslations )
28
    );
23
}
29
}
24
30
25
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
Lines 549-555 subtest "NewSubscription|ModSubscription" => sub { Link Here
549
555
550
subtest "_numeration" => sub {
556
subtest "_numeration" => sub {
551
557
552
    plan tests => 6;
558
    plan tests => 8;
553
559
554
    my $s = C4::Serials::_numeration(0, 'monthname', 'cat');
560
    my $s = C4::Serials::_numeration(0, 'monthname', 'cat');
555
    is( $s, "gener" );
561
    is( $s, "gener" );
Lines 564-567 subtest "_numeration" => sub { Link Here
564
    like( $s, qr{^ene\.?} );
570
    like( $s, qr{^ene\.?} );
565
    $s = C4::Serials::_numeration(0, 'monthabrv', 'fr');
571
    $s = C4::Serials::_numeration(0, 'monthabrv', 'fr');
566
    is( $s, "janv." );
572
    is( $s, "janv." );
573
574
    my $translations = {
575
        seasons     => [ 'Spring', 'Summer', 'Fall', 'Winter' ],
576
        seasonsabrv => [ 'Spr',    'Sum',    'Fal',  'Win' ],
577
    };
578
579
    $s = C4::Serials::_numeration( 0, 'season', 'en', $translations );
580
    is( $s, "Spring" );
581
    $s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations );
582
    is( $s, "Spr" );
583
};
584
585
subtest "GetSeasonsTranslations" => sub {
586
587
    plan tests => 8;
588
589
    my @seasons     = qw( Printemps Été Automne Hiver );
590
    my @seasonsabrv = qw( Pri Été Aut Hiv );
591
592
    my $dir      = C4::Context->config('intranetdir') . '/misc/translator/po/';
593
    my $fh       = File::Temp->new( DIR => $dir, SUFFIX => '-staff-prog.po' );
594
    my $filename = $fh->filename;
595
596
    my $txt = '
597
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
598
#, c-format
599
msgid "Spring"
600
msgstr "Printemps"
601
602
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
603
#, c-format
604
msgid "Summer"
605
msgstr "Été"
606
607
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
608
#, c-format
609
msgid "Fall"
610
msgstr "Automne"
611
612
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
613
#, c-format
614
msgid "Winter"
615
msgstr "Hiver"
616
617
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:208
618
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:210
619
#, c-format
620
msgid "Sum"
621
msgstr "Total"
622
623
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:248
624
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt:43
625
#, c-format
626
msgid ""
627
"%s %sSpring%s %s %sSummer%s %s %sFall%s %s %sWinter%s %s %sSpr%s %s %sSum%s "
628
"%s %sFal%s %s %sWin%s %s %s %s "
629
msgstr ""
630
"%s %sPrintemps%s %s %sÉté%s %s %sAutomne%s %s %sHiver%s %s %sPri%s %s %sÉté"
631
"%s %s %sAut%s %s %sHiv%s %s %s %s "
632
    ';
633
634
    print $fh encode( 'utf-8', $txt );
635
    close($fh);
636
637
    my $translations = GetSeasonsTranslations( 1, 1, $filename =~ s/($dir|-staff-prog.po)//gr );
638
639
    for my $idx ( 0 .. $#{ $translations->{seasons} } ) {
640
        is( $translations->{seasons}->[$idx],     $seasons[$idx] );
641
        is( $translations->{seasonsabrv}->[$idx], $seasonsabrv[$idx] );
642
    }
567
};
643
};
(-)a/t/db_dependent/Serials/GetNextSeq.t (-8 / +8 lines)
Lines 135-148 is($seq, 'X: May'); Link Here
135
135
136
# TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3
136
# TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3
137
$subscription = {
137
$subscription = {
138
    periodicity => $id,
138
    periodicity        => $id,
139
    firstacquidate => '1970-01-01',
139
    firstacquidate     => '1970-01-01',
140
    lastvalue1 => 0, lastvalue2 => 1, lastvalue3 => 1,
140
    lastvalue1         => 0, lastvalue2 => 1, lastvalue3 => 1,
141
    innerloop1 => 0, innerloop2 => 0, innerloop3 => 0,
141
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
142
    skip_serialseq => 1,
142
    skip_serialseq     => 1,
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