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

(-)a/C4/Serials.pm (-19 / +44 lines)
Lines 861-868 sub GetNextSeq { Link Here
861
861
862
    my $calculated = "";
862
    my $calculated = "";
863
    my $numberingmethod = "";
863
    my $numberingmethod = "";
864
    my $dateformat = $subscription->{pubdatepatternformat};
864
    if ($pattern eq "pubdate"){
865
    if ($pattern eq "pubdate"){
865
        $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
866
        if ( $dateformat eq 'dmy' ){
867
            $calculated = dt_from_string( $planneddate )->strftime( '%d %B %Y' );
868
        } elsif ( $dateformat eq 'mdy' ){
869
            $calculated = dt_from_string( $planneddate )->strftime( '%B %d %Y' );
870
        } elsif ( $dateformat eq 'ydm' ){
871
            $calculated = dt_from_string( $planneddate )->strftime( '%Y %d %B' );
872
        } else {
873
            $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
874
        }
866
    } else {
875
    } else {
867
        $numberingmethod = $pattern->{numberingmethod};
876
        $numberingmethod = $pattern->{numberingmethod};
868
    }
877
    }
Lines 1156-1181 sub ModSerialStatus { Link Here
1156
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1165
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1157
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1166
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1158
1167
1159
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1);
1168
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency);
1160
        my ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1169
        my ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1161
             $newinnerloop1, $newinnerloop2, $newinnerloop3 );
1170
             $newinnerloop1, $newinnerloop2, $newinnerloop3 );
1162
1171
1172
        # next issue number
1163
        if (!defined $pattern){
1173
        if (!defined $pattern){
1164
            $pattern = "pubdate";
1174
            $pattern = "pubdate";
1165
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1175
            $newserialseq = "pubdate";
1166
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $nextpublisheddate );
1167
        } else {
1176
        } else {
1168
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1177
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1169
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
1178
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
1170
        }
1179
        }
1171
1180
1172
        # next issue number
1173
        my (
1174
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1175
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1176
          )
1177
          = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
1178
1179
        # next date (calculated from actual date & frequency parameters)
1181
        # next date (calculated from actual date & frequency parameters)
1180
        my $nextpubdate = $nextpublisheddate;
1182
        my $nextpubdate = $nextpublisheddate;
1181
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1183
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
Lines 1322-1328 sub ModSubscription { Link Here
1322
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1324
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1323
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1325
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1324
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1326
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1325
    $itemtype, $previousitemtype, $mana_id
1327
    $itemtype, $previousitemtype, $mana_id, $dateformat
1326
    ) = @_;
1328
    ) = @_;
1327
1329
1328
    my $dbh   = C4::Context->dbh;
1330
    my $dbh   = C4::Context->dbh;
Lines 1335-1343 sub ModSubscription { Link Here
1335
            callnumber=?, notes=?, letter=?, manualhistory=?,
1337
            callnumber=?, notes=?, letter=?, manualhistory=?,
1336
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1338
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1337
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1339
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1338
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?
1340
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?,
1341
            pubdatepatternformat=?
1339
        WHERE subscriptionid = ?";
1342
        WHERE subscriptionid = ?";
1340
1341
    my $sth = $dbh->prepare($query);
1343
    my $sth = $dbh->prepare($query);
1342
    $sth->execute(
1344
    $sth->execute(
1343
        $auser,           $branchcode,     $aqbooksellerid, $cost,
1345
        $auser,           $branchcode,     $aqbooksellerid, $cost,
Lines 1349-1355 sub ModSubscription { Link Here
1349
        $letter,          ($manualhistory ? $manualhistory : 0),
1351
        $letter,          ($manualhistory ? $manualhistory : 0),
1350
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1352
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1351
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1353
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1352
        $itemtype,        $previousitemtype, $mana_id,
1354
        $itemtype,        $previousitemtype, $mana_id,      $dateformat,
1353
        $subscriptionid
1355
        $subscriptionid
1354
    );
1356
    );
1355
    my $rows = $sth->rows;
1357
    my $rows = $sth->rows;
Lines 1366-1372 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1366
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1368
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1367
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1369
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1368
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1370
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1369
    $skip_serialseq, $itemtype, $previousitemtype);
1371
    $skip_serialseq, $itemtype, $previousitemtype, $dateformat);
