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 1323-1329 sub ModSubscription { Link Here
1323
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1325
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1324
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1326
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1325
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1327
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1326
    $itemtype, $previousitemtype, $mana_id
1328
    $itemtype, $previousitemtype, $mana_id, $dateformat
1327
    ) = @_;
1329
    ) = @_;
1328
1330
1329
    my $dbh   = C4::Context->dbh;
1331
    my $dbh   = C4::Context->dbh;
Lines 1336-1344 sub ModSubscription { Link Here
1336
            callnumber=?, notes=?, letter=?, manualhistory=?,
1338
            callnumber=?, notes=?, letter=?, manualhistory=?,
1337
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1339
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1338
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1340
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1339
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?
1341
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?,
1342
            pubdatepatternformat=?
1340
        WHERE subscriptionid = ?";
1343
        WHERE subscriptionid = ?";
1341
1342
    my $sth = $dbh->prepare($query);
1344
    my $sth = $dbh->prepare($query);
1343
    $sth->execute(
1345
    $sth->execute(
1344
        $auser,           $branchcode,     $aqbooksellerid, $cost,
1346
        $auser,           $branchcode,     $aqbooksellerid, $cost,
Lines 1350-1356 sub ModSubscription { Link Here
1350
        $letter,          ($manualhistory ? $manualhistory : 0),
1352
        $letter,          ($manualhistory ? $manualhistory : 0),
1351
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1353
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1352
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1354
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1353
        $itemtype,        $previousitemtype, $mana_id,
1355
        $itemtype,        $previousitemtype, $mana_id,      $dateformat,
1354
        $subscriptionid
1356
        $subscriptionid
1355
    );
1357
    );
1356
    my $rows = $sth->rows;
1358
    my $rows = $sth->rows;
Lines 1367-1373 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1367
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1369
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1368
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1370
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1369
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1371
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1370
    $skip_serialseq, $itemtype, $previousitemtype);
1372
    $skip_serialseq, $itemtype, $previousitemtype, $dateformat);
1371
1373
1372
Create a new subscription with value given on input args.
1374
Create a new subscription with value given on input args.
1373
1375
Lines 1384-1390 sub NewSubscription { Link Here
1384
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1386
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1385
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1387
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1386
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1388
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1387
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
1389
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id,
1390
    $dateformat
1388
    ) = @_;
1391
    ) = @_;
1389
    my $dbh = C4::Context->dbh;
1392
    my $dbh = C4::Context->dbh;
1390
1393
Lines 1427-1432 sub NewSubscription { Link Here
1427
            itemtype          => $itemtype,
1430
            itemtype          => $itemtype,
1428
            previousitemtype  => $previousitemtype,
1431
            previousitemtype  => $previousitemtype,
1429
            mana_id           => $mana_id,
1432
            mana_id           => $mana_id,
1433
            pubdatepatternformat => $dateformat,
1430
        }
1434
        }
1431
    )->store;
1435
    )->store;
1432
    $subscription->discard_changes;
1436
    $subscription->discard_changes;
Lines 1459-1466 sub NewSubscription { Link Here
1459
    # calculate issue number
1463
    # calculate issue number
1460
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1464
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1461
1465
1466
    $dateformat //= '';
1462
    if ($serialseq eq "pubdate"){
1467
    if ($serialseq eq "pubdate"){
1463
        $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1468
        if ( $dateformat eq 'dmy' ){
1469
            $serialseq = dt_from_string( $firstacquidate )->strftime('%d %B %Y');
1470
        } elsif ( $dateformat eq 'mdy' ){
1471
            $serialseq = dt_from_string( $firstacquidate )->strftime('%B %d %Y');
1472
        } elsif ( $dateformat eq 'ydm' ){
1473
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %d %B');
1474
        } else {
1475
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1476
        }
1464
    }
1477
    }
1465
1478
1466
    Koha::Serial->new(
1479
    Koha::Serial->new(
Lines 1573-1578 sub NewIssue { Link Here
1573
1586
1574
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1587
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1575
1588
1589
    my $dateformat = $subscription->pubdatepatternformat;
1590
    if ($serialseq eq "pubdate"){
1591
        if ( $dateformat eq 'dmy' ){
1592
            $serialseq = dt_from_string( $publisheddate )->strftime('%d %B %Y');
1593
        } elsif ( $dateformat eq 'mdy' ){
1594
            $serialseq = dt_from_string( $publisheddate )->strftime('%B %d %Y');
1595
        } elsif ( $dateformat eq 'ydm' ){
1596
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %d %B');
1597
        } else {
1598
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %B %d');
1599
        }
1600
    }
1601
1576
    my $serial = Koha::Serial->new(
1602
    my $serial = Koha::Serial->new(
1577
        {
1603
        {
1578
            serialseq         => $serialseq,
1604
            serialseq         => $serialseq,
Lines 2353-2359 sub GetNextDate { Link Here
2353
2379
2354
    return unless $subscription and $publisheddate;
2380
    return unless $subscription and $publisheddate;
2355
2381
2356
2357
    if ($freqdata->{'unit'}) {
2382
    if ($freqdata->{'unit'}) {
2358
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2383
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2359
2384
(-)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 pubdatepatternformat == '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 pubdatepatternformat == '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 pubdatepatternformat == '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 pubdatepatternformat == '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
    pubdatepatternformat => $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