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

(-)a/C4/Serials.pm (-23 / +47 lines)
Lines 872-879 sub GetNextSeq { Link Here
872
872
873
    my $calculated = "";
873
    my $calculated = "";
874
    my $numberingmethod = "";
874
    my $numberingmethod = "";
875
    my $dateformat = $subscription->{pubdatepatternformat};
875
    if ($pattern eq "pubdate"){
876
    if ($pattern eq "pubdate"){
876
        $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
877
        if ( $dateformat eq 'dmy' ){
878
            $calculated = dt_from_string( $planneddate )->strftime( '%d %B %Y' );
879
        } elsif ( $dateformat eq 'mdy' ){
880
            $calculated = dt_from_string( $planneddate )->strftime( '%B %d %Y' );
881
        } elsif ( $dateformat eq 'ydm' ){
882
            $calculated = dt_from_string( $planneddate )->strftime( '%Y %d %B' );
883
        } else {
884
            $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
885
        }
877
    } else {
886
    } else {
878
        $numberingmethod = $pattern->{numberingmethod};
887
        $numberingmethod = $pattern->{numberingmethod};
879
    }
888
    }
Lines 1168-1193 sub ModSerialStatus { Link Here
1168
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1177
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1169
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1178
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1170
1179
1171
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1);
1180
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency);
1172
        my ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1181
        my ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1173
             $newinnerloop1, $newinnerloop2, $newinnerloop3 );
1182
             $newinnerloop1, $newinnerloop2, $newinnerloop3 );
1174
1183
1184
        # next issue number
1175
        if (!defined $pattern){
1185
        if (!defined $pattern){
1176
            $pattern = "pubdate";
1186
            $pattern = "pubdate";
1177
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1187
            $newserialseq = "pubdate";
1178
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $nextpublisheddate );
1179
        } else {
1188
        } else {
1180
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1189
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1181
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
1190
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
1182
        }
1191
        }
1183
1192
1184
        # next issue number
1185
        my (
1186
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1187
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1188
          )
1189
          = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
1190
1191
        # next date (calculated from actual date & frequency parameters)
1193
        # next date (calculated from actual date & frequency parameters)
1192
        my $nextpubdate = $nextpublisheddate;
1194
        my $nextpubdate = $nextpublisheddate;
1193
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1195
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
Lines 1336-1342 sub ModSubscription { Link Here
1336
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1338
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1337
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1339
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1338
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1340
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1339
    $itemtype, $previousitemtype
1341
    $itemtype, $previousitemtype, $mana_id, $dateformat
1340
    ) = @_;
1342
    ) = @_;
1341
1343
1342
    my $dbh   = C4::Context->dbh;
1344
    my $dbh   = C4::Context->dbh;
Lines 1349-1357 sub ModSubscription { Link Here
1349
            callnumber=?, notes=?, letter=?, manualhistory=?,
1351
            callnumber=?, notes=?, letter=?, manualhistory=?,
1350
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1352
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1351
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1353
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1352
            skip_serialseq=?, itemtype=?, previousitemtype=?
1354
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?, 
1355
            pubdatepatternformat=?
1353
        WHERE subscriptionid = ?";
1356
        WHERE subscriptionid = ?";
1354
1355
    my $sth = $dbh->prepare($query);
1357
    my $sth = $dbh->prepare($query);
1356
    $sth->execute(
1358
    $sth->execute(
1357
        $auser,           $branchcode,     $aqbooksellerid, $cost,
1359
        $auser,           $branchcode,     $aqbooksellerid, $cost,
Lines 1363-1369 sub ModSubscription { Link Here
1363
        $letter,          ($manualhistory ? $manualhistory : 0),
1365
        $letter,          ($manualhistory ? $manualhistory : 0),
1364
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1366
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1365
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1367
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1366
        $itemtype,        $previousitemtype,
1368
        $itemtype,        $previousitemtype, $mana_id,      $dateformat,
1367
        $subscriptionid
1369
        $subscriptionid
1368
    );
1370
    );
1369
    my $rows = $sth->rows;
1371
    my $rows = $sth->rows;
Lines 1380-1386 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1380
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1382
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1381
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1383
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1382
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1384
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1383
    $skip_serialseq, $itemtype, $previousitemtype);
1385
    $skip_serialseq, $itemtype, $previousitemtype, $dateformat);
1384
1386
1385
Create a new subscription with value given on input args.
1387
Create a new subscription with value given on input args.
1386
1388
Lines 1397-1403 sub NewSubscription { Link Here
1397
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1399
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1398
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1400
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1399
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1401
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1400
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
1402
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id,
1403
    $dateformat
1401
    ) = @_;
1404
    ) = @_;
1402
    my $dbh = C4::Context->dbh;
1405
    my $dbh = C4::Context->dbh;
1403
1406
Lines 1411-1418 sub NewSubscription { Link Here
1411
            irregularity, numberpattern, locale, callnumber,
1414
            irregularity, numberpattern, locale, callnumber,
1412
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1415
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1413
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1416
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1414
            itemtype, previousitemtype, mana_id)
1417
            itemtype, previousitemtype, mana_id, pubdatepatternformat)
1415
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?)
1418
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1416
        |;
1419
        |;
1417
    my $sth = $dbh->prepare($query);
1420
    my $sth = $dbh->prepare($query);
1418
    $sth->execute(
1421
    $sth->execute(
Lines 1423-1429 sub NewSubscription { Link Here
1423
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1426
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1424
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1427
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1425
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1428
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1426
        $itemtype, $previousitemtype, $mana_id
1429
        $itemtype, $previousitemtype, $mana_id, $dateformat
1427
    );
1430
    );
1428
1431
1429
    my $subscriptionid = $dbh->{'mysql_insertid'};
1432
    my $subscriptionid = $dbh->{'mysql_insertid'};
Lines 1454-1461 sub NewSubscription { Link Here
1454
    # calculate issue number
1457
    # calculate issue number
1455
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1458
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1456
1459
1460
    $dateformat //= '';
1457
    if ($serialseq eq "pubdate"){
1461
    if ($serialseq eq "pubdate"){
1458
        $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1462
        if ( $dateformat eq 'dmy' ){
1463
            $serialseq = dt_from_string( $firstacquidate )->strftime('%d %B %Y');
1464
        } elsif ( $dateformat eq 'mdy' ){
1465
            $serialseq = dt_from_string( $firstacquidate )->strftime('%B %d %Y');
1466
        } elsif ( $dateformat eq 'ydm' ){
1467
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %d %B');
1468
        } else {
1469
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1470
        }
1459
    }
1471
    }
1460
1472
1461
    Koha::Serial->new(
1473
    Koha::Serial->new(
Lines 1549-1555 sub ReNewSubscription { Link Here
1549
1561
1550
=head2 NewIssue
1562
=head2 NewIssue
1551
1563
1552
NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate,  $notes)
1564
NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes)
1553
1565
1554
Create a new issue stored on the database.
1566
Create a new issue stored on the database.
1555
Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription.
1567
Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription.
Lines 1568-1573 sub NewIssue { Link Here
1568
1580
1569
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1581
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1570
1582
1583
    my $dateformat = $subscription->pubdatepatternformat;
1584
    if ($serialseq eq "pubdate"){
1585
        if ( $dateformat eq 'dmy' ){
1586
            $serialseq = dt_from_string( $publisheddate )->strftime('%d %B %Y');
1587
        } elsif ( $dateformat eq 'mdy' ){
1588
            $serialseq = dt_from_string( $publisheddate )->strftime('%B %d %Y');
1589
        } elsif ( $dateformat eq 'ydm' ){
1590
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %d %B');
1591
        } else {
1592
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %B %d');
1593
        }
1594
    }
1595
1571
    my $serial = Koha::Serial->new(
1596
    my $serial = Koha::Serial->new(
1572
        {
1597
        {
1573
            serialseq         => $serialseq,
1598
            serialseq         => $serialseq,
Lines 2349-2355 sub GetNextDate { Link Here
2349
2374
2350
    return unless $subscription and $publisheddate;
2375
    return unless $subscription and $publisheddate;
2351
2376
2352
2353
    if ($freqdata->{'unit'}) {
2377
    if ($freqdata->{'unit'}) {
2354
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2378
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2355
2379
(-)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
466
459
# You can replace this text with custom content, and it will be preserved on regeneration
467
# You can replace this text with custom content, and it will be preserved on regeneration
(-)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 298-306 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
298
                                    <li>
298
                                    <li>
299
                                        <label for="numberpattern" class="required">Numbering pattern:</label>
299
                                        <label for="numberpattern" class="required">Numbering pattern:</label>
300
                                        <select name="numbering_pattern" size="1" id="numberpattern" class="required" required="required">
300
                                        <select name="numbering_pattern" size="1" id="numberpattern" class="required" required="required">
301
                                            <option value="">-- please choose --</option>
301
                                            [% IF subscriptionid %]
302
                                                <option value="">-- please choose --</option>
303
                                            [% ELSE %]
304
                                                <option value="" selected="selected">-- please choose --</option>
305
                                            [% END %]
306
                                            [% SET pattern = 0 %]
302
                                            [% FOREACH numberpattern IN numberpatterns %]
307
                                            [% FOREACH numberpattern IN numberpatterns %]
303
                                                [% IF (numberpattern.selected) %]
308
                                                [% IF (numberpattern.selected) %]
309
                                                    [% pattern = 1 %]
304
                                                    <option value="[% numberpattern.id | html %]" selected="selected">
310
                                                    <option value="[% numberpattern.id | html %]" selected="selected">
305
                                                [% ELSE %]
311
                                                [% ELSE %]
306
                                                    <option value="[% numberpattern.id | html %]">
312
                                                    <option value="[% numberpattern.id | html %]">
Lines 308-314 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
308
                                                    [% numberpattern.label | html %]
314
                                                    [% numberpattern.label | html %]
309
                                                </option>
315
                                                </option>
310
                                            [% END %]
316
                                            [% END %]
311
                                            <option value="0">Use publication date</option>
317
                                            [% IF pattern == 0 and subscriptionid %]
318
                                                <option value="0" selected="selected">Use publication date</option>
319
                                            [% ELSE %]
320
                                                <option value="0">Use publication date</option>
321
                                            [% END %]
322
                                        </select>
323
                                        <select name="date_format" size="1" id="date_format">
324
                                            <option value="">-- choose date format --</option>
325
                                            [% IF dateformat == 'dmy' %]
326
                                                <option value="dmy" selected="selected">Day Month Year</option>
327
                                            [% ELSE %]
328
                                                <option value="dmy">Day Month Year</option>
329
                                            [% END %]
330
                                            [% IF dateformat == 'mdy' %]
331
                                                <option value="mdy" selected="selected">Month Day Year</option>
332
                                            [% ELSE %]
333
                                                <option value="mdy">Month Day Year</option>
334
                                            [% END %]
335
                                            [% IF dateformat == 'ymd' %]
336
                                                <option value="ymd" selected="selected">Year Month Day</option>
337
                                            [% ELSE %]
338
                                                <option value="ymd">Year Month Day</option>
339
                                            [% END %]
340
                                            [% IF dateformat == 'ydm' %]
341
                                                <option value="ydm" selected="selected">Year Day Month</option>
342
                                            [% ELSE %]
343
                                                <option value="ydm">Year Day Month</option>
344
                                            [% END %]
312
                                        </select>
345
                                        </select>
313
                                    </li>
346
                                    </li>
314
                                    <li>
347
                                    <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-1 / +1 lines)
Lines 177-183 Link Here
177
                [% IF ( numberpattern ) %]
177
                [% IF ( numberpattern ) %]
178
                    [% numberpattern.label | html %]
178
                    [% numberpattern.label | html %]
179
                [% ELSE %]
179
                [% ELSE %]
180
                    Uses publication date
180
                    Uses publication date - [% dateformat %] format
181
                [% END %]
181
                [% END %]
182
            </li>
182
            </li>
183
            [% IF ( numberpattern ) %]
183
            [% 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 525-530 function mana_use(mana_id){ Link Here
525
}
525
}
526
526
527
function usedatepattern() {
527
function usedatepattern() {
528
    $("#date_format").show();
528
    $("#more_options").hide();
529
    $("#more_options").hide();
529
    clearAdvancedPattern();
530
    clearAdvancedPattern();
530
    if ($("#advancedpredictionpattern").is(":visible")){
531
    if ($("#advancedpredictionpattern").is(":visible")){
Lines 539-544 $(document).ready(function() { Link Here
539
    }
540
    }
540
    $("#displayexample").hide();
541
    $("#displayexample").hide();
541
    $("#mana_search_result").modal("hide");
542
    $("#mana_search_result").modal("hide");
543
544
    $("#date_format").hide();
545
    if ($("select#numberpattern").val() == "0"){
546
        $("#date_format").show();
547
    }
548
542
    $("#aqbooksellerid").on('keypress', function(e) {
549
    $("#aqbooksellerid").on('keypress', function(e) {
543
        if (e.keyCode == 13) {
550
        if (e.keyCode == 13) {
544
            e.preventDefault();
551
            e.preventDefault();
Lines 558-568 $(document).ready(function() { Link Here
558
    });
565
    });
559
    $("select#numberpattern").change(function(){
566
    $("select#numberpattern").change(function(){
560
        patternneedtobetested = 1;
567
        patternneedtobetested = 1;
561
        console.log($("select#numberpattern").val());
562
        if ($("select#numberpattern").val() == "0"){
568
        if ($("select#numberpattern").val() == "0"){
563
            usedatepattern();
569
            usedatepattern();
564
        } else {
570
        } else {
565
            numberpatternload();
571
            numberpatternload();
572
            $("#date_format").hide();
573
            $("#date_format").val("");
566
        }
574
        }
567
    });
575
    });
568
    $("#subtype").change(function(){
576
    $("#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 137-143 if (@subscriptionid){ Link Here
137
    $subs->{frequency} = $frequency;
146
    $subs->{frequency} = $frequency;
138
    my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
147
    my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
139
    if (!defined $numberpattern){
148
    if (!defined $numberpattern){
140
        $numberpattern->{label} = "Uses publication date";
149
        $numberpattern->{label} = "Uses publication date - $subs->{pubdatepatternformat} format";
141
    }
150
    }
142
    $subs->{numberpattern} = $numberpattern;
151
    $subs->{numberpattern} = $numberpattern;
143
    $subs->{'hasRouting'} = check_routing($subscriptionid);
152
    $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 165-170 $template->param( Link Here
165
    typeloop                 => \@typearg,
165
    typeloop                 => \@typearg,
166
    previoustypeloop         => \@previoustypearg,
166
    previoustypeloop         => \@previoustypearg,
167
    locations_loop=>$locations_loop,
167
    locations_loop=>$locations_loop,
168
    dateformat => $subs->{pubdatepatternformat},
168
);
169
);
169
170
170
# prepare template variables common to all $op conditions:
171
# prepare template variables common to all $op conditions:
Lines 366-371 sub redirect_add_subscription { Link Here
366
    if ($numberpattern == "0"){ # using publication date as numbering pattern
367
    if ($numberpattern == "0"){ # using publication date as numbering pattern
367
        $numberpattern = undef;
368
        $numberpattern = undef;
368
    }
369
    }
370
    my $dateformat = $query->param('date_format');
369
371
370
    my $subscriptionid = NewSubscription(
372
    my $subscriptionid = NewSubscription(
371
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
373
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
Lines 375-381 sub redirect_add_subscription { Link Here
375
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
377
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
376
        $manualhistory, $internalnotes, $serialsadditems,
378
        $manualhistory, $internalnotes, $serialsadditems,
377
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
379
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
378
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
380
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $dateformat
379
    );
381
    );
380
    if ( (C4::Context->preference('Mana')) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
382
    if ( (C4::Context->preference('Mana')) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
381
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
383
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
Lines 477-482 sub redirect_mod_subscription { Link Here
477
    if ($numberpattern == "0"){ # using publication date as numbering pattern
479
    if ($numberpattern == "0"){ # using publication date as numbering pattern
478
        $numberpattern = undef;
480
        $numberpattern = undef;
479
    }
481
    }
482
    my $dateformat = $query->param('date_format');
480
483
481
    ModSubscription(
484
    ModSubscription(
482
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
485
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
Lines 486-492 sub redirect_mod_subscription { Link Here
486
        $status, $biblionumber, $callnumber, $notes, $letter,
489
        $status, $biblionumber, $callnumber, $notes, $letter,
487
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
490
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
488
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
491
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
489
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
492
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $dateformat
490
    );
493
    );
491
494
492
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
495
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
(-)a/serials/subscription-detail.pl (-1 / +2 lines)
Lines 125-130 my @irregular_issues = split /;/, $subs->{irregularity}; Link Here
125
125
126
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
126
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
127
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
127
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
128
my $dateformat = $subs->{pubdatepatternformat};
128
129
129
my $default_bib_view = get_default_view();
130
my $default_bib_view = get_default_view();
130
131
Lines 162-167 $template->param( Link Here
162
    cannotedit => (not C4::Serials::can_edit_subscription( $subs )),
163
    cannotedit => (not C4::Serials::can_edit_subscription( $subs )),
163
    frequency => $frequency,
164
    frequency => $frequency,
164
    numberpattern => $numberpattern,
165
    numberpattern => $numberpattern,
166
    dateformat      => $dateformat,
165
    has_X           => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
167
    has_X           => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
166
    has_Y           => ($numberpattern->{'numberingmethod'} =~ /{Y}/) ? 1 : 0,
168
    has_Y           => ($numberpattern->{'numberingmethod'} =~ /{Y}/) ? 1 : 0,
167
    has_Z           => ($numberpattern->{'numberingmethod'} =~ /{Z}/) ? 1 : 0,
169
    has_Z           => ($numberpattern->{'numberingmethod'} =~ /{Z}/) ? 1 : 0,
168
- 

Return to bug 22188