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

(-)a/C4/Serials.pm (-44 / +138 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 319-340 sub GetFullSubscription { Link Here
319
    my $query = qq|
322
    my $query = qq|
320
  SELECT    serial.serialid,
323
  SELECT    serial.serialid,
321
            serial.serialseq,
324
            serial.serialseq,
322
            serial.planneddate, 
325
            serial.planneddate,
323
            serial.publisheddate, 
326
            serial.publisheddate,
324
            serial.publisheddatetext,
327
            serial.publisheddatetext,
325
            serial.status, 
328
            serial.status,
326
            serial.notes as notes,
329
            serial.notes as notes,
327
            year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year,
330
            year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year,
328
            aqbooksellers.name as aqbooksellername,
331
            aqbooksellers.name as aqbooksellername,
329
            biblio.title as bibliotitle,
332
            biblio.title as bibliotitle,
330
            subscription.branchcode AS branchcode,
333
            subscription.branchcode AS branchcode,
331
            subscription.subscriptionid AS subscriptionid
334
            subscription.subscriptionid AS subscriptionid
332
  FROM      serial 
335
  FROM      serial
333
  LEFT JOIN subscription ON 
336
  LEFT JOIN subscription ON
334
          (serial.subscriptionid=subscription.subscriptionid )
337
          (serial.subscriptionid=subscription.subscriptionid )
335
  LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id 
338
  LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id
336
  LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber 
339
  LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber
337
  WHERE     serial.subscriptionid = ? 
340
  WHERE     serial.subscriptionid = ?
338
  ORDER BY year DESC,
341
  ORDER BY year DESC,
339
          IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC,
342
          IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC,
340
          serial.subscriptionid
343
          serial.subscriptionid
Lines 460-481 sub GetFullSubscriptionsFromBiblionumber { Link Here
460
    my $query          = qq|
463
    my $query          = qq|
461
  SELECT    serial.serialid,
464
  SELECT    serial.serialid,
462
            serial.serialseq,
465
            serial.serialseq,
463
            serial.planneddate, 
466
            serial.planneddate,
464
            serial.publisheddate, 
467
            serial.publisheddate,
465
            serial.publisheddatetext,
468
            serial.publisheddatetext,
466
            serial.status, 
469
            serial.status,
467
            serial.notes as notes,
470
            serial.notes as notes,
468
            year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year,
471
            year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year,
469
            biblio.title as bibliotitle,
472
            biblio.title as bibliotitle,
470
            subscription.branchcode AS branchcode,
473
            subscription.branchcode AS branchcode,
471
            subscription.subscriptionid AS subscriptionid,
474
            subscription.subscriptionid AS subscriptionid,
472
            subscription.location AS location
475
            subscription.location AS location
473
  FROM      serial 
476
  FROM      serial
474
  LEFT JOIN subscription ON 
477
  LEFT JOIN subscription ON
475
          (serial.subscriptionid=subscription.subscriptionid)
478
          (serial.subscriptionid=subscription.subscriptionid)
476
  LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id 
479
  LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id
477
  LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber 
480
  LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber
478
  WHERE     subscription.biblionumber = ? 
481
  WHERE     subscription.biblionumber = ?
479
  ORDER BY year DESC,
482
  ORDER BY year DESC,
480
          IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC,
483
          IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC,
481
          serial.subscriptionid
484
          serial.subscriptionid
Lines 726-732 sub GetSerials2 { Link Here
726
    my $query = q|
729
    my $query = q|
727
                 SELECT serialid,serialseq, status, planneddate, publisheddate,
730
                 SELECT serialid,serialseq, status, planneddate, publisheddate,
728
                    publisheddatetext, notes, routingnotes
731
                    publisheddatetext, notes, routingnotes
729
                 FROM     serial 
732
                 FROM     serial
730
                 WHERE    subscriptionid=?
733
                 WHERE    subscriptionid=?
731
            |
734
            |
732
        . q| AND status IN (| . join( ",", ('?') x @$statuses ) . q|)| . q|
735
        . q| AND status IN (| . join( ",", ('?') x @$statuses ) . q|)| . q|
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 905-920 sub GetNextSeq { Link Here
905
                $newlastvalue3 = $pattern->{setto3} if ( $newlastvalue3 > $pattern->{whenmorethan3} );
909
                $newlastvalue3 = $pattern->{setto3} if ( $newlastvalue3 > $pattern->{whenmorethan3} );
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 1072-1078 sub ModSubscriptionHistory { Link Here
1072
    return unless ($subscriptionid);
1075
    return unless ($subscriptionid);
1073
1076
1074
    my $dbh   = C4::Context->dbh;
1077
    my $dbh   = C4::Context->dbh;
1075
    my $query = "UPDATE subscriptionhistory 
1078
    my $query = "UPDATE subscriptionhistory
1076
                    SET histstartdate=?,histenddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=?
1079
                    SET histstartdate=?,histenddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=?
1077
                    WHERE subscriptionid=?
1080
                    WHERE subscriptionid=?
1078
                ";
1081
                ";
Lines 1279-1285 sub GetNextExpected { Link Here
1279
ModNextExpected($subscriptionid,$date)
1282
ModNextExpected($subscriptionid,$date)
1280
1283
1281
Update the planneddate for the current expected issue of the subscription.
1284
Update the planneddate for the current expected issue of the subscription.
1282
This will modify all future prediction results.  
1285
This will modify all future prediction results.
1283
1286
1284
C<$date> is an ISO date.
1287
C<$date> is an ISO date.
1285
1288
Lines 1582-1588 sub ReNewSubscription { Link Here
1582
    my $subscription = GetSubscription($subscriptionid);
1585
    my $subscription = GetSubscription($subscriptionid);
1583
    my $query        = qq|
1586
    my $query        = qq|
1584
         SELECT *
1587
         SELECT *
1585
         FROM   biblio 
1588
         FROM   biblio
1586
         LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber
1589
         LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber
1587
         WHERE    biblio.biblionumber=?
1590
         WHERE    biblio.biblionumber=?
1588
     |;
1591
     |;
Lines 1719-1725 sub NewIssue { Link Here
1719
1722
1720
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid)
1723
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid)
1721
1724
1722
the subscription has stricly expired when today > the end subscription date 
1725
the subscription has stricly expired when today > the end subscription date
1723
1726
1724
return :
1727
return :
1725
1 if true, 0 if false, -1 if the expiration date is not set.
1728
1 if true, 0 if false, -1 if the expiration date is not set.
Lines 1907-1913 sub DelIssue { Link Here
1907
this function selects missing issues on database - where serial.status = MISSING* or serial.status = LATE or planneddate<now
1910
this function selects missing issues on database - where serial.status = MISSING* or serial.status = LATE or planneddate<now
1908
1911
1909
return :
1912
return :
1910
the issuelist as an array of hash refs. Each element of this array contains 
1913
the issuelist as an array of hash refs. Each element of this array contains
1911
name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio
1914
name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio
1912
1915
1913
=cut
1916
=cut
Lines 2040-2046 sub check_routing { Link Here
2040
2043
2041
    my $dbh = C4::Context->dbh;
2044
    my $dbh = C4::Context->dbh;
2042
    my $sth = $dbh->prepare(
2045
    my $sth = $dbh->prepare(
2043
        "SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist 
2046
        "SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist
2044
                              ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
2047
                              ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
2045
                              WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC
2048
                              WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC
2046
                              "
2049
                              "
Lines 2172-2178 sub getroutinglist { Link Here
2172
    my $dbh              = C4::Context->dbh;
2175
    my $dbh              = C4::Context->dbh;
2173
    my $sth              = $dbh->prepare(
2176
    my $sth              = $dbh->prepare(
2174
        'SELECT routingid, borrowernumber, ranking, biblionumber
2177
        'SELECT routingid, borrowernumber, ranking, biblionumber
2175
            FROM subscription 
2178
            FROM subscription
2176
            JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
2179
            JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
2177
            WHERE subscription.subscriptionid = ? ORDER BY ranking ASC'
2180
            WHERE subscription.subscriptionid = ? ORDER BY ranking ASC'
2178
    );
2181
    );
Lines 2240-2246 sub HasItems { Link Here
2240
    my $dbh              = C4::Context->dbh;
2243
    my $dbh              = C4::Context->dbh;
2241
    my $query            = q|
2244
    my $query            = q|
2242
            SELECT COUNT(serialitems.itemnumber)
2245
            SELECT COUNT(serialitems.itemnumber)
2243
            FROM   serial 
2246
            FROM   serial
2244
			LEFT JOIN serialitems USING(serialid)
2247
			LEFT JOIN serialitems USING(serialid)
2245
            WHERE  subscriptionid=? AND serialitems.serialid IS NOT NULL
2248
            WHERE  subscriptionid=? AND serialitems.serialid IS NOT NULL
2246
        |;
2249
        |;
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 );
2643
        $value = $value % 4;
2641
        $value  = $value % 4;
2644
        $string = $translations->{seasons}->[$value];
2642
        $string = $seasons[$value];
2643
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2645
    } elsif ( $num_type =~ /^seasonabrv$/ ) {
2644
        my @seasonsabrv = qw( Spr Sum Fal Win );
2646
        $value = $value % 4;
2645
        $value  = $value % 4;
2647
        $string = $translations->{seasonsabrv}->[$value];
2646
        $string = $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 (-12 / +22 lines)
Lines 68-87 Link Here
68
                    [% IF (ask_for_irregularities) %]
68
                    [% IF (ask_for_irregularities) %]
69
                        <td style="text-align:center">
69
                        <td style="text-align:center">
70
                            [% UNLESS (loop.first) %]
70
                            [% UNLESS (loop.first) %]
71
                                [% IF (prediction.not_published) %]
71
                            [% IF (prediction.not_published) %]
72
                                    <input type="checkbox" name="irregularity" value="[% prediction.issuenumber | html %]" data-dow="[% prediction.dow | html %]" checked="checked" />
72
                                <input type="checkbox" name="irregularity" value="[% prediction.issuenumber | html %]" data-dow="[% prediction.dow | html %]" checked="checked" />
73
                                [% ELSE %]
73
                            [% ELSE %]
74
                                    <input type="checkbox" name="irregularity" value="[% prediction.issuenumber | html %]" data-dow="[% prediction.dow | html %]" />
74
                                <input type="checkbox" name="irregularity" value="[% prediction.issuenumber | html %]" data-dow="[% prediction.dow | html %]" />
75
                                [% END %]
76
                            [% END %]
75
                            [% END %]
77
                        </td>
76
                        </td>
77
                        [% END %]
78
                    [% END %]
78
                    [% END %]
79
                </tr>
79
        </tr>
80
            [% END %]
80
        [% END %]
81
        </tbody>
81
  </tbody>
82
    </table>
82
</table>
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
93
<fieldset class="action">
94
    <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button>
95
</fieldset>
83
96
84
    <fieldset class="action">
85
        <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button>
86
    </fieldset>
87
[% END %]
97
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-120 / +138 lines)
Lines 305-311 Link Here
305
                        >
305
                        >
306
                    </fieldset>
306
                    </fieldset>
307
                [% END %]
307
                [% END %]
308
                <div style="display:none" id="mana_search" class="alert alert-info"> </div>
308
                <div style="display:none" id="mana_search" class="alert alert-info">
309
                </div>
309
                <div id="subscription_form_planning">
310
                <div id="subscription_form_planning">
310
                    <fieldset class="rows">
311
                    <fieldset class="rows">
311
                        <legend>Serials planning</legend>
312
                        <legend>Serials planning</legend>
Lines 316-329 Link Here
316
                                    <input type="text" size="10" id="acqui_date" name="firstacquidate" value="[% firstacquidate | html %]" class="flatpickr required" required="required" />
317
                                    <input type="text" size="10" id="acqui_date" name="firstacquidate" value="[% firstacquidate | html %]" class="flatpickr required" required="required" />
317
                                [% ELSE %]
318
                                [% ELSE %]
318
                                    [% firstacquidate | $KohaDates %]
319
                                    [% firstacquidate | $KohaDates %]
319
                                    <input type="hidden" id="acqui_date" name="firstacquidate" value="[% firstacquidate | $KohaDates dateformat => 'iso' %]" />
320
                                    <input type="hidden" id="acqui_date" name="firstacquidate" value="[% firstacquidate | $KohaDates dateformat => 'iso' %]"/>
320
                                [% END %]
321
                                [% END %]
321
                                <span class="required">Required</span>
322
                                <span class="required">Required</span>
322
                            </li>
323
                            </li>
323
                            [% IF (more_than_one_serial) %]
324
                            [% IF (more_than_one_serial) %]
324
                                <li>
325
                                <li>
325
                                    <label for="nextacquidate">Next issue publication date:</label>
326
                                <label for="nextacquidate">Next issue publication date:</label>
326
                                    <input type="text" size="10" id="nextacquidate" name="nextacquidate" value="[% nextacquidate | html %]" class="flatpickr" />
327
                                <input type="text" size="10" id="nextacquidate" name="nextacquidate" value="[% nextacquidate | html %]" class="flatpickr" />
327
                                </li>
328
                                </li>
328
                            [% END %]
329
                            [% END %]
329
                            <li>
330
                            <li>
Lines 331-337 Link Here
331
                                <select name="frequency" id="frequency" class="required" required="required">
332
                                <select name="frequency" id="frequency" class="required" required="required">
332
                                    <option value="">-- please choose --</option>
333
                                    <option value="">-- please choose --</option>
333
                                    [% FOREACH frequency IN frequencies %]
334
                                    [% FOREACH frequency IN frequencies %]
334
                                        <option value="[% frequency.id | html %]" [% IF frequency.selected %]selected="selected"[% END %]> [% frequency.label | html %] </option>
335
                                        [% IF (frequency.selected) %]
336
                                            <option value="[% frequency.id | html %]" selected="selected">
337
                                        [% ELSE %]
338
                                            <option value="[% frequency.id | html %]">
339
                                        [% END %]
340
                                            [% frequency.label | html %]
341
                                        </option>
335
                                    [% END %]
342
                                    [% END %]
336
                                </select>
343
                                </select>
337
                            </li>
344
                            </li>
Lines 340-370 Link Here
340
                                <select name="subtype" id="subtype">
347
                                <select name="subtype" id="subtype">
341
                                    [% FOREACH st IN subtypes %]
348
                                    [% FOREACH st IN subtypes %]
342
                                        [% SWITCH st %]
349
                                        [% SWITCH st %]
343
                                        [% CASE 'numberlength' %]
350
                                            [% CASE 'numberlength' %]
344
                                            [% IF st == subtype %]
351
                                                [% IF st == subtype %]
345
                                                <option value="issues" selected="selected">issues</option>
352
                                                    <option value="issues" selected="selected">
346
                                            [% ELSE %]
353
                                                [% ELSE %]
347
                                                <option value="issues">issues</option>
354
                                                    <option value="issues">
348
                                            [% END %]
355
                                                [% END %]
349
                                        [% CASE 'weeklength' %]
356
                                                issues
350
                                            [% IF st == subtype %]
357
                                            [% CASE 'weeklength' %]
351
                                                <option value="weeks" selected="selected">weeks</option>
358
                                                [% IF st == subtype %]
352
                                            [% ELSE %]
359
                                                    <option value="weeks" selected="selected">
353
                                                <option value="weeks">weeks</option>
360
                                                [% ELSE %]
354
                                            [% END %]
361
                                                    <option value="weeks">
355
                                        [% CASE 'monthlength' %]
362
                                                [% END %]
356
                                            [% IF st == subtype %]
363
                                                weeks
357
                                                <option value="months" selected="selected">months</option>
364
                                            [% CASE 'monthlength' %]
358
                                            [% ELSE %]
365
                                                [% IF st == subtype %]
359
                                                <option value="months">months</option>
366
                                                    <option value="months" selected="selected">
360
                                            [% END %]
367
                                                [% ELSE %]
361
                                        [% CASE %]
368
                                                    <option value="months">
362
                                            [% st | html %]
369
                                                [% END %]
370
                                                months
371
                                            [% CASE %][% st | html %]
363
                                        [% END %]
372
                                        [% END %]
373
                                        </option>
364
                                    [% END %]
374
                                    [% END %]
365
                                </select>
375
                                </select>
366
                                <input type="text" name="sublength" id="sublength" value="[% sublength | html %]" size="3" /> (enter amount in numerals)
376
                                <input type="text" name="sublength" id="sublength" value="[% sublength | html %]" size="3" /> (enter amount in numerals)
367
                                <input type="hidden" name="issuelengthcount" />
377
                                <input type="hidden" name="issuelengthcount">
368
                            </li>
378
                            </li>
369
                            <li>
379
                            <li>
370
                                <label for="from" class="required"> Subscription start date:</label>
380
                                <label for="from" class="required"> Subscription start date:</label>
Lines 379-385 Link Here
379
                                <select name="numbering_pattern" id="numberpattern" class="required" required="required">
389
                                <select name="numbering_pattern" id="numberpattern" class="required" required="required">
380
                                    <option value="">-- please choose --</option>
390
                                    <option value="">-- please choose --</option>
381
                                    [% FOREACH numberpattern IN numberpatterns %]
391
                                    [% FOREACH numberpattern IN numberpatterns %]
382
                                        <option value="[% numberpattern.id | html %]" [% IF numberpattern.selected %]selected="selected"[% END %]> [% numberpattern.label | html %] </option>
392
                                        [% IF (numberpattern.selected) %]
393
                                            <option value="[% numberpattern.id | html %]" selected="selected">
394
                                        [% ELSE %]
395
                                            <option value="[% numberpattern.id | html %]">
396
                                        [% END %]
397
                                            [% numberpattern.label | html %]
398
                                        </option>
383
                                    [% END %]
399
                                    [% END %]
384
                                </select>
400
                                </select>
385
                                <span class="required">Required</span>
401
                                <span class="required">Required</span>
Lines 394-405 Link Here
394
                                    <option value=""></option>
410
                                    <option value=""></option>
395
                                    [% FOREACH l IN locales %]
411
                                    [% FOREACH l IN locales %]
396
                                        [% IF l.language == locale %]
412
                                        [% IF l.language == locale %]
397
                                            <option value="[% l.language | html %]" selected="selected">[% l.description | html %]</option>
413
                                            <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]" selected="selected">[% l.description | html %]</option>
398
                                        [% ELSE %]
414
                                        [% ELSE %]
399
                                            <option value="[% l.language | html %]">[% l.description | html %]</option>
415
                                            <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]">[% l.description | html %]</option>
400
                                        [% END %]
416
                                        [% END %]
401
                                    [% END %]
417
                                    [% END %]
402
                                </select>
418
                                </select>
419
                                <input type="hidden" id="subtag" name="subtag" value="">
403
                                <div class="hint">If empty, English is used</div>
420
                                <div class="hint">If empty, English is used</div>
404
                            </li>
421
                            </li>
405
                            <li id="more_options">
422
                            <li id="more_options">
Lines 417-425 Link Here
417
                                        <tr>
434
                                        <tr>
418
                                            <th scope="row">
435
                                            <th scope="row">
419
                                                [% IF (more_than_one_serial) %]
436
                                                [% IF (more_than_one_serial) %]
420
                                                    Last value:
437
                                                Last value:
421
                                                [% ELSE %]
438
                                                [% ELSE %]
422
                                                    Begins with:
439
                                                Begins with:
423
                                                [% END %]
440
                                                [% END %]
424
                                            </th>
441
                                            </th>
425
                                            <td id="beginsX"><input type="text" id="lastvaluetemp1" name="lastvaluetemp1" value="[% lastvalue1 | html %]" /></td>
442
                                            <td id="beginsX"><input type="text" id="lastvaluetemp1" name="lastvaluetemp1" value="[% lastvalue1 | html %]" /></td>
Lines 442-548 Link Here
442
                            </li>
459
                            </li>
443
                        </ol>
460
                        </ol>
444
461
445
                        <div id="advancedpredictionpattern" style="display:none">
462
                            <div id="advancedpredictionpattern" style="display:none">
446
                            <ol>
463
                                <ol>
447
                                <li>
448
                                    <label for="patternname" class="required">Pattern name:</label>
449
                                    <input id="patternname" name="patternname" type="text" readonly="readonly" class="required" required="required" />
450
                                    <span class="required">Required</span>
451
                                </li>
452
                                <li>
464
                                <li>
453
                                    <label for="numberingmethod">Numbering formula:</label>
465
                                <label for="patternname" class="required">Pattern name:</label>
454
                                    <input readonly="readonly" type="text" name="numberingmethod" id="numberingmethod" size="50" value="[% numberingmethod | html %]" />
466
                                <input id="patternname" name="patternname" type="text" readonly="readonly" class="required" required="required" />
467
                                <span class="required">Required</span>
455
                                </li>
468
                                </li>
456
                                <li>
469
                                <li>
457
                                    <span class="label">Advanced prediction pattern: </span>
470
                                <label for="numberingmethod">Numbering formula:</label>
458
                                    <table id="advancedpredictionpatternt">
471
                                <input readonly="readonly" type="text" name="numberingmethod" id="numberingmethod" size="50" value="[% numberingmethod | html %]" />
459
                                        <thead>
460
                                            <tr>
461
                                                <th>&nbsp;</th>
462
                                                <th>X</th>
463
                                                <th>Y</th>
464
                                                <th>Z</th>
465
                                            </tr>
466
                                        </thead>
467
                                        <tbody>
468
                                            <tr>
469
                                                <th scope="row">Label: </th>
470
                                                <td><input type="text" readonly="readonly" id="label1" name="label1" /></td>
471
                                                <td><input type="text" readonly="readonly" id="label2" name="label2" /></td>
472
                                                <td><input type="text" readonly="readonly" id="label3" name="label3" /></td>
473
                                            </tr>
474
                                            <tr>
475
                                                <th scope="row">Begins with: </th>
476
                                                <td><input type="text" readonly="readonly" id="lastvalue1" name="lastvalue1" /></td>
477
                                                <td><input type="text" readonly="readonly" id="lastvalue2" name="lastvalue2" /></td>
478
                                                <td><input type="text" readonly="readonly" id="lastvalue3" name="lastvalue3" /></td>
479
                                            </tr>
480
                                            <tr>
481
                                                <th scope="row">Add: </th>
482
                                                <td><input type="text" readonly="readonly" id="add1" name="add1" /></td>
483
                                                <td><input type="text" readonly="readonly" id="add2" name="add2" /></td>
484
                                                <td><input type="text" readonly="readonly" id="add3" name="add3" /></td>
485
                                            </tr>
486
                                            <tr>
487
                                                <th scope="row">Every: </th>
488
                                                <td><input type="text" readonly="readonly" id="every1" name="every1" /></td>
489
                                                <td><input type="text" readonly="readonly" id="every2" name="every2" /></td>
490
                                                <td><input type="text" readonly="readonly" id="every3" name="every3" /></td>
491
                                            </tr>
492
                                            <tr>
493
                                                <th scope="row">Set back to: </th>
494
                                                <td><input type="text" readonly="readonly" id="setto1" name="setto1" /></td>
495
                                                <td><input type="text" readonly="readonly" id="setto2" name="setto2" /></td>
496
                                                <td><input type="text" readonly="readonly" id="setto3" name="setto3" /></td>
497
                                            </tr>
498
                                            <tr>
499
                                                <th scope="row">When more than: </th>
500
                                                <td><input type="text" readonly="readonly" id="whenmorethan1" name="whenmorethan1" /></td>
501
                                                <td><input type="text" readonly="readonly" id="whenmorethan2" name="whenmorethan2" /></td>
502
                                                <td><input type="text" readonly="readonly" id="whenmorethan3" name="whenmorethan3" /></td>
503
                                            </tr>
504
                                            <tr>
505
                                                <th scope="row">Inner counter: </th>
506
                                                <td><input type="text" readonly="readonly" id="innerloop1" name="innerloop1" /></td>
507
                                                <td><input type="text" readonly="readonly" id="innerloop2" name="innerloop2" /></td>
508
                                                <td><input type="text" readonly="readonly" id="innerloop3" name="innerloop3" /></td>
509
                                            </tr>
510
                                            <tr>
511
                                                [% BLOCK numbering_select %]
512
                                                    <select disabled="disabled" id="[% name | html %]" name="[% name | html %]">
513
                                                        <option value=""></option>
514
                                                        <option value="dayname">Name of day</option>
515
                                                        <option value="dayabrv">Name of day (abbreviated)</option>
516
                                                        <option value="monthname">Name of month</option>
517
                                                        <option value="monthabrv">Name of month (abbreviated)</option>
518
                                                        <option value="season">Name of season</option>
519
                                                        <option value="seasonabrv">Name of season (abbreviated)</option>
520
                                                    </select>
521
                                                [% END %]
522
                                                <th scope="row">Formatting:</th>
523
                                                <td>[% PROCESS numbering_select name="numbering1" %]</td>
524
                                                <td>[% PROCESS numbering_select name="numbering2" %]</td>
525
                                                <td>[% PROCESS numbering_select name="numbering3" %]</td>
526
                                            </tr>
527
                                        </tbody>
528
                                    </table>
529
                                </li>
472
                                </li>
530
                                <li>
473
                                <li>
531
                                    <span class="label">&nbsp;</span>
474
                                <span class="label">Advanced prediction pattern: </span>
532
                                    <a href="#" id="modifyadvancedpatternbutton"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Modify pattern</a>
475
                                <table id="advancedpredictionpatternt">
533
                                    <button type="button" class="btn btn-default btn-xs" id="saveadvancedpatternbutton" style="display:none"><i class="fa fa-save"></i> Save as new pattern</button>
476
                                    <thead>
534
                                    <a class="cancel" href="#" id="restoreadvancedpatternbutton" style="display:none">Cancel modifications</a>
477
                                        <tr>
535
                                </li>
478
                                            <th>&nbsp;</th>
479
                                            <th>X</th>
480
                                            <th>Y</th>
481
                                            <th>Z</th>
482
                                        </tr>
483
                                    </thead>
484
                                    <tbody>
485
                                        <tr>
486
                                            <th scope="row">Label: </th>
487
                                            <td><input type="text" readonly="readonly" id="label1" name="label1" /></td>
488
                                            <td><input type="text" readonly="readonly" id="label2" name="label2" /></td>
489
                                            <td><input type="text" readonly="readonly" id="label3" name="label3" /></td>
490
                                        </tr>
491
                                        <tr>
492
                                            <th scope="row">Begins with: </th>
493
                                            <td><input type="text" readonly="readonly" id="lastvalue1" name="lastvalue1" /></td>
494
                                            <td><input type="text" readonly="readonly" id="lastvalue2" name="lastvalue2" /></td>
495
                                            <td><input type="text" readonly="readonly" id="lastvalue3" name="lastvalue3" /></td>
496
                                        </tr>
497
                                        <tr>
498
                                            <th scope="row">Add: </th>
499
                                            <td><input type="text" readonly="readonly" id="add1" name="add1" /></td>
500
                                            <td><input type="text" readonly="readonly" id="add2" name="add2" /></td>
501
                                            <td><input type="text" readonly="readonly" id="add3" name="add3" /></td>
502
                                        </tr>
503
                                        <tr>
504
                                            <th scope="row">Every: </th>
505
                                            <td><input type="text" readonly="readonly" id="every1" name="every1" /></td>
506
                                            <td><input type="text" readonly="readonly" id="every2" name="every2" /></td>
507
                                            <td><input type="text" readonly="readonly" id="every3" name="every3" /></td>
508
                                        </tr>
509
                                        <tr>
510
                                            <th scope="row">Set back to: </th>
511
                                            <td><input type="text" readonly="readonly" id="setto1" name="setto1" /></td>
512
                                            <td><input type="text" readonly="readonly" id="setto2" name="setto2" /></td>
513
                                            <td><input type="text" readonly="readonly" id="setto3" name="setto3" /></td>
514
                                        </tr>
515
                                        <tr>
516
                                            <th scope="row">When more than: </th>
517
                                            <td><input type="text" readonly="readonly" id="whenmorethan1" name="whenmorethan1" /></td>
518
                                            <td><input type="text" readonly="readonly" id="whenmorethan2" name="whenmorethan2" /></td>
519
                                            <td><input type="text" readonly="readonly" id="whenmorethan3" name="whenmorethan3" /></td>
520
                                        </tr>
521
                                        <tr>
522
                                            <th scope="row">Inner counter: </th>
523
                                            <td><input type="text" readonly="readonly" id="innerloop1" name="innerloop1" /></td>
524
                                            <td><input type="text" readonly="readonly" id="innerloop2" name="innerloop2" /></td>
525
                                            <td><input type="text" readonly="readonly" id="innerloop3" name="innerloop3" /></td>
526
                                        </tr>
527
                                        <tr>
528
                                            [% BLOCK numbering_select %]
529
                                                <select disabled="disabled" id="[% name | html %]" name="[% name | html %]">
530
                                                    <option value=""></option>
531
                                                    <option value="dayname">Name of day</option>
532
                                                    <option value="dayabrv">Name of day (abbreviated)</option>
533
                                                    <option value="monthname">Name of month</option>
534
                                                    <option value="monthabrv">Name of month (abbreviated)</option>
535
                                                    <option value="season">Name of season</option>
536
                                                    <option value="seasonabrv">Name of season (abbreviated)</option>
537
                                                </select>
538
                                            [% END %]
539
                                            <th scope="row">Formatting:</th>
540
                                            <td>[% PROCESS numbering_select name="numbering1" %]</td>
541
                                            <td>[% PROCESS numbering_select name="numbering2" %]</td>
542
                                            <td>[% PROCESS numbering_select name="numbering3" %]</td>
543
                                        </tr>
544
                                    </tbody>
545
                                </table>
546
                            </li>
547
                            <li>
548
                                <span class="label">&nbsp;</span>
549
                                <a href="#" id="modifyadvancedpatternbutton"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Modify pattern</a>
550
                                <button type="button" class="btn btn-default btn-xs" id="saveadvancedpatternbutton" style="display:none"><i class="fa fa-save"></i> Save as new pattern</button>
551
                                <a class="cancel" href="#" id="restoreadvancedpatternbutton" style="display:none">Cancel modifications</a>
552
                            </li>
536
                            </ol>
553
                            </ol>
537
                        </div>
554
                        </div> <!-- /#advancedpredictionpattern -->
538
                        <!-- /#advancedpredictionpattern -->
539
                        <fieldset class="action">
555
                        <fieldset class="action">
540
                            <button type="button" id="testpatternbutton" class="btn btn-default btn-sm"><i class="fa fa-play"></i> Test prediction pattern</button>
556
                            <button type="button" id="testpatternbutton" class="btn btn-default btn-sm"><i class="fa fa-play"></i> Test prediction pattern</button>
541
                        </fieldset>
557
                        </fieldset>
542
                    </fieldset>
558
                    </fieldset>
543
559
544
                    [% IF additional_fields %]
560
                    [% IF additional_fields %]
545
                        <div id="subscription_additional_fields"> [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values %] </div>
561
                        <div id="subscription_additional_fields">
562
                            [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values %]
563
                        </div>
546
                    [% END %]
564
                    [% END %]
547
565
548
                    <input type="hidden" id="mana_id" name="mana_id" value="" />
566
                    <input type="hidden" id="mana_id" name="mana_id" value="" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt (-60 / +70 lines)
Lines 192-256 Link Here
192
192
193
        <form method="get">
193
        <form method="get">
194
            <fieldset class="rows">
194
            <fieldset class="rows">
195
                <legend>Test prediction pattern</legend>
195
              <legend>Test prediction pattern</legend>
196
                <ol>
196
              <ol>
197
                    <li>
197
                <li>
198
                        <label for="frequency">Frequency: </label>
198
                  <label for="frequency">Frequency: </label>
199
                        <select id="frequency">
199
                  <select id="frequency">
200
                            [% FOREACH frequency IN frequencies_loop %]
200
                    [% FOREACH frequency IN frequencies_loop %]
201
                                <option value="[% frequency.id | html %]">[% frequency.description | html %]</option>
201
                      <option value="[% frequency.id | html %]">[% frequency.description | html %]</option>
202
                            [% END %]
202
                    [% END %]
203
                        </select>
203
                  </select>
204
                    </li>
204
                </li>
205
                    <li>
205
                <li>
206
                        <label for="firstacquidate">First issue publication date: </label>
206
                  <label for="firstacquidate">First issue publication date: </label>
207
                        <input type="text" id="firstacquidate" class="flatpickr" size="10" />
207
                  <input type="text" id="firstacquidate" class="flatpickr" size="10" />
208
                    </li>
208
                </li>
209
                    <li>
209
                <li>
210
                        <label for="sublength">Subscription length:</label>
210
                  <label for="sublength">Subscription length:</label>
211
                        <select id="subtype">
211
                  <select id="subtype">
212
                            <option value="issues">issues</option>
212
                    <option value="issues">issues</option>
213
                            <option value="weeks">weeks</option>
213
                    <option value="weeks">weeks</option>
214
                            <option value="months">months</option>
214
                    <option value="months">months</option>
215
                        </select>
215
                  </select>
216
                        <input type="text" id="sublength" size="3" />
216
                  <input type="text" id="sublength" size="3" />
217
                    </li>
217
                </li>
218
                    <li>
218
                <li>
219
                        <label for="locale">Locale: </label>
219
                  <label for="locale">Locale: </label>
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
                    </li>
227
                  <input type="hidden" id="subtag" name="subtag" value="">
228
                </ol>
228
                </li>
229
                <table>
229
              </ol>
230
                    <thead>
230
              <table>
231
                        <tr>
231
                <thead>
232
                            <th>&nbsp;</th>
232
                  <tr>
233
                            <th>X</th>
233
                    <th>&nbsp;</th>
234
                            <th>Y</th>
234
                    <th>X</th>
235
                            <th>Z</th>
235
                    <th>Y</th>
236
                        </tr>
236
                    <th>Z</th>
237
                    </thead>
237
                  </tr>
238
                    <tbody>
238
                </thead>
239
                        <tr>
239
                <tbody>
240
                            <td>Begins with</td>
240
                  <tr>
241
                            <td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 | html %]" /></td>
241
                    <td>Begins with</td>
242
                            <td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 | html %]" /></td>
242
                    <td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 | html %]" /></td>
243
                            <td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 | html %]" /></td>
243
                    <td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 | html %]" /></td>
244
                        </tr>
244
                    <td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 | html %]" /></td>
245
                        <tr>
245
                  </tr>
246
                            <td>Inner counter</td>
246
                  <tr>
247
                            <td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 | html %]" /></td>
247
                    <td>Inner counter</td>
248
                            <td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 | html %]" /></td>
248
                    <td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 | html %]" /></td>
