&CountIssues
HasItems
&GetSubscriptionsFromBorrower
+ &subscriptionCurrentlyOnOrder
);
}
$sth->execute($subscriptionid);
my ( $missinglist, $recievedlist ) = $sth->fetchrow;
if ( $status == 2 ) {
-
$recievedlist .= "; $serialseq"
- unless ( index( "$recievedlist", "$serialseq" ) >= 0 );
+ if $recievedlist!~/(^|;)\s*$serialseq(?=;|$)/;
+ }
+ # in case serial has been previously marked as missing
+ if (grep /$status/, (1,2,3,7)) {
+ $missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g;
}
-
- # warn "missinglist : $missinglist serialseq :$serialseq, ".index("$missinglist","$serialseq");
$missinglist .= "; $serialseq"
- if ( $status == 4
- and not index( "$missinglist", "$serialseq" ) >= 0 );
+ if $status==4 && $missinglist!~/(^|;)\s*$serialseq(?=;|$)/;
$missinglist .= "; not issued $serialseq"
- if ( $status == 5
- and index( "$missinglist", "$serialseq" ) >= 0 );
+ if $status==5 && $missinglist!~/(^|;)\s*$serialseq(?=;|$)/;
+
$query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE subscriptionid=?";
$sth = $dbh->prepare($query);
$recievedlist =~ s/^; //;
# renew subscription
$query = qq|
UPDATE subscription
- SET startdate=?,numberlength=?,weeklength=?,monthlength=?
+ SET startdate=?,numberlength=?,weeklength=?,monthlength=?,reneweddate=NOW()
WHERE subscriptionid=?
|;
$sth = $dbh->prepare($query);
$sth->execute( $subscriptionid );
}
+=head2 subscriptionCurrentlyOnOrder
+
+ $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
+
+Return 1 if subscription is currently on order else 0.
+
+=cut
+
+sub subscriptionCurrentlyOnOrder {
+ my ( $subscriptionid ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = qq|
+ SELECT COUNT(*) FROM aqorders
+ WHERE subscriptionid = ?
+ AND datereceived IS NULL
+ AND datecancellationprinted IS NULL
+ |;
+ my $sth = $dbh->prepare( $query );
+ $sth->execute($subscriptionid);
+ return $sth->fetchrow_array;
+}
+
1;
__END__