From 2c25016a8e17b52e23c3d9806264e141b6426254 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Fri, 7 Dec 2018 01:03:42 +0000 Subject: [PATCH] Bug 11492: Keep routing notes when receiving next serial MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch ensures the routing notes are carried over when generating the next serial. To test: 1) Create a routing list for a subscription 2) Add a borrower and a note to the routing list 3) Generate the next serial (serials-collection.pl) 4) Edit the routing list to see the notes 5) Note that the notes have disappeared 6) Apply patch 7) Edit the routing list, add a note 8) Generate the next serial 9) Edit the routing list and confirm the note is still there 10) Confirm you are still able to edit serials (serials-edit.pl) and routing notes stay Sponsored-by: Plant and Food Research Limited Signed-off-by: Nazlı Çetin Signed-off-by: Liz Rea Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize --- C4/Serials.pm | 18 ++++++++---------- serials/serials-collection.pl | 5 +++-- serials/serials-edit.pl | 3 ++- t/db_dependent/Serials.t | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 4eb23dfa9e..a647f02ae3 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1086,13 +1086,13 @@ sub ModSerialStatus { #It is a usual serial # 1st, get previous status : my $dbh = C4::Context->dbh; - my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity + my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity,serial.routingnotes FROM serial, subscription WHERE serial.subscriptionid=subscription.subscriptionid AND serialid=?"; my $sth = $dbh->prepare($query); $sth->execute($serialid); - my ( $subscriptionid, $oldstatus, $periodicity ) = $sth->fetchrow; + my ( $subscriptionid, $oldstatus, $periodicity, $routingnotes ) = $sth->fetchrow; my $frequency = GetSubscriptionFrequency($periodicity); # change status & update subscriptionhistory @@ -1100,16 +1100,15 @@ sub ModSerialStatus { if ( $status == DELETED ) { DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } ); } else { - my $query = ' UPDATE serial SET serialseq = ?, publisheddate = ?, publisheddatetext = ?, - planneddate = ?, status = ?, notes = ? + planneddate = ?, status = ?, notes = ?, routingnotes = ? WHERE serialid = ? '; $sth = $dbh->prepare($query); $sth->execute( $serialseq, $publisheddate, $publisheddatetext, - $planneddate, $status, $notes, $serialid ); + $planneddate, $status, $notes, $routingnotes, $serialid ); $query = "SELECT * FROM subscription WHERE subscriptionid = ?"; $sth = $dbh->prepare($query); $sth->execute($subscriptionid); @@ -1164,9 +1163,7 @@ sub ModSerialStatus { WHERE subscriptionid = ?"; $sth = $dbh->prepare($query); $sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid ); - - NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate ); - + NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate, $publisheddatetext, $notes, $routingnotes ); # check if an alert must be sent... (= a letter is defined & status became "arrived" if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) { require C4::Letters; @@ -1533,7 +1530,7 @@ sub ReNewSubscription { =head2 NewIssue -NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes) +NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes, $routingnotes) Create a new issue stored on the database. Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription. @@ -1543,7 +1540,7 @@ returns the serial id sub NewIssue { my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, - $publisheddate, $publisheddatetext, $notes ) = @_; + $publisheddate, $publisheddatetext, $notes, $routingnotes ) = @_; ### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ? return unless ($subscriptionid); @@ -1565,6 +1562,7 @@ sub NewIssue { publisheddate => $publisheddate, publisheddatetext => $publisheddatetext, notes => $notes, + routingnotes => $routingnotes } )->store(); diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index e5adb3686a..18a46b5ea1 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -59,7 +59,7 @@ if($op eq 'gennext' && @subscriptionid){ my $subscriptionid = $subscriptionid[0]; my $sth = $dbh->prepare(" SELECT publisheddate, publisheddatetext, serialid, serialseq, - planneddate + planneddate, notes, routingnotes FROM serial WHERE status = 1 AND subscriptionid = ? "); @@ -90,7 +90,8 @@ if($op eq 'gennext' && @subscriptionid){ my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate; ## Creating the new issue NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, - 1, $planneddate, $nextpublisheddate ); + 1, $planneddate, $nextpublisheddate, $issue->{publisheddatetext}, + $issue->{notes}, $issue->{routingnotes} ); ## Updating the subscription seq status my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 33e11ad3bc..0b25dc4169 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -238,7 +238,8 @@ if ( $op and $op eq 'serialchangestatus' ) { $plan_date, $pub_date, $publisheddatetexts[$i], - $notes[$i] + $notes[$i], + $serialdatalist[0]->{'routingnotes'} ); } } diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index d30a32a48f..cfad08a9b9 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -163,7 +163,7 @@ subtest 'Values should not be erased on editing' => sub { ); my ( undef, undef, $itemnumber ) = C4::Items::AddItemFromMarc( $item_record, $biblionumber ); my $serialid = C4::Serials::NewIssue( "serialseq", $subscriptionid, $biblionumber, - 1, undef, undef, "publisheddatetext", "notes" ); + 1, undef, undef, "publisheddatetext", "notes", "routingnotes" ); C4::Serials::AddItem2Serial( $serialid, $itemnumber ); my $serial_info = C4::Serials::GetSerialInformation($serialid); my ($itemcallnumber_info) = grep { $_->{kohafield} eq 'items.itemcallnumber' } -- 2.39.5