249
                            <td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 | html %]" /></td>
249
                    <td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 | html %]" /></td>
250
                        </tr>
250
                    <td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 | html %]" /></td>
251
                    </tbody>
251
                  </tr>
252
                </table>
252
                </tbody>
253
                <div id="predictionpattern"></div>
253
              </table>
254
              <div id="predictionpattern"></div>
254
            </fieldset>
255
            </fieldset>
255
            <fieldset class="action">
256
            <fieldset class="action">
256
                <button type="button" id="test_pattern" class="btn btn-default">Test pattern</button>
257
                <button type="button" id="test_pattern" class="btn btn-default">Test pattern</button>
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 (-32 / +17 lines)
Lines 384-420 function testPredictionPattern() { Link Here
384
    }
384
    }
385
385
386
    var ajaxParams = [
386
    var ajaxParams = [
387
        "to",
387
        'to', 'subtype', 'sublength', 'frequency', 'numberingmethod',
388
        "subtype",
388
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
389
        "sublength",
389
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
390
        "frequency",
390
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
391
        "numberingmethod",
391
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag',
392
        "lastvalue1",
392
        'sfdescription', 'unitsperissue', 'issuesperunit', 'unit'
393
        "lastvalue2",
394
        "lastvalue3",
395
        "add1",
396
        "add2",
397
        "add3",
398
        "every1",
399
        "every2",
400
        "every3",
401
        "innerloop1",
402
        "innerloop2",
403
        "innerloop3",
404
        "setto1",
405
        "setto2",
406
        "setto3",
407
        "numbering1",
408
        "numbering2",
409
        "numbering3",
410
        "whenmorethan1",
411
        "whenmorethan2",
412
        "whenmorethan3",
413
        "locale",
414
        "sfdescription",
415
        "unitsperissue",
416
        "issuesperunit",
417
        "unit",
418
    ];
393
    ];
