BUG FIXING + Modification in API for DelIssue

DelIssue now takes in a reference hash of data to delete (serialid, subscriptionid and serialseq are required)
DelIssue now delete one peculiar serialid and doesnot proceed only on serialseq any longer.

Signed-off-by: Chris Cormack <crc@liblime.com>
This commit is contained in:
Henri-Damien LAURENT 2007-10-02 22:30:01 +02:00 committed by Chris Cormack
parent d638399aed
commit d00600c373

View file

@ -1162,7 +1162,7 @@ sub ModSerialStatus {
# change status & update subscriptionhistory
my $val;
if ( $status eq 6 ) {
DelIssue( $serialseq, $subscriptionid );
DelIssue( {'serialid'=>$serialid, 'subscriptionid'=>$subscriptionid,'serialseq'=>$serialseq} );
}
else {
my $query =
@ -1826,20 +1826,21 @@ this function delete an issue which has $serialseq and $subscriptionid given on
=cut
sub DelIssue {
my ( $serialseq, $subscriptionid ) = @_;
my ( $dataissue) = @_;
my $dbh = C4::Context->dbh;
### TODO Add itemdeletion. Should be in a pref ?
my $query = qq|
DELETE FROM serial
WHERE serialseq= ?
WHERE serialid= ?
AND subscriptionid= ?
|;
my $mainsth = $dbh->prepare($query);
$mainsth->execute( $serialseq, $subscriptionid );
$mainsth->execute( $dataissue->{'serialid'}, $dataissue->{'subscriptionid'});
#Delete element from subscription history
$query = "SELECT * FROM subscription WHERE subscriptionid = ?";
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
$sth->execute($dataissue->{'subscriptionid'});
my $val = $sth->fetchrow_hashref;
unless ( $val->{manualhistory} ) {
my $query = qq|
@ -1847,18 +1848,18 @@ sub DelIssue {
WHERE subscriptionid= ?
|;
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
$sth->execute($dataissue->{'subscriptionid'});
my $data = $sth->fetchrow_hashref;
$data->{'missinglist'} =~ s/$serialseq//;
$data->{'recievedlist'} =~ s/$serialseq//;
my $serialseq= $dataissue->{'serialseq'};
$data->{'missinglist'} =~ s/\b$serialseq\b//;
$data->{'recievedlist'} =~ s/\b$serialseq\b//;
my $strsth = "UPDATE subscriptionhistory SET "
. join( ",",
map { join( "=", $_, $dbh->quote( $data->{$_} ) ) } keys %$data )
. " WHERE subscriptionid=?";
$sth = $dbh->prepare($strsth);
$sth->execute($subscriptionid);
$sth->execute($dataissue->{'subscriptionid'});
}
### TODO Add itemdeletion. Should be in a pref ?
return $mainsth->rows;
}