Bug 13215: (follow-up) Fix notice edition
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 21 Nov 2014 15:13:41 +0000 (16:13 +0100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 27 Nov 2014 14:42:24 +0000 (11:42 -0300)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
tools/letter.pl

index 4fcd8a8..ab4f78f 100755 (executable)
@@ -254,12 +254,18 @@ sub add_validate {
         my $title   = shift @title;
         my $content = shift @content;
         my $letter = C4::Letters::getletter( $oldmodule, $code, $branchcode, $mtt);
+
+        # getletter can return the default letter even if we pass a branchcode
+        # If we got the default one and we needed the specific one, we didn't get the one we needed!
+        if ( $letter and $branchcode ne $letter->{branchcode} ) {
+            $letter = undef;
+        }
         unless ( $title and $content ) {
             # Delete this mtt if no title or content given
             delete_confirmed( $branchcode, $oldmodule, $code, $mtt );
             next;
         }
-        elsif ( $letter->{message_transport_type} eq $mtt ) {
+        elsif ( $letter and $letter->{message_transport_type} eq $mtt ) {
             $dbh->do(
                 q{
                     UPDATE letter