From 67923a0b7b3e91023fc03ca382015f8bd8dd25f9 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 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 --- 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 1459841..947163c 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1130,13 +1130,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 @@ -1144,16 +1144,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); @@ -1207,9 +1206,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; @@ -1558,7 +1555,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. @@ -1568,7 +1565,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); @@ -1590,6 +1587,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 a4fd91d..2f83c32 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 = ? "); @@ -88,7 +88,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 e5f69e8..3d5ccc9 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -235,7 +235,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 6e65ee3..6ef801c 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -166,7 +166,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.1.4