Bug 9032: (follow-up) add new dependency Email::Valid
[koha.git] / C4 / Letters.pm
index c78d01e..5025c10 100644 (file)
@@ -23,6 +23,7 @@ use warnings;
 use MIME::Lite;
 use Mail::Sendmail;
 
+use C4::Koha qw(GetAuthorisedValueByCode);
 use C4::Members;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
 use C4::Branch;
@@ -126,7 +127,6 @@ our %letter;
 sub getletter {
     my ( $module, $code, $branchcode ) = @_;
 
-    $branchcode ||= '';
 
     if ( C4::Context->preference('IndependentBranches')
             and $branchcode
@@ -134,6 +134,7 @@ sub getletter {
 
         $branchcode = C4::Context->userenv->{'branch'};
     }
+    $branchcode //= '';
 
     if ( my $l = $letter{$module}{$code}{$branchcode} ) {
         return { %$l }; # deep copy
@@ -612,9 +613,13 @@ sub _parseletter {
     if ( $table eq 'reserves' && $values->{'waitingdate'} ) {
         my @waitingdate = split /-/, $values->{'waitingdate'};
 
-        my $dt = dt_from_string();
-        $dt->add( days => C4::Context->preference('ReservesMaxPickUpDelay') || 0);
-        $values->{'expirationdate'} = output_pref({ dt => $dt, dateonly => 1 });
+        $values->{'expirationdate'} = '';
+        if( C4::Context->preference('ExpireReservesMaxPickUpDelay') &&
+        C4::Context->preference('ReservesMaxPickUpDelay') ) {
+            my $dt = dt_from_string();
+            $dt->add( days => C4::Context->preference('ReservesMaxPickUpDelay') );
+            $values->{'expirationdate'} = output_pref({ dt => $dt, dateonly => 1 });
+        }
 
         $values->{'waitingdate'} = output_pref({ dt => dt_from_string( $values->{'waitingdate'} ), dateonly => 1 });
 
@@ -633,6 +638,7 @@ sub _parseletter {
             #Therefore adding the test on biblio. This includes biblioitems,
             #but excludes items. Removed unneeded global and lookahead.
 
+        $val = GetAuthorisedValueByCode ('ROADTYPE', $val, 0) if $table=~/^borrowers$/ && $field=~/^streettype$/;
         my $replacedby   = defined ($val) ? $val : '';
         ($letter->{title}  ) and do {
             $letter->{title}   =~ s/$replacetablefield/$replacedby/g;