Lines 1137-1167
sub ModSerialStatus {
Link Here
|
1137 |
$query = "SELECT missinglist,recievedlist FROM subscriptionhistory WHERE subscriptionid=?"; |
1137 |
$query = "SELECT missinglist,recievedlist FROM subscriptionhistory WHERE subscriptionid=?"; |
1138 |
$sth = $dbh->prepare($query); |
1138 |
$sth = $dbh->prepare($query); |
1139 |
$sth->execute($subscriptionid); |
1139 |
$sth->execute($subscriptionid); |
1140 |
my ( $missinglist, $recievedlist ) = $sth->fetchrow; |
1140 |
my ($missinglist, $recievedlist)= _update_missing_and_received_list($sth->fetchrow,$serialseq,$status); |
1141 |
|
|
|
1142 |
#Arrived: add to received list, remove from missing |
1143 |
if($status==2) { |
1144 |
$recievedlist .= "; $serialseq" |
1145 |
if $recievedlist!~/(^|;)\s*$serialseq(?=;|$)/; |
1146 |
$missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1147 |
} |
1148 |
#Expected,late,claimed: remove optionally from received+missing |
1149 |
if (grep /$status/, (1,3,7)) { |
1150 |
$recievedlist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1151 |
$missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1152 |
} |
1153 |
#Missing, not available: add to missing, remove from received |
1154 |
#No longer putting additional text into missing field |
1155 |
if($status==4 || $status==5) { |
1156 |
$missinglist .= "; $serialseq" |
1157 |
if $missinglist!~/(^|;)\s*$serialseq(?=;|$)/; |
1158 |
$recievedlist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1159 |
} |
1160 |
|
1161 |
$query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE subscriptionid=?"; |
1141 |
$query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE subscriptionid=?"; |
1162 |
$sth = $dbh->prepare($query); |
1142 |
$sth = $dbh->prepare($query); |
1163 |
$recievedlist =~ s/^; //; |
|
|
1164 |
$missinglist =~ s/^; //; |
1165 |
$sth->execute( $recievedlist, $missinglist, $subscriptionid ); |
1143 |
$sth->execute( $recievedlist, $missinglist, $subscriptionid ); |
1166 |
} |
1144 |
} |
1167 |
} |
1145 |
} |
Lines 1196-1201
sub ModSerialStatus {
Link Here
|
1196 |
return; |
1174 |
return; |
1197 |
} |
1175 |
} |
1198 |
|
1176 |
|
|
|
1177 |
sub _update_missing_and_received_list { |
1178 |
my ($missinglist, $recievedlist, $serialseq, $status)=@_; |
1179 |
|
1180 |
#Arrived: add to received list, remove from missing |
1181 |
if($status==2) { |
1182 |
$recievedlist .= "; $serialseq" |
1183 |
if $recievedlist!~/(^|;)\s*$serialseq(?=;|$)/; |
1184 |
$missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1185 |
} |
1186 |
#Expected,late,claimed: remove optionally from received+missing |
1187 |
if (grep /$status/, (1,3,7)) { |
1188 |
$recievedlist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1189 |
$missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1190 |
} |
1191 |
#Missing, not available: add to missing, remove from received |
1192 |
#No longer putting additional text into missing field |
1193 |
if($status==4 || $status==5) { |
1194 |
$missinglist .= "; $serialseq" |
1195 |
if $missinglist!~/(^|;)\s*$serialseq(?=;|$)/; |
1196 |
$recievedlist=~ s/(^|;)\s*$serialseq(?=;|$)//g; |
1197 |
} |
1198 |
$missinglist =~ s/^; //; |
1199 |
$recievedlist =~ s/^; //; |
1200 |
return ($missinglist, $recievedlist); |
1201 |
} |
1202 |
|
1199 |
=head2 GetNextExpected |
1203 |
=head2 GetNextExpected |
1200 |
|
1204 |
|
1201 |
$nextexpected = GetNextExpected($subscriptionid) |
1205 |
$nextexpected = GetNextExpected($subscriptionid) |
Lines 1510-1534
sub NewIssue {
Link Here
|
1510 |
|; |
1514 |
|; |
1511 |
$sth = $dbh->prepare($query); |
1515 |
$sth = $dbh->prepare($query); |
1512 |
$sth->execute($subscriptionid); |
1516 |
$sth->execute($subscriptionid); |
1513 |
my ( $missinglist, $recievedlist ) = $sth->fetchrow; |
1517 |
my ($missinglist, $recievedlist)= _update_missing_and_received_list( |
1514 |
|
1518 |
$sth->fetchrow, $serialseq, $status); |
1515 |
if ( $status == 2 ) { |
|
|
1516 |
### TODO Add a feature that improves recognition and description. |
1517 |
### As such count (serialseq) i.e. : N18,2(N19),N20 |
1518 |
### Would use substr and index But be careful to previous presence of () |
1519 |
$recievedlist .= "; $serialseq" unless (index($recievedlist,$serialseq)>0); |
1520 |
} |
1521 |
if ( $status == 4 ) { |
1522 |
$missinglist .= "; $serialseq" unless (index($missinglist,$serialseq)>0); |
1523 |
} |
1524 |
$query = qq| |
1519 |
$query = qq| |
1525 |
UPDATE subscriptionhistory |
1520 |
UPDATE subscriptionhistory |
1526 |
SET recievedlist=?, missinglist=? |
1521 |
SET recievedlist=?, missinglist=? |
1527 |
WHERE subscriptionid=? |
1522 |
WHERE subscriptionid=? |
1528 |
|; |
1523 |
|; |
1529 |
$sth = $dbh->prepare($query); |
1524 |
$sth = $dbh->prepare($query); |
1530 |
$recievedlist =~ s/^; //; |
|
|
1531 |
$missinglist =~ s/^; //; |
1532 |
$sth->execute( $recievedlist, $missinglist, $subscriptionid ); |
1525 |
$sth->execute( $recievedlist, $missinglist, $subscriptionid ); |
1533 |
return $serialid; |
1526 |
return $serialid; |
1534 |
} |
1527 |
} |
1535 |
- |
|
|