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

(-)a/C4/Serials.pm (-8 / +22 lines)
Lines 1118-1136 sub ModSerialStatus { Link Here
1118
            my ( $missinglist, $recievedlist ) = $sth->fetchrow;
1118
            my ( $missinglist, $recievedlist ) = $sth->fetchrow;
1119
1119
1120
            if ( $status == ARRIVED || ($oldstatus == ARRIVED && $status != ARRIVED) ) {
1120
            if ( $status == ARRIVED || ($oldstatus == ARRIVED && $status != ARRIVED) ) {
1121
                $recievedlist .= "; $serialseq"
1121
                $recievedlist = _handle_seqno($serialseq, $recievedlist);
1122
                    if ($recievedlist !~ /(^|;)\s*$serialseq(?=;|$)/);
1123
            }
1122
            }
1124
1123
1125
            # in case serial has been previously marked as missing
1124
            # in case serial has been previously marked as missing
1126
            if (grep /$status/, (EXPECTED, ARRIVED, LATE, CLAIMED)) {
1125
            if (grep /$status/, (EXPECTED, ARRIVED, LATE, CLAIMED)) {
1127
                $missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g;
1126
                $missinglist = _handle_seqno($serialseq, $missinglist, 'REMOVE');
1128
            }
1127
            }
1129
1128
1130
            $missinglist .= "; $serialseq"
1129
            $missinglist = _handle_seqno($serialseq, $missinglist) if grep { $_ == $status } MISSING_STATUSES;
1131
                if ( ( grep { $_ == $status } ( MISSING_STATUSES ) ) && ( $missinglist !~/(^|;)\s*$serialseq(?=;|$)/ ) );
1130
            $missinglist .= "; not issued $serialseq" if $status == NOT_ISSUED and not _handle_seqno($serialseq, $missinglist, 'CHECK');
1132
            $missinglist .= "; not issued $serialseq"
1133
                if ( $status == NOT_ISSUED && $missinglist !~ /(^|;)\s*$serialseq(?=;|$)/ );
1134
1131
1135
            $query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE  subscriptionid=?";
1132
            $query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE  subscriptionid=?";
1136
            $sth   = $dbh->prepare($query);
1133
            $sth   = $dbh->prepare($query);
Lines 1173-1178 sub ModSerialStatus { Link Here
1173
    return;
1170
    return;
1174
}
1171
}
1175
1172
1173
sub _handle_seqno {
1174
# Adds or removes seqno from list when needed; returns list
1175
# Or checks and returns true when present
1176
1177
    my ( $seq, $list, $op ) = @_; # op = ADD | REMOVE | CHECK (default: ADD)
1178
    my $seq_r = $seq;
1179
    $seq_r =~ s/([()])/\\$1/g; # Adjust disturbing parentheses for regex, maybe extend in future
1180
1181
    if( !$op or $op eq 'ADD' ) {
1182
        $list .= "; $seq" if $list !~ /(^|;)\s*$seq_r(?=;|$)/;
1183
    } elsif( $op eq 'REMOVE' ) {
1184
        $list=~ s/(^|;)\s*(not issued )?$seq_r(?=;|$)//g;
1185
    } else { # CHECK
1186
        return $list =~ /(^|;)\s*$seq_r(?=;|$)/ ? 1 : q{};
1187
    }
1188
    return $list;
1189
}
1190
1176
=head2 GetNextExpected
1191
=head2 GetNextExpected
1177
1192
1178
$nextexpected = GetNextExpected($subscriptionid)
1193
$nextexpected = GetNextExpected($subscriptionid)
1179
- 

Return to bug 24903