|
Lines 1228-1264
sub ModSerialStatus {
Link Here
|
| 1228 |
} |
1228 |
} |
| 1229 |
} |
1229 |
} |
| 1230 |
|
1230 |
|
| 1231 |
# create new waited entry if needed (ie : was a "waited" and has changed) |
1231 |
# check if an alert must be sent... (= a letter is defined & status became "arrived" |
| 1232 |
if ( $oldstatus == 1 && $status != 1 ) { |
1232 |
my $subscription = GetSubscription($subscriptionid); |
| 1233 |
my $subscription = GetSubscription($subscriptionid); |
1233 |
if ( $subscription->{letter} && $status == 2 && $oldstatus != 2 ) { |
| 1234 |
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); |
1234 |
require C4::Letters; |
| 1235 |
|
1235 |
C4::Letters::SendAlerts( 'issue', $subscription->{subscriptionid}, $subscription->{letter} ); |
| 1236 |
# next issue number |
|
|
| 1237 |
my ( |
| 1238 |
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, |
| 1239 |
$newinnerloop1, $newinnerloop2, $newinnerloop3 |
| 1240 |
) |
| 1241 |
= GetNextSeq( $subscription, $pattern, $publisheddate ); |
| 1242 |
|
| 1243 |
# next date (calculated from actual date & frequency parameters) |
| 1244 |
my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1); |
| 1245 |
my $nextpubdate = $nextpublisheddate; |
| 1246 |
NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate ); |
| 1247 |
$query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? |
| 1248 |
WHERE subscriptionid = ?"; |
| 1249 |
$sth = $dbh->prepare($query); |
| 1250 |
$sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid ); |
| 1251 |
|
| 1252 |
# check if an alert must be sent... (= a letter is defined & status became "arrived" |
| 1253 |
if ( $subscription->{letter} && $status == 2 && $oldstatus != 2 ) { |
| 1254 |
require C4::Letters; |
| 1255 |
C4::Letters::SendAlerts( 'issue', $subscription->{subscriptionid}, $subscription->{letter} ); |
| 1256 |
} |
| 1257 |
} |
1236 |
} |
| 1258 |
|
1237 |
|
| 1259 |
return; |
1238 |
return; |
| 1260 |
} |
1239 |
} |
| 1261 |
|
1240 |
|
|
|
1241 |
=head2 GenerateNewIssue |
| 1242 |
|
| 1243 |
GenerateNewIssue($subscriptionid) |
| 1244 |
|
| 1245 |
Autogenerate a new issue to serial subscription. |
| 1246 |
|
| 1247 |
=cut |
| 1248 |
|
| 1249 |
sub GenerateNewIssue { |
| 1250 |
my $dbh = C4::Context->dbh; |
| 1251 |
my ($subscriptionid) = @_; |
| 1252 |
require C4::Serials::Numberpattern; |
| 1253 |
my $subscription = GetSubscription($subscriptionid); |
| 1254 |
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); |
| 1255 |
my $expected = GetNextExpected($subscriptionid); |
| 1256 |
my ( |
| 1257 |
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, |
| 1258 |
$newinnerloop1, $newinnerloop2, $newinnerloop3 |
| 1259 |
) = GetNextSeq($subscription, $pattern, $expected->{publisheddate}); |
| 1260 |
|
| 1261 |
## We generate the next publication date |
| 1262 |
my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1); |
| 1263 |
## Creating the new issue |
| 1264 |
NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, |
| 1265 |
1, $nextpublisheddate, $nextpublisheddate ); |
| 1266 |
|
| 1267 |
## Updating the subscription seq status |
| 1268 |
my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? |
| 1269 |
WHERE subscriptionid = ?"; |
| 1270 |
my $seqsth = $dbh->prepare($squery); |
| 1271 |
$seqsth->execute( |
| 1272 |
$newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, |
| 1273 |
$newinnerloop2, $newinnerloop3, $subscriptionid |
| 1274 |
); |
| 1275 |
} |
| 1276 |
|
| 1262 |
=head2 GetNextExpected |
1277 |
=head2 GetNextExpected |
| 1263 |
|
1278 |
|
| 1264 |
$nextexpected = GetNextExpected($subscriptionid) |
1279 |
$nextexpected = GetNextExpected($subscriptionid) |