From 92abced36bc7978c01ec832d330eef2be6e0a769 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Wed, 5 Feb 2014 11:05:19 +0100
Subject: [PATCH] [PASSED QA] Bug 11689: New missing statuses are not well
 managed

Bug 10851 introduced new missing status (codes 41,42,43,44), but in
GetSerials and _update_missinglist, they are not take into account.

To reproduce:
1/ Create a serial with 10 issues.
2/ Set different statuses on each one, with at least 6 missing statuses
(not only "Missing").
3/ Go on the subscription detail page, tab "Summary", the issues with a
new missing status are not listed in the missing issues list.
4/ On the "Issues" tab, all missing are listed (normally only 5 should
be listed.
5/ Apply the patch.
6/ Edit serial (to rewrite the missing list).
6/ Verify that steps 3 and 4 have now correct behavior.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, passes QA script and tests.
---
 C4/Serials.pm | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/C4/Serials.pm b/C4/Serials.pm
index 2fb639b..bfbf21f 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -772,7 +772,7 @@ sub GetSerials {
     my @serials;
     my $query = "SELECT serialid,serialseq, status, publisheddate, planneddate,notes, routingnotes
                         FROM   serial
-                        WHERE  subscriptionid = ? AND status NOT IN (2,4,5) 
+                        WHERE  subscriptionid = ? AND status NOT IN (2, 4, 41, 42, 43, 44, 5)
                         ORDER BY IF(publisheddate<>'0000-00-00',publisheddate,planneddate) DESC";
     my $sth = $dbh->prepare($query);
     $sth->execute($subscriptionid);
@@ -793,7 +793,7 @@ sub GetSerials {
     $query = "SELECT   serialid,serialseq, status, planneddate, publisheddate,notes, routingnotes
        FROM     serial
        WHERE    subscriptionid = ?
-       AND      (status in (2,4,5))
+       AND      (status in (2, 4, 41, 42, 43, 44, 5))
        ORDER BY IF(publisheddate<>'0000-00-00',publisheddate,planneddate) DESC
       ";
     $sth = $dbh->prepare($query);
@@ -1164,13 +1164,13 @@ sub _update_missinglist {
     my $subscriptionid = shift;
 
     my $dbh = C4::Context->dbh;
-    my @missingserials = GetSerials2($subscriptionid, "4,5");
+    my @missingserials = GetSerials2($subscriptionid, "4,41,42,43,44,5");
     my $missinglist;
-    foreach (@missingserials) {
-        if($_->{'status'} == 4) {
-            $missinglist .= $_->{'serialseq'} . "; ";
-        } elsif($_->{'status'} == 5) {
-            $missinglist .= "not issued " . $_->{'serialseq'} . "; ";
+    foreach my $missingserial (@missingserials) {
+        if ( grep { $_ == $missingserial->{status} } qw( 4 41 42 43 44 ) ) {
+            $missinglist .= $missingserial->{'serialseq'} . "; ";
+        } elsif($missingserial->{'status'} == 5) {
+            $missinglist .= "not issued " . $missingserial->{'serialseq'} . "; ";
         }
     }
     $missinglist =~ s/; $//;
-- 
1.8.3.2