419
    for (i in ajaxParams) {
394
    for (i in ajaxParams) {
420
        var param = ajaxParams[i];
395
        var param = ajaxParams[i];
Lines 688-694 function mana_comment_close() { Link Here
688
    $("#new_mana_comment").hide();
663
    $("#new_mana_comment").hide();
689
}
664
}
690
665
691
function showPredictionPatternTest(data) {
666
function setSubtag () {
667
    $("#subtag").val($("#locale").find(':selected').data('subtag'));
668
}
669
670
function showPredictionPatternTest( data ){
692
    $("#displayexample").html(data).show();
671
    $("#displayexample").html(data).show();
693
    $("#page_2 > div").attr("class", "col-sm-6");
672
    $("#page_2 > div").attr("class", "col-sm-6");
694
}
673
}
Lines 891-894 $(document).ready(function () { Link Here
891
        const display = $(this).val() == "1" ? "flex" : "none";
870
        const display = $(this).val() == "1" ? "flex" : "none";
892
        $(".use_items").css("display", display).find("select").val("");
871
        $(".use_items").css("display", display).find("select").val("");
893
    });
872
    });
873
874
    $("#locale").on("change", function() {
875
        setSubtag();
876
    });
877
878
    setSubtag();
894
});
879
});
(-)a/serials/showpredictionpattern.pl (-5 / +16 lines)
Lines 30-40 publication date, based on frequency and first publication date. Link Here
30
30
31
use Modern::Perl;
31
use Modern::Perl;
32
32
33
use CGI         qw ( -utf8 );
33
use CGI qw ( -utf8 );
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
38
    qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq GetSeasonsTranslations );