1370
1372
1371
Create a new subscription with value given on input args.
1373
Create a new subscription with value given on input args.
1372
1374
Lines 1383-1389 sub NewSubscription { Link Here
1383
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1385
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1384
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1386
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1385
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1387
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1386
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
1388
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id,
1389
    $dateformat
1387
    ) = @_;
1390
    ) = @_;
1388
    my $dbh = C4::Context->dbh;
1391
    my $dbh = C4::Context->dbh;
1389
1392
Lines 1426-1431 sub NewSubscription { Link Here
1426
            itemtype          => $itemtype,
1429
            itemtype          => $itemtype,
1427
            previousitemtype  => $previousitemtype,
1430
            previousitemtype  => $previousitemtype,
1428
            mana_id           => $mana_id,
1431
            mana_id           => $mana_id,
1432
            pubdatepatternformat => $dateformat,
1429
        }
1433
        }
1430
    )->store;
1434
    )->store;
1431
    $subscription->discard_changes;
1435
    $subscription->discard_changes;
Lines 1458-1465 sub NewSubscription { Link Here
1458
    # calculate issue number
1462
    # calculate issue number
1459
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1463
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1460
1464
1465
    $dateformat //= '';
1461
    if ($serialseq eq "pubdate"){
1466
    if ($serialseq eq "pubdate"){
1462
        $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1467
        if ( $dateformat eq 'dmy' ){
1468
            $serialseq = dt_from_string( $firstacquidate )->strftime('%d %B %Y');
1469
        } elsif ( $dateformat eq 'mdy' ){
1470
            $serialseq = dt_from_string( $firstacquidate )->strftime('%B %d %Y');
1471
        } elsif ( $dateformat eq 'ydm' ){
1472
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %d %B');
1473
        } else {
1474
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1475
        }
1463
    }
1476
    }
1464
1477
1465
    Koha::Serial->new(
1478
    Koha::Serial->new(
Lines 1572-1577 sub NewIssue { Link Here
1572
1585
1573
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1586
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1574
1587
1588
    my $dateformat = $subscription->pubdatepatternformat;
1589
    if ($serialseq eq "pubdate"){
1590
        if ( $dateformat eq 'dmy' ){
1591
            $serialseq = dt_from_string( $publisheddate )->strftime('%d %B %Y');
1592
        } elsif ( $dateformat eq 'mdy' ){
1593
            $serialseq = dt_from_string( $publisheddate )->strftime('%B %d %Y');
1594
        } elsif ( $dateformat eq 'ydm' ){
1595
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %d %B');
1596
        } else {
1597
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %B %d');
1598
        }
1599
    }
1600
1575
    my $serial = Koha::Serial->new(
1601
    my $serial = Koha::Serial->new(
1576
        {
1602
        {
1577
            serialseq         => $serialseq,
1603
            serialseq         => $serialseq,
Lines 2352-2358 sub GetNextDate { Link Here
2352
2378
2353
    return unless $subscription and $publisheddate;
2379
    return unless $subscription and $publisheddate;
2354
2380
2355
2356
    if ($freqdata->{'unit'}) {
2381
    if ($freqdata->{'unit'}) {
2357
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2382
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2358
2383
(-)a/Koha/Schema/Result/Subscription.pm (-2 / +10 lines)
Lines 276-281 __PACKAGE__->table("subscription"); Link Here
276
  data_type: 'integer'
276
  data_type: 'integer'
277
  is_nullable: 1
277
  is_nullable: 1
278
278
279
=head2 pubdatepatternformat
280
281
  data_type: 'varchar'
282
  is_nullable: 1
283
  size: 3
284
279
=cut
285
=cut
280
286
281
__PACKAGE__->add_columns(
287
__PACKAGE__->add_columns(
Lines 365-370 __PACKAGE__->add_columns( Link Here
365
  { data_type => "varchar", is_nullable => 1, size => 10 },
371
  { data_type => "varchar", is_nullable => 1, size => 10 },
366
  "mana_id",
372
  "mana_id",
367
  { data_type => "integer", is_nullable => 1 },
373
  { data_type => "integer", is_nullable => 1 },
374
  "pubdatepatternformat",
375
  { data_type => "varchar", is_nullable => 1, size => 3 },
368
);
376
);
369
377
370
=head1 PRIMARY KEY
378
=head1 PRIMARY KEY
Lines 452-459 __PACKAGE__->has_many( Link Here
452
);
460
);
453
461
454
462
455
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-23 12:56:39
463
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2019-02-28 22:06:40
456
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dTb/JOO3KQ3NZGypFbRiEw
464
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xfL68dHECH0R31U1uCTJtA
457
465
458
__PACKAGE__->has_many(
466
__PACKAGE__->has_many(
459
  "additional_field_values",
467
  "additional_field_values",
(-)a/installer/data/mysql/atomicupdate/bug_22188_-_add_pubdatepatternformat_column_serial.perl (+8 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    unless( column_exists( 'subscription', 'pubdatepatternformat' ) ) {
4
        $dbh->do(q|ALTER TABLE subscription ADD pubdatepatternformat varchar(3) default NULL AFTER mana_id|);
5
    }
6
    SetVersion( $DBversion );
7
    print "Upgrade to $DBversion done (Bug 22188: Add column subscription.pubdatepatternformat)\n";
8
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-2 / +35 lines)
Lines 306-314 fieldset.rows table { clear: none; margin: 0; } Link Here
306
                                    <li>
306
                                    <li>
307
                                        <label for="numberpattern" class="required">Numbering pattern:</label>
307
                                        <label for="numberpattern" class="required">Numbering pattern:</label>
308
                                        <select name="numbering_pattern" size="1" id="numberpattern" class="required" required="required">
308
                                        <select name="numbering_pattern" size="1" id="numberpattern" class="required" required="required">
309
                                            <option value="">-- please choose --</option>
309
                                            [% IF subscriptionid %]
310
                                                <option value="">-- please choose --</option>
311
                                            [% ELSE %]
312
                                                <option value="" selected="selected">-- please choose --</option>
313
                                            [% END %]
314
                                            [% SET pattern = 0 %]
310
                                            [% FOREACH numberpattern IN numberpatterns %]
315
                                            [% FOREACH numberpattern IN numberpatterns %]
311
                                                [% IF (numberpattern.selected) %]
316
                                                [% IF (numberpattern.selected) %]
317
                                                    [% pattern = 1 %]
312
                                                    <option value="[% numberpattern.id | html %]" selected="selected">
318
                                                    <option value="[% numberpattern.id | html %]" selected="selected">
313
                                                [% ELSE %]
319
                                                [% ELSE %]
314
                                                    <option value="[% numberpattern.id | html %]">
320
                                                    <option value="[% numberpattern.id | html %]">
Lines 316-322 fieldset.rows table { clear: none; margin: 0; } Link Here
316
                                                    [% numberpattern.label | html %]
322
                                                    [% numberpattern.label | html %]
317
                                                </option>
323
                                                </option>
318
                                            [% END %]
324
                                            [% END %]
319
                                            <option value="0">Use publication date</option>
325
                                            [% IF pattern == 0 and subscriptionid %]
326
                                                <option value="0" selected="selected">Use publication date</option>
327
                                            [% ELSE %]
328
                                                <option value="0">Use publication date</option>
329
                                            [% END %]
330
                                        </select>
331
                                        <select name="date_format" size="1" id="date_format">
332
                                            <option value="">-- choose date format --</option>
333
                                            [% IF dateformat == 'dmy' %]
334
                                                <option value="dmy" selected="selected">Day Month Year</option>
335
                                            [% ELSE %]
336
                                                <option value="dmy">Day Month Year</option>
337
                                            [% END %]
338
                                            [% IF dateformat == 'mdy' %]
339
                                                <option value="mdy" selected="selected">Month Day Year</option>
340
                                            [% ELSE %]
341
                                                <option value="mdy">Month Day Year</option>
342
                                            [% END %]
343
                                            [% IF dateformat == 'ymd' %]
344
                                                <option value="ymd" selected="selected">Year Month Day</option>
345
                                            [% ELSE %]
346
                                                <option value="ymd">Year Month Day</option>
347
                                            [% END %]
348
                                            [% IF dateformat == 'ydm' %]
349
                                                <option value="ydm" selected="selected">Year Day Month</option>
350
                                            [% ELSE %]
351
                                                <option value="ydm">Year Day Month</option>
352
                                            [% END %]
320
                                        </select>
353
                                        </select>
321
                                        <span class="required">Required</span>
354
                                        <span class="required">Required</span>
322
                                    </li>
355
                                    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-1 / +1 lines)
Lines 169-175 Link Here
169
                [% IF ( numberpattern ) %]
169
                [% IF ( numberpattern ) %]
170
                    [% numberpattern.label | html %]
170
                    [% numberpattern.label | html %]
171
                [% ELSE %]
171
                [% ELSE %]
172
                    Uses publication date
172
                    Uses publication date - [% dateformat %] format
173
                [% END %]
173
                [% END %]
174
            </li>
174
            </li>
175
            [% IF ( numberpattern ) %]
175
            [% IF ( numberpattern ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-2 / +10 lines)
Lines 323-329 function testPredictionPattern() { Link Here
323
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
323
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
324
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
324
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
325
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale',
325
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale',
326
        'sfdescription', 'unitsperissue', 'issuesperunit', 'unit'
326
        'sfdescription', 'unitsperissue', 'issuesperunit', 'unit', 'date_format'
327
    ];
327
    ];
328
    for(i in ajaxParams) {
328
    for(i in ajaxParams) {
329
        var param = ajaxParams[i];
329
        var param = ajaxParams[i];
Lines 548-553 function hidePredcitionPatternTest(){ Link Here
548
}
548
}
549
549
550
function usedatepattern() {
550
function usedatepattern() {
551
    $("#date_format").show();
551
    $("#more_options").hide();
552
    $("#more_options").hide();
552
    clearAdvancedPattern();
553
    clearAdvancedPattern();
553
    if ($("#advancedpredictionpattern").is(":visible")){
554
    if ($("#advancedpredictionpattern").is(":visible")){
Lines 568-573 $(document).ready(function() { Link Here
568
        $("#new_mana_comment").hide();
569
        $("#new_mana_comment").hide();
569
        $(".mana_comment_status").hide();
570
        $(".mana_comment_status").hide();
570
    });
571
    });
572
    $("#mana_search_result").modal("hide");
573
574
    $("#date_format").hide();
575
    if ($("select#numberpattern").val() == "0"){
576
        $("#date_format").show();
577
    }
571
578
572
    $("#aqbooksellerid").on('keypress', function(e) {
579
    $("#aqbooksellerid").on('keypress', function(e) {
573
        if (e.keyCode == 13) {
580
        if (e.keyCode == 13) {
Lines 588-598 $(document).ready(function() { Link Here
588
    });
595
    });
589
    $("select#numberpattern").change(function(){
596
    $("select#numberpattern").change(function(){
590
        patternneedtobetested = 1;
597
        patternneedtobetested = 1;
591
        console.log($("select#numberpattern").val());
592
        if ($("select#numberpattern").val() == "0"){
598
        if ($("select#numberpattern").val() == "0"){
593
            usedatepattern();
599
            usedatepattern();
594
        } else {
600
        } else {
595
            numberpatternload();
601
            numberpatternload();
602
            $("#date_format").hide();
603
            $("#date_format").val("");
596
        }
604
        }
597
    });
605
    });
598
    $("#subtype").change(function(){
606
    $("#subtype").change(function(){
(-)a/serials/serials-collection.pl (-4 / +13 lines)
Lines 32-38 use Koha::DateUtils qw( dt_from_string ); Link Here
32
32
33
use List::MoreUtils qw/uniq/;
33
use List::MoreUtils qw/uniq/;
34
34
35
36
my $query = new CGI;
35
my $query = new CGI;
37
my $op = $query->param('op') || q{};
36
my $op = $query->param('op') || q{};
38
my $nbissues=$query->param('nbissues');
37
my $nbissues=$query->param('nbissues');
Lines 69-74 if($op eq 'gennext' && @subscriptionid){ Link Here
69
        $sth->execute($subscriptionid);
68
        $sth->execute($subscriptionid);
70
        # modify actual expected issue, to generate the next
69
        # modify actual expected issue, to generate the next
71
        if ( my $issue = $sth->fetchrow_hashref ) {
70
        if ( my $issue = $sth->fetchrow_hashref ) {
71
72
            my $planneddate = $date_received_today ? dt_from_string : $issue->{planneddate};
72
            my $planneddate = $date_received_today ? dt_from_string : $issue->{planneddate};
73
            ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
73
            ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
74
                    $planneddate, $issue->{publisheddate},
74
                    $planneddate, $issue->{publisheddate},
Lines 82-91 if($op eq 'gennext' && @subscriptionid){ Link Here
82
            my (
82
            my (
83
                 $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
83
                 $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
84
                 $newinnerloop1, $newinnerloop2, $newinnerloop3
84
                 $newinnerloop1, $newinnerloop2, $newinnerloop3
85
            ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate});
85
            ) = GetNextSeq($subscription, $pattern, $frequency);
86
86
87
            if (!defined $pattern && !defined $newserialseq){
87
            if (!defined $pattern && !defined $newserialseq){
88
                $newserialseq = $expected->{publisheddate};
88
                my $dateformat = $subscription->{pubdatepatternformat};
89
                if ( $dateformat eq 'dmy' ){
90
                    $newserialseq = dt_from_string( $expected->{publisheddate} )->strftime('%d %B %Y');
91
                } elsif ( $dateformat eq 'mdy' ){
92
                    $newserialseq = dt_from_string( $expected->{publisheddate} )->strftime('%B %d %Y');
93
                } elsif ( $dateformat eq 'ydm' ){
94
                    $newserialseq = dt_from_string( $expected->{publisheddate} )->strftime('%Y %d %B');
95
                } else {
96
                    $newserialseq = dt_from_string( $expected->{publisheddate} )->strftime('%Y %B %d');
97
                }
89
            }
98
            }
90
99
91
             ## We generate the next publication date
100
             ## We generate the next publication date
Lines 134-140 if (@subscriptionid){ Link Here
134
    $subs->{frequency} = $frequency;
143
    $subs->{frequency} = $frequency;
135
    my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
144
    my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
136
    if (!defined $numberpattern){
145
    if (!defined $numberpattern){
137
        $numberpattern->{label} = "Uses publication date";
146
        $numberpattern->{label} = "Uses publication date - $subs->{pubdatepatternformat} format";
138
    }
147
    }
139
    $subs->{numberpattern} = $numberpattern;
148
    $subs->{numberpattern} = $numberpattern;
140
    $subs->{'hasRouting'} = check_routing($subscriptionid);
149
    $subs->{'hasRouting'} = check_routing($subscriptionid);
(-)a/serials/showpredictionpattern.pl (-2 / +20 lines)
Lines 127-134 if(defined $subscriptionid) { Link Here
127
my @predictions_loop;
127
my @predictions_loop;
128
my ($calculated) = GetSeq(\%subscription, \%pattern);
128
my ($calculated) = GetSeq(\%subscription, \%pattern);
129
129
130
my $dateformat = scalar $input->param('date_format');
131
130
if ($calculated eq "pubdate"){
132
if ($calculated eq "pubdate"){
131
    $calculated = dt_from_string( $date )->strftime('%Y %B %d');
133
    if ( $dateformat eq 'dmy' ){
134
        $calculated = dt_from_string( $date )->strftime('%d %B %Y');
135
    } elsif ( $dateformat eq 'mdy' ){
136
        $calculated = dt_from_string( $date )->strftime('%B %d %Y');
137
    } elsif ( $dateformat eq 'ydm' ){
138
        $calculated = dt_from_string( $date )->strftime('%Y %d %B');
139
    } else {
140
        $calculated = dt_from_string( $date )->strftime('%Y %B %d');
141
    }
132
}
142
}
133
143
134
push @predictions_loop, {
144
push @predictions_loop, {
Lines 179-185 while( $i < 1000 ) { Link Here
179
    $issuenumber++;
189
    $issuenumber++;
180
    $line{'number'} = $calculated;
190
    $line{'number'} = $calculated;
181
    if ($calculated eq ''){
191
    if ($calculated eq ''){
182
        $line{'number'} = dt_from_string( $date )->strftime('%Y %B %d');
192
        if ( $dateformat eq 'dmy' ){
193
            $line{'number'} = dt_from_string( $date )->strftime('%d %B %Y');
194
        } elsif ( $dateformat eq 'mdy' ){
195
            $line{'number'} = dt_from_string( $date )->strftime('%B %d %Y');
196
        } elsif ( $dateformat eq 'ydm' ){
197
            $line{'number'} = dt_from_string( $date )->strftime('%Y %d %B');
198
        } else {
199
            $line{'number'} = dt_from_string( $date )->strftime('%Y %B %d');
200
        }
183
    }
201
    }
184
    $line{'issuenumber'} = $issuenumber;
202
    $line{'issuenumber'} = $issuenumber;
185
    if(@irreg && $issuenumber == $irreg[0]){
203
    if(@irreg && $issuenumber == $irreg[0]){
(-)a/serials/subscription-add.pl (-2 / +5 lines)
Lines 170-175 $template->param( Link Here
170
    typeloop                 => \@typearg,
170
    typeloop                 => \@typearg,
171
    previoustypeloop         => \@previoustypearg,
171
    previoustypeloop         => \@previoustypearg,
172
    locations_loop=>$locations_loop,
172
    locations_loop=>$locations_loop,
173
    dateformat => $subs->{pubdatepatternformat},
173
);
174
);
174
175
175
# prepare template variables common to all $op conditions:
176
# prepare template variables common to all $op conditions:
Lines 371-376 sub redirect_add_subscription { Link Here
371
    if ($numberpattern == "0"){ # using publication date as numbering pattern
372
    if ($numberpattern == "0"){ # using publication date as numbering pattern
372
        $numberpattern = undef;
373
        $numberpattern = undef;
373
    }
374
    }
375
    my $dateformat = $query->param('date_format');
374
376
375
    my $subscriptionid = NewSubscription(
377
    my $subscriptionid = NewSubscription(
376
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
378
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
Lines 380-386 sub redirect_add_subscription { Link Here
380
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
382
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
381
        $manualhistory, $internalnotes, $serialsadditems,
383
        $manualhistory, $internalnotes, $serialsadditems,
382
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
384
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
383
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
385
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $dateformat
384
    );
386
    );
385
    if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
387
    if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
386
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
388
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
Lines 498-503 sub redirect_mod_subscription { Link Here
498
    if ($numberpattern == "0"){ # using publication date as numbering pattern
500
    if ($numberpattern == "0"){ # using publication date as numbering pattern
499
        $numberpattern = undef;
501
        $numberpattern = undef;
500
    }
502
    }
503
    my $dateformat = $query->param('date_format');
501
504
502
    ModSubscription(
505
    ModSubscription(
503
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
506
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
Lines 507-513 sub redirect_mod_subscription { Link Here
507
        $status, $biblionumber, $callnumber, $notes, $letter,
510
        $status, $biblionumber, $callnumber, $notes, $letter,
508
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
511
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
509
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
512
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
510
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
513
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $dateformat
511
    );
514
    );
512
515
513
    my @additional_fields;
516
    my @additional_fields;
(-)a/serials/subscription-detail.pl (-1 / +2 lines)
Lines 127-132 my @irregular_issues = split /;/, $subs->{irregularity}; Link Here
127
127
128
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
128
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
129
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
129
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
130
my $dateformat = $subs->{pubdatepatternformat};
130
131
131
my $default_bib_view = get_default_view();
132
my $default_bib_view = get_default_view();
132
133
Lines 165-170 $template->param( Link Here
165
    cannotedit => (not C4::Serials::can_edit_subscription( $subs )),
166
    cannotedit => (not C4::Serials::can_edit_subscription( $subs )),
166
    frequency => $frequency,
167
    frequency => $frequency,
167
    numberpattern => $numberpattern,
168
    numberpattern => $numberpattern,
169
    dateformat      => $dateformat,
168
    has_X           => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
170
    has_X           => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
169
    has_Y           => ($numberpattern->{'numberingmethod'} =~ /{Y}/) ? 1 : 0,
171
    has_Y           => ($numberpattern->{'numberingmethod'} =~ /{Y}/) ? 1 : 0,
170
    has_Z           => ($numberpattern->{'numberingmethod'} =~ /{Z}/) ? 1 : 0,
172
    has_Z           => ($numberpattern->{'numberingmethod'} =~ /{Z}/) ? 1 : 0,
171
- 

Return to bug 22188