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

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

Return to bug 24903