38
use C4::Serials::Frequency;
39
use C4::Serials::Frequency;
39
use Koha::DateUtils qw( dt_from_string );
40
use Koha::DateUtils qw( dt_from_string );
40
41
Lines 97-102 $enddate = dt_from_string($enddate)->ymd if $enddate; Link Here
97
$nextacquidate = $nextacquidate ? dt_from_string($nextacquidate)->ymd : $firstacquidate;
98
$nextacquidate = $nextacquidate ? dt_from_string($nextacquidate)->ymd : $firstacquidate;
98
my $date = $nextacquidate;
99
my $date = $nextacquidate;
99
100
101
my $need_seasons     = grep { $_ =~ /^season$/ } %pattern;
102
my $need_seasonsabrv = grep { $_ =~ /^seasonabrv$/ } %pattern;
103
my $subtag           = scalar $input->param('subtag');
104
105
my $translations;
106
$translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $subtag )
107
    if ( $need_seasons || $need_seasonsabrv );
108
100
my %subscription = (
109
my %subscription = (
101
    locale             => scalar $input->param('locale')     // '',
110
    locale             => scalar $input->param('locale')     // '',
102
    lastvalue1         => scalar $input->param('lastvalue1') // '',
111
    lastvalue1         => scalar $input->param('lastvalue1') // '',
Lines 108-113 my %subscription = ( Link Here
108
    irregularity       => '',
117
    irregularity       => '',
109
    countissuesperunit => 1,
118
    countissuesperunit => 1,
110
    firstacquidate     => $firstacquidate,
119
    firstacquidate     => $firstacquidate,
120
    translations       => $translations,
111
);
121
);
112
122
113
my $issuenumber;
123
my $issuenumber;
Lines 189-194 while ( $i < 1000 ) { Link Here
189
199
190
$template->param(
200
$template->param(
191
    predictions_loop => \@predictions_loop,
201
    predictions_loop => \@predictions_loop,
202
    error_messages   => \@{ $translations->{error_messages} },
192
);
203
);
193
204
194
if ( $frequency->{unit} and not $custompattern ) {
205
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 (-5 / +77 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::Items   qw( AddItemFromMarc );
14
use C4::Context;
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 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,
(-)a/t/db_dependent/Serials/GetNextSeq.t.tdy (-1 / +279 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use C4::Context;
4
use Test::More tests => 32;
5
use Modern::Perl;
6
use Koha::Database;
7
8
my $schema = Koha::Database->new->schema;
9
$schema->storage->txn_begin;
10
11
use C4::Serials::Frequency;
12
use C4::Serials qw( GetNextDate GetNextSeq );
13
14
my $frequency = {
15
    description   => "One issue per day",
16
    unit          => 'day',
17
    issuesperunit => 1,
18
    unitsperissue => 1,
19
};
20
my $id = AddSubscriptionFrequency($frequency);
21
22
# TEST CASE 1 - 1 variable, from 1 to 4
23
my $pattern = {
24
    add1            => 1, add2          => 0, add3          => 0,
25
    every1          => 1, every2        => 0, every3        => 0,
26
    whenmorethan1   => 4, whenmorethan2 => 0, whenmorethan3 => 0,
27
    setto1          => 1, setto2        => 0, setto3        => 0,
28
    numberingmethod => 'X: {X}',
29
    numbering1      => '',
30
    numbering2      => '',
31
    numbering3      => '',
32
};
33
34
my $subscription = {
35
    periodicity        => $id,
36
    firstacquidate     => '1970-01-01',
37
    lastvalue1         => 1, lastvalue2 => 1, lastvalue3 => 1,
38
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
39
    skip_serialseq     => 1,
40
    irregularity       => '3;5',
41
    countissuesperunit => 1,
42
    locale             => 'en',
43
};
44
my $publisheddate = $subscription->{firstacquidate};
45
46
my $seq = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
47
is( $seq, 'X: 2' );
48
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
49
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
50
is( $seq, 'X: 4' );
51
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
52
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
53
is( $seq, 'X: 2' );
54
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
55
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
56
is( $seq, 'X: 3' );
57
58
# TEST CASE 2 - 1 variable, use 'dayname' numbering, from 1 to 7
59
$subscription = {
60
    periodicity        => $id,
61
    firstacquidate     => '1970-01-01',
62
    lastvalue1         => 1, lastvalue2 => 1, lastvalue3 => 1,
63
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
64
    skip_serialseq     => 1,
65
    irregularity       => '3;4;6',
66
    countissuesperunit => 1,
67
    locale             => 'C',
68
};
69
$pattern = {
70
    add1            => 1, add2          => 0, add3          => 0,
71
    every1          => 1, every2        => 0, every3        => 0,
72
    whenmorethan1   => 7, whenmorethan2 => 0, whenmorethan3 => 0,
73
    setto1          => 1, setto2        => 0, setto3        => 0,
74
    numberingmethod => 'X: {X}',
75
    numbering1      => 'dayname',
76
    numbering2      => '',
77
    numbering3      => '',
78
};
79
80
$publisheddate = $subscription->{firstacquidate};
81
82
$seq = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
83
is( $seq, 'X: Tuesday' );
84
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
85
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
86
is( $seq, 'X: Friday' );
87
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
88
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
89
is( $seq, 'X: Sunday' );
90
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
91
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
92
is( $seq, 'X: Monday' );
93
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
94
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
95
is( $seq, 'X: Tuesday' );
96
97
# TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2
98
$subscription = {
99
    periodicity        => $id,
100
    firstacquidate     => '1970-01-01',
101
    lastvalue1         => 0, lastvalue2 => 1, lastvalue3 => 1,
102
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
103
    skip_serialseq     => 1,
104
    irregularity       => '3;4;6',
105
    countissuesperunit => 1,
106
    locale             => 'C',
107
};
108
$pattern = {
109
    add1            => 2,  add2          => 0, add3          => 0,
110
    every1          => 1,  every2        => 0, every3        => 0,
111
    whenmorethan1   => 11, whenmorethan2 => 0, whenmorethan3 => 0,
112
    setto1          => 0,  setto2        => 0, setto3        => 0,
113
    numberingmethod => 'X: {X}',
114
    numbering1      => 'monthname',
115
    numbering2      => '',
116
    numbering3      => '',
117
};
118
119
$publisheddate = $subscription->{firstacquidate};
120
121
$seq = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
122
is( $seq, 'X: March' );
123
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
124
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
125
is( $seq, 'X: September' );
126
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
127
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
128
is( $seq, 'X: January' );
129
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
130
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
131
is( $seq, 'X: March' );
132
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
133
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
134
is( $seq, 'X: May' );
135
136
# TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3
137
$subscription = {
138
    periodicity        => $id,
139
    firstacquidate     => '1970-01-01',
140
    lastvalue1         => 0, lastvalue2 => 1, lastvalue3 => 1,
141
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
142
    skip_serialseq     => 1,
143
    irregularity       => '3;4;6',
144
    countissuesperunit => 1,
145
    locale             => 'C',
146
    translations       => { seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ] },
147
};
148
$pattern = {
149
    add1            => 1, add2          => 0, add3          => 0,
150
    every1          => 1, every2        => 0, every3        => 0,
151
    whenmorethan1   => 3, whenmorethan2 => 0, whenmorethan3 => 0,
152
    setto1          => 0, setto2        => 0, setto3        => 0,
153
    numberingmethod => 'X: {X}',
154
    numbering1      => 'season',
155
    numbering2      => '',
156
    numbering3      => '',
157
};
158
159
$publisheddate = $subscription->{firstacquidate};
160
161
$seq = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
162
is( $seq, 'X: Summer' );
163
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
164
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
165
is( $seq, 'X: Spring' );
166
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
167
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
168
is( $seq, 'X: Fall' );
169
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
170
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
171
is( $seq, 'X: Winter' );
172
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
173
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
174
is( $seq, 'X: Spring' );
175
176
# TEST CASE 5 - 2 variables, from 1 to 12, and from 1 to 4
177
$subscription = {
178
    periodicity        => $id,
179
    firstacquidate     => '1970-01-01',
180
    lastvalue1         => 1, lastvalue2 => 1, lastvalue3 => 1,
181
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
182
    skip_serialseq     => 1,
183
    irregularity       => '3;4;6',
184
    countissuesperunit => 1,
185
    locale             => 'C',
186
};
187
$pattern = {
188
    add1            => 1, add2          => 1,  add3          => 0,
189
    every1          => 1, every2        => 4,  every3        => 0,
190
    whenmorethan1   => 4, whenmorethan2 => 12, whenmorethan3 => 0,
191
    setto1          => 1, setto2        => 1,  setto3        => 0,
192
    numberingmethod => 'Y: {Y}, X: {X}',
193
    numbering1      => '',
194
    numbering2      => '',
195
    numbering3      => '',
196
};
197
198
$publisheddate = $subscription->{firstacquidate};
199
200
$seq = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
201
is( $seq, 'Y: 1, X: 2' );
202
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
203
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
204
is( $seq, 'Y: 2, X: 1' );
205
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
206
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
207
is( $seq, 'Y: 2, X: 3' );
208
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
209
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
210
is( $seq, 'Y: 2, X: 4' );
211
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
212
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
213
is( $seq, 'Y: 3, X: 1' );
214
215
# TEST CASE 6 - 3 variables, from 1 to 12, from 1 to 8, and from 1 to 4
216
$subscription = {
217
    periodicity        => $id,
218
    firstacquidate     => '1970-01-01',
219
    lastvalue1         => 1, lastvalue2 => 1, lastvalue3 => 1,
220
    innerloop1         => 0, innerloop2 => 0, innerloop3 => 0,
221
    skip_serialseq     => 1,
222
    irregularity       => '3;4;6;110',
223
    countissuesperunit => 1,
224
    locale             => 'C',
225
};
226
$pattern = {
227
    add1            => 1, add2          => 1, add3          => 1,
228
    every1          => 1, every2        => 4, every3        => 32,
229
    whenmorethan1   => 4, whenmorethan2 => 8, whenmorethan3 => 12,
230
    setto1          => 1, setto2        => 1, setto3        => 1,
231
    numberingmethod => 'Z: {Z}, Y: {Y}, X: {X}',
232
    numbering1      => '',
233
    numbering2      => '',
234
    numbering3      => '',
235
};
236
237
$publisheddate = $subscription->{firstacquidate};
238
239
$seq = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
240
is( $seq, 'Z: 1, Y: 1, X: 2' );
241
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
242
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
243
is( $seq, 'Z: 1, Y: 2, X: 1' );
244
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
245
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
246
is( $seq, 'Z: 1, Y: 2, X: 3' );
247
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
248
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
249
is( $seq, 'Z: 1, Y: 2, X: 4' );
250
251
for ( 1 .. 100 ) {
252
    $publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
253
    $seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
254
}
255
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
256
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
257
is( $seq, 'Z: 4, Y: 4, X: 1' );
258
259
# 110th is here
260
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
261
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
262
is( $seq, 'Z: 4, Y: 4, X: 3' );
263
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
264
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
265
is( $seq, 'Z: 4, Y: 4, X: 4' );
266
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency );
267
$seq           = _next_seq( $subscription, $pattern, $frequency, $publisheddate );
268
is( $seq, 'Z: 4, Y: 5, X: 1' );
269
270
sub _next_seq {
271
    my ( $subscription, $pattern, $frequency, $publisheddate ) = @_;
272
    my $seq;
273
    (
274
        $seq,                        $subscription->{lastvalue1}, $subscription->{lastvalue2},
275
        $subscription->{lastvalue3}, $subscription->{innerloop1},
276
        $subscription->{innerloop2}, $subscription->{innerloop3}
277
    ) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
278
    return $seq;
279
}

Return to bug 35590