From d00600c373b63bb3efcbc2664399d8e75a875c59 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Tue, 2 Oct 2007 22:30:01 +0200 Subject: [PATCH] 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 --- C4/Serials.pm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index fe0b15fb78..feaae7eaf0 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -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; } -- 2.39.5