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

(-)a/C4/Serials.pm (-27 / +32 lines)
Lines 907-913 sub GetNextSeq { Link Here
907
    $newlastvalue1 = $val->{lastvalue1};
907
    $newlastvalue1 = $val->{lastvalue1};
908
    $newlastvalue2 = $val->{lastvalue2};
908
    $newlastvalue2 = $val->{lastvalue2};
909
    $newlastvalue3 = $val->{lastvalue3};
909
    $newlastvalue3 = $val->{lastvalue3};
910
    $newlastvalue1 = $val->{lastvalue1};
911
910
912
    # check if we have to increase the new value.
911
    # check if we have to increase the new value.
913
    $newinnerloop1 = $val->{innerloop1} + 1;
912
    $newinnerloop1 = $val->{innerloop1} + 1;
Lines 916-923 sub GetNextSeq { Link Here
916
    $newlastvalue1 = $val->{setto1} if ( $newlastvalue1 > $val->{whenmorethan1} );    # reset counter if needed.
915
    $newlastvalue1 = $val->{setto1} if ( $newlastvalue1 > $val->{whenmorethan1} );    # reset counter if needed.
917
    $calculated =~ s/\{X\}/$newlastvalue1/g;
916
    $calculated =~ s/\{X\}/$newlastvalue1/g;
918
917
919
    $newlastvalue2 = $val->{lastvalue2};
920
921
    # check if we have to increase the new value.
918
    # check if we have to increase the new value.
922
    $newinnerloop2 = $val->{innerloop2} + 1;
919
    $newinnerloop2 = $val->{innerloop2} + 1;
923
    $newinnerloop2 = 0 if ( $newinnerloop2 >= $val->{every2} );
920
    $newinnerloop2 = 0 if ( $newinnerloop2 >= $val->{every2} );
Lines 958-986 the sequence in integer format Link Here
958
=cut
955
=cut
959
956
960
sub GetSeq {
957
sub GetSeq {
961
    my ($val) = @_;
962
    my $pattern = $val->{numberpattern};
963
    my @seasons          = ( 'nothing', 'Winter', 'Spring', 'Summer', 'Autumn' );
958
    my @seasons          = ( 'nothing', 'Winter', 'Spring', 'Summer', 'Autumn' );
964
    my @southern_seasons = ( '',        'Summer', 'Autumn', 'Winter', 'Spring' );
959
    my @southern_seasons = ( '',        'Summer', 'Autumn', 'Winter', 'Spring' );
965
    my $calculated       = $val->{numberingmethod};
966
    my $x                = $val->{'lastvalue1'};
967
    $calculated =~ s/\{X\}/$x/g;
968
    my $newlastvalue2 = $val->{'lastvalue2'};
969
960
970
    if ( $pattern == 6 ) {
961
    my ($val) = @_;
962
    my $pattern = $val->{numberpattern};
963
    my $calculated       = $val->{numberingmethod};
964
    my $x                = $val->{'lastvalue1'}; 
965
    my $y                = $val->{'lastvalue2'};
966
    my $z                = $val->{'lastvalue3'};
967
    
968
    if ( $pattern == 6 ) { ## Seasons
971
        if ( $val->{hemisphere} == 2 ) {
969
        if ( $val->{hemisphere} == 2 ) {
972
            my $newlastvalue2seq = $southern_seasons[$newlastvalue2];
970
            $y = $southern_seasons[$y];
973
            $calculated =~ s/\{Y\}/$newlastvalue2seq/g;
974
        } else {
971
        } else {
975
            my $newlastvalue2seq = $seasons[$newlastvalue2];
972
            $y = $seasons[$y];
976
            $calculated =~ s/\{Y\}/$newlastvalue2seq/g;
977
        }
973
        }
978
    } else {
979
        $calculated =~ s/\{Y\}/$newlastvalue2/g;
980
    }
974
    }
981
    my $z = $val->{'lastvalue3'};
975
976
    $calculated =~ s/\{X\}/$x/g;
977
    $calculated =~ s/\{Y\}/$y/g;
982
    $calculated =~ s/\{Z\}/$z/g;
978
    $calculated =~ s/\{Z\}/$z/g;
983
    return $calculated;
979
980
    my $x_label = $val->{'serialseq_x_label'};
981
    my $y_label = $val->{'serialseq_y_label'};
982
    my $z_label = $val->{'serialseq_z_label'};
983
    $calculated =~ s/\{XL\}/$x_label/g;
984
    $calculated =~ s/\{YL\}/$y_label/g;
985
    $calculated =~ s/\{ZL\}/$z_label/g;
986
987
    return ( $calculated, $x, $y, $z );
984
}
988
}
985
989
986
=head2 GetExpirationDate
990
=head2 GetExpirationDate
Lines 1149-1155 sub ModSerialStatus { Link Here
1149
1153
1150
        # next date (calculated from actual date & frequency parameters)
1154
        # next date (calculated from actual date & frequency parameters)
1151
        my $nextpublisheddate = GetNextDate( $publisheddate, $val );
1155
        my $nextpublisheddate = GetNextDate( $publisheddate, $val );
1152
        NewIssue( $newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextpublisheddate, $nextpublisheddate );
1156
        NewIssue( $newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextpublisheddate, $nextpublisheddate, undef, $newlastvalue1, $newlastvalue2, $newlastvalue3 );
1153
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1157
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1154
                    WHERE  subscriptionid = ?";
1158
                    WHERE  subscriptionid = ?";
1155
        $sth = $dbh->prepare($query);
1159
        $sth = $dbh->prepare($query);
Lines 1360-1373 sub NewSubscription { Link Here
1360
    my $val = $sth->fetchrow_hashref;
1364
    my $val = $sth->fetchrow_hashref;
1361
1365
1362
    # calculate issue number
1366
    # calculate issue number
1363
    my $serialseq = GetSeq($val);
1367
    my ( $serialseq, $x, $y, $z ) = GetSeq($val);
1364
    $query = qq|
1368
    $query = qq|
1365
        INSERT INTO serial
1369
        INSERT INTO serial
1366
            (serialseq,subscriptionid,biblionumber,status, planneddate, publisheddate)
1370
            (serialseq,serialseq_x,serialseq_y,serialseq_z,subscriptionid,biblionumber,status, planneddate, publisheddate)
1367
        VALUES (?,?,?,?,?,?)
1371
        VALUES (?,?,?,?,?,?,?,?,?)
1368
    |;
1372
    |;
1369
    $sth = $dbh->prepare($query);
1373
    $sth = $dbh->prepare($query);
1370
    $sth->execute( "$serialseq", $subscriptionid, $biblionumber, 1, $firstacquidate, $firstacquidate );
1374
    $sth->execute( $serialseq, $x, $y, $z, $subscriptionid, $biblionumber, 1, $firstacquidate, $firstacquidate );
1371
1375
1372
    logaction( "SERIAL", "ADD", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
1376
    logaction( "SERIAL", "ADD", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
1373
1377
Lines 1459-1475 returns the serial id Link Here
1459
=cut
1463
=cut
1460
1464
1461
sub NewIssue {
1465
sub NewIssue {
1462
    my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, $publisheddate, $notes ) = @_;
1466
    my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, $publisheddate, $notes, $x, $y, $z ) = @_;
1467
    warn "NewIssue( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, $publisheddate, $notes, $x, $y, $z )";
1463
    ### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ?
1468
    ### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ?
1464
1469
1465
    my $dbh   = C4::Context->dbh;
1470
    my $dbh   = C4::Context->dbh;
1466
    my $query = qq|
1471
    my $query = qq|
1467
        INSERT INTO serial
1472
        INSERT INTO serial
1468
            (serialseq,subscriptionid,biblionumber,status,publisheddate,planneddate,notes)
1473
            (serialseq,subscriptionid,biblionumber,status,publisheddate,planneddate,notes,serialseq_x,serialseq_y,serialseq_z)
1469
        VALUES (?,?,?,?,?,?,?)
1474
        VALUES (?,?,?,?,?,?,?,?,?,?)
1470
    |;
1475
    |;
1471
    my $sth = $dbh->prepare($query);
1476
    my $sth = $dbh->prepare($query);
1472
    $sth->execute( $serialseq, $subscriptionid, $biblionumber, $status, $publisheddate, $planneddate, $notes );
1477
    $sth->execute( $serialseq, $subscriptionid, $biblionumber, $status, $publisheddate, $planneddate, $notes, $x, $y, $z );
1473
    my $serialid = $dbh->{'mysql_insertid'};
1478
    my $serialid = $dbh->{'mysql_insertid'};
1474
    $query = qq|
1479
    $query = qq|
1475
        SELECT missinglist,recievedlist
1480
        SELECT missinglist,recievedlist
(-)a/serials/serials-collection.pl (-2 / +1 lines)
Lines 79-85 if($op eq 'gennext' && @subscriptionid){ Link Here
79
	     my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription );
79
	     my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription );
80
	     ## Creating the new issue
80
	     ## Creating the new issue
81
	     NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
81
	     NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
82
	             1, $nextpublisheddate, $nextpublisheddate );
82
	             1, $nextpublisheddate, $nextpublisheddate, undef, $newlastvalue1, $newlastvalue2, $newlastvalue3 );
83
83
84
	     ## Updating the subscription seq status
84
	     ## Updating the subscription seq status
85
	     my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
85
	     my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
86
- 

Return to bug 8956