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

(-)a/C4/Serials.pm (-23 / +47 lines)
Lines 865-872 sub GetNextSeq { Link Here
865
865
866
    my $calculated = "";
866
    my $calculated = "";
867
    my $numberingmethod = "";
867
    my $numberingmethod = "";
868
    my $dateformat = $subscription->{pubdatepatternformat};
868
    if ($pattern eq "pubdate"){
869
    if ($pattern eq "pubdate"){
869
        $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
870
        if ( $dateformat eq 'dmy' ){
871
            $calculated = dt_from_string( $planneddate )->strftime( '%d %B %Y' );
872
        } elsif ( $dateformat eq 'mdy' ){
873
            $calculated = dt_from_string( $planneddate )->strftime( '%B %d %Y' );
874
        } elsif ( $dateformat eq 'ydm' ){
875
            $calculated = dt_from_string( $planneddate )->strftime( '%Y %d %B' );
876
        } else {
877
            $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
878
        }
870
    } else {
879
    } else {
871
        $numberingmethod = $pattern->{numberingmethod};
880
        $numberingmethod = $pattern->{numberingmethod};
872
    }
881
    }
Lines 1161-1186 sub ModSerialStatus { Link Here
1161
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1170
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1162
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1171
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1163
1172
1164
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1);
1173
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency);
1165
        my ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1174
        my ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1166
             $newinnerloop1, $newinnerloop2, $newinnerloop3 );
1175
             $newinnerloop1, $newinnerloop2, $newinnerloop3 );
1167
1176
1177
        # next issue number
1168
        if (!defined $pattern){
1178
        if (!defined $pattern){
1169
            $pattern = "pubdate";
1179
            $pattern = "pubdate";
1170
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1180
            $newserialseq = "pubdate";
1171
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $nextpublisheddate );
1172
        } else {
1181
        } else {
1173
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1182
            ( $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1174
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
1183
              $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
1175
        }
1184
        }
1176
1185
1177
        # next issue number
1178
        my (
1179
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1180
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1181
          )
1182
          = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
1183
1184
        # next date (calculated from actual date & frequency parameters)
1186
        # next date (calculated from actual date & frequency parameters)
1185
        my $nextpubdate = $nextpublisheddate;
1187
        my $nextpubdate = $nextpublisheddate;
1186
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1188
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
Lines 1329-1335 sub ModSubscription { Link Here
1329
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1331
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1330
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1332
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1331
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1333
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1332
    $itemtype, $previousitemtype, $mana_id
1334
    $itemtype, $previousitemtype, $mana_id, $dateformat
1333
    ) = @_;
1335
    ) = @_;
1334
1336
1335
    my $dbh   = C4::Context->dbh;
1337
    my $dbh   = C4::Context->dbh;
Lines 1342-1350 sub ModSubscription { Link Here
1342
            callnumber=?, notes=?, letter=?, manualhistory=?,
1344
            callnumber=?, notes=?, letter=?, manualhistory=?,
1343
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1345
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1344
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1346
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1345
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?
1347
            skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?,
1348
            pubdatepatternformat=?
1346
        WHERE subscriptionid = ?";
1349
        WHERE subscriptionid = ?";
1347
1348
    my $sth = $dbh->prepare($query);
1350
    my $sth = $dbh->prepare($query);
1349
    $sth->execute(
1351
    $sth->execute(
1350
        $auser,           $branchcode,     $aqbooksellerid, $cost,
1352
        $auser,           $branchcode,     $aqbooksellerid, $cost,
Lines 1356-1362 sub ModSubscription { Link Here
1356
        $letter,          ($manualhistory ? $manualhistory : 0),
1358
        $letter,          ($manualhistory ? $manualhistory : 0),
1357
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1359
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1358
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1360
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1359
        $itemtype,        $previousitemtype, $mana_id,
1361
        $itemtype,        $previousitemtype, $mana_id,      $dateformat,
1360
        $subscriptionid
1362
        $subscriptionid
1361
    );
1363
    );
1362
    my $rows = $sth->rows;
1364
    my $rows = $sth->rows;
Lines 1373-1379 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1373
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1375
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1374
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1376
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1375
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1377
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1376
    $skip_serialseq, $itemtype, $previousitemtype);
1378
    $skip_serialseq, $itemtype, $previousitemtype, $dateformat);
1377
1379
1378
Create a new subscription with value given on input args.
1380
Create a new subscription with value given on input args.
1379
1381
Lines 1390-1396 sub NewSubscription { Link Here
1390
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1392
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1391
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1393
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1392
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1394
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1393
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
1395
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id,
1396
    $dateformat
1394
    ) = @_;
1397
    ) = @_;
1395
    my $dbh = C4::Context->dbh;
1398
    my $dbh = C4::Context->dbh;
1396
1399
Lines 1404-1411 sub NewSubscription { Link Here
1404
            irregularity, numberpattern, locale, callnumber,
1407
            irregularity, numberpattern, locale, callnumber,
1405
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1408
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1406
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1409
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1407
            itemtype, previousitemtype, mana_id)
1410
            itemtype, previousitemtype, mana_id, pubdatepatternformat)
1408
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?)
1411
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1409
        |;
1412
        |;
1410
    my $sth = $dbh->prepare($query);
1413
    my $sth = $dbh->prepare($query);
1411
    $sth->execute(
1414
    $sth->execute(
Lines 1416-1422 sub NewSubscription { Link Here
1416
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1419
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1417
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1420
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1418
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1421
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1419
        $itemtype, $previousitemtype, $mana_id
1422
        $itemtype, $previousitemtype, $mana_id, $dateformat
1420
    );
1423
    );
1421
1424
1422
    my $subscriptionid = $dbh->{'mysql_insertid'};
1425
    my $subscriptionid = $dbh->{'mysql_insertid'};
Lines 1447-1454 sub NewSubscription { Link Here
1447
    # calculate issue number
1450
    # calculate issue number
1448
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1451
    my $serialseq = GetSeq($subscription, $pattern) || q{};
1449
1452
1453
    $dateformat //= '';
1450
    if ($serialseq eq "pubdate"){
1454
    if ($serialseq eq "pubdate"){
1451
        $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1455
        if ( $dateformat eq 'dmy' ){
1456
            $serialseq = dt_from_string( $firstacquidate )->strftime('%d %B %Y');
1457
        } elsif ( $dateformat eq 'mdy' ){
1458
            $serialseq = dt_from_string( $firstacquidate )->strftime('%B %d %Y');
1459
        } elsif ( $dateformat eq 'ydm' ){
1460
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %d %B');
1461
        } else {
1462
            $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
1463
        }
1452
    }
1464
    }
1453
1465
1454
    Koha::Serial->new(
1466
    Koha::Serial->new(
Lines 1542-1548 sub ReNewSubscription { Link Here
1542
1554
1543
=head2 NewIssue
1555
=head2 NewIssue
1544
1556
1545
NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate,  $notes)
1557
NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes)
1546
1558
1547
Create a new issue stored on the database.
1559
Create a new issue stored on the database.
1548
Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription.
1560
Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription.
Lines 1561-1566 sub NewIssue { Link Here
1561
1573
1562
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1574
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1563
1575
1576
    my $dateformat = $subscription->pubdatepatternformat;
1577
    if ($serialseq eq "pubdate"){
1578
        if ( $dateformat eq 'dmy' ){
1579
            $serialseq = dt_from_string( $publisheddate )->strftime('%d %B %Y');
1580
        } elsif ( $dateformat eq 'mdy' ){
1581
            $serialseq = dt_from_string( $publisheddate )->strftime('%B %d %Y');
1582
        } elsif ( $dateformat eq 'ydm' ){
1583
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %d %B');
1584
        } else {
1585
            $serialseq = dt_from_string( $publisheddate )->strftime('%Y %B %d');
1586
        }
1587
    }
1588
1564
    my $serial = Koha::Serial->new(
1589
    my $serial = Koha::Serial->new(
1565
        {
1590
        {
1566
            serialseq         => $serialseq,
1591
            serialseq         => $serialseq,
Lines 2340-2346 sub GetNextDate { Link Here
2340
2365
2341
    return unless $subscription and $publisheddate;
2366
    return unless $subscription and $publisheddate;
2342
2367
2343
2344
    if ($freqdata->{'unit'}) {
2368
    if ($freqdata->{'unit'}) {
2345
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2369
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2346
2370
(-)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 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 168-174 Link Here
168
                [% IF ( numberpattern ) %]
168
                [% IF ( numberpattern ) %]
169
                    [% numberpattern.label | html %]
169
                    [% numberpattern.label | html %]
170
                [% ELSE %]
170
                [% ELSE %]
171
                    Uses publication date
171
                    Uses publication date - [% dateformat %] format
172
                [% END %]
172
                [% END %]
173
            </li>
173
            </li>
174
            [% IF ( numberpattern ) %]
174
            [% 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 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')) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
387
    if ( (C4::Context->preference('Mana')) 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