| Lines 1002-1032
          Returns the empty string if no email address.
      
      
        Link Here | 
        
          | 1002 | =cut | 1002 | =cut | 
        
          | 1003 |  | 1003 |  | 
        
          | 1004 | sub notice_email_address{ | 1004 | sub notice_email_address{ | 
          
            
              | 1005 |     my ( $self ) = @_; | 1005 |      my ( $self ) = @_; | 
            
              | 1006 |     my $address; | 1006 |      my $address; | 
            
              | 1007 |  | 1007 |      my $guarantor_address; | 
            
              | 1008 |     my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); | 1008 |   | 
            
              | 1009 |     # if syspref is set to 'first valid' (value == OFF), look up email address | 1009 |      my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); | 
            
              | 1010 |     if ( $which_address eq 'OFF' ) { | 1010 |      # if syspref is set to 'first valid' (value == OFF), look up email address | 
            
              | 1011 |         $address = $self->first_valid_email_address; | 1011 |      if ( $which_address eq 'OFF' ) { | 
            
              | 1012 |     } else { | 1012 |          $address = $self->first_valid_email_address; | 
            
              | 1013 |         $address = $self->$which_address || ''; | 1013 |      } else { | 
            
              | 1014 |     } | 1014 |          $address = $self->$which_address || ''; | 
            
              | 1015 |  | 1015 |      } | 
            
              | 1016 |     my $use_guarantor = C4::Context->preference('RedirectGuaranteeEmail'); | 1016 |   | 
            
              | 1017 |     if ($use_guarantor) { | 1017 |      my $use_guarantor = C4::Context->preference('RedirectGuaranteeEmail'); | 
            
              | 1018 |         my $guarantor = $self->guarantor; | 1018 |      if ($use_guarantor) { | 
            
              | 1019 |         if ($guarantor) { | 1019 |          my $guarantor = $self->guarantor; | 
            
              | 1020 |             my $guarantor_address = $guarantor->notice_email_address; | 1020 |          if ($guarantor) { | 
            
              | 1021 |             if ($address){ | 1021 |              if ( $which_address eq 'OFF' ) { | 
            
              | 1022 |             $address .= ', '; | 1022 |                  $guarantor_address = $guarantor->first_valid_email_address; | 
            
              | 1023 |             } | 1023 |              } else { | 
            
              | 1024 |             $address .=  $guarantor_address if $guarantor_address; | 1024 |                  $guarantor_address = $guarantor->$which_address || ''; | 
            
              | 1025 |         } | 1025 |              } | 
            
              | 1026 |     } | 1026 |              if ($address){ | 
            
              | 1027 |     return $address; | 1027 |                  $address .= ', '; | 
            
              |  |  | 1028 |              } | 
            
              | 1029 |                  $address .=  $guarantor_address if $guarantor_address; | 
            
              | 1030 |          } | 
            
              | 1031 |      } | 
            
              | 1032 |      return $address; | 
        
          | 1028 | } | 1033 | } | 
        
          | 1029 |  | 1034 |  | 
            
              |  |  | 1035 |  | 
        
          | 1030 | =head3 first_valid_email_address | 1036 | =head3 first_valid_email_address | 
        
          | 1031 |  | 1037 |  | 
        
          | 1032 | my $first_valid_email_address = $patron->first_valid_email_address | 1038 | my $first_valid_email_address = $patron->first_valid_email_address | 
            
              | 1033 | -  |  |  |