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