| 
      
            Lines 98-105
          GetOptions(
      
      
        Link Here
      
     | 
  
        
          | 98 | 
           | 
          98 | 
           | 
        
        
          | 99 | 
          pod2usage(0) if $help;  | 
          99 | 
          pod2usage(0) if $help;  | 
        
        
          | 100 | 
           | 
          100 | 
           | 
        
          
            
              | 101 | 
              my $send_notices_pref = C4::Context->preference('AutoRenewalNotices') | 
              101 | 
              my $send_notices_pref = C4::Context->preference('AutoRenewalNotices'); | 
            
            
              | 102 | 
              if ( $send_notices_pref = 'cron' ) { | 
              102 | 
              if ( $send_notices_pref eq 'cron' ) { | 
            
        
          | 103 | 
              warn <<'END_WARN';  | 
          103 | 
              warn <<'END_WARN';  | 
        
        
          | 104 | 
           | 
          104 | 
           | 
        
        
          | 105 | 
          The "AutoRenewalNotices" syspref is set to 'Follow the cron switch'.  | 
          105 | 
          The "AutoRenewalNotices" syspref is set to 'Follow the cron switch'.  | 
        
  
    | 
      
            Lines 144-149
          while ( my $auto_renew = $auto_renews->next ) {
      
      
        Link Here
      
     | 
  
        
          | 144 | 
              $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, | 
          144 | 
              $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, | 
        
        
          | 145 | 
                                                                                             message_name   => 'auto_renewals' } ) if $send_notices_pref eq 'preferences';  | 
          145 | 
                                                                                             message_name   => 'auto_renewals' } ) if $send_notices_pref eq 'preferences';  | 
        
        
          | 146 | 
           | 
          146 | 
           | 
        
            
               | 
               | 
              147 | 
                  $send_notices = 1 if !$send_notices && $send_notices_pref eq 'preferences' && $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email}; | 
            
            
              | 148 | 
               | 
            
        
          | 147 | 
              # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script  | 
          149 | 
              # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script  | 
        
        
          | 148 | 
              my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );  | 
          150 | 
              my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );  | 
        
        
          | 149 | 
              if ( $error eq 'auto_renew' ) { | 
          151 | 
              if ( $error eq 'auto_renew' ) { | 
        
  
    | 
      
            Lines 155-161
          while ( my $auto_renew = $auto_renews->next ) {
      
      
        Link Here
      
     | 
  
        
          | 155 | 
                      my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode );  | 
          157 | 
                      my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode );  | 
        
        
          | 156 | 
                      $auto_renew->auto_renew_error(undef)->store;  | 
          158 | 
                      $auto_renew->auto_renew_error(undef)->store;  | 
        
        
          | 157 | 
                  }  | 
          159 | 
                  }  | 
        
          
            
              | 158 | 
                      push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $borrower_preferences && (!$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); | 
              160 | 
                      push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $send_notices_pref ne 'cron' && (!$borrower_preferences || !$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); | 
            
        
          | 159 | 
              } elsif ( $error eq 'too_many'  | 
          161 | 
              } elsif ( $error eq 'too_many'  | 
        
        
          | 160 | 
                  or $error eq 'on_reserve'  | 
          162 | 
                  or $error eq 'on_reserve'  | 
        
        
          | 161 | 
                  or $error eq 'restriction'  | 
          163 | 
                  or $error eq 'restriction'  | 
        
  
    | 
      
            Lines 172-178
          while ( my $auto_renew = $auto_renews->next ) {
      
      
        Link Here
      
     | 
  
        
          | 172 | 
                  if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { | 
          174 | 
                  if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { | 
        
        
          | 173 | 
                      $auto_renew->auto_renew_error($error)->store if $confirm;  | 
          175 | 
                      $auto_renew->auto_renew_error($error)->store if $confirm;  | 
        
        
          | 174 | 
                      push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew | 
          176 | 
                      push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew | 
        
          
            
              | 175 | 
                            if $error ne 'auto_too_soon' && (!$borrower_preferences || ($borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'}));    # Do not notify if it's too soon | 
              177 | 
                            if $error ne 'auto_too_soon' && ($send_notices_pref eq 'cron' || ($borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'}));    # Do not notify if it's too soon | 
            
        
          | 176 | 
                  }  | 
          178 | 
                  }  | 
        
        
          | 177 | 
              }  | 
          179 | 
              }  | 
        
        
          | 178 | 
           | 
          180 | 
           | 
        
  
    | 
      
            Lines 181-189
          while ( my $auto_renew = $auto_renews->next ) {
      
      
        Link Here
      
     | 
  
        
          | 181 | 
                  if ($digest_per_branch) { | 
          183 | 
                  if ($digest_per_branch) { | 
        
        
          | 182 | 
                      $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; | 
          184 | 
                      $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; | 
        
        
          | 183 | 
                      $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ; | 
          185 | 
                      $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ; | 
        
            
               | 
               | 
              186 | 
                          push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; | 
            
        
          | 184 | 
                  } else { | 
          187 | 
                  } else { | 
        
        
          | 185 | 
                      $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; | 
          188 | 
                      $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; | 
        
        
          | 186 | 
                      $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ; | 
          189 | 
                      $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ; | 
        
            
               | 
               | 
              190 | 
                          push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; | 
            
        
          | 187 | 
                  }  | 
          191 | 
                  }  | 
        
        
          | 188 | 
              }  | 
          192 | 
              }  | 
        
        
          | 189 | 
           | 
          193 | 
           | 
        
  
    | 
      
            Lines 292-297
          sub send_digests {
      
      
        Link Here
      
     | 
  
        
          | 292 | 
                              error => $digest->{error}||0, | 
          296 | 
                              error => $digest->{error}||0, | 
        
        
          | 293 | 
                              success => $digest->{success}||0, | 
          297 | 
                              success => $digest->{success}||0, | 
        
        
          | 294 | 
                          },  | 
          298 | 
                          },  | 
        
            
               | 
               | 
              299 | 
                              loops => { issues => \@{$digest->{issues}} }, | 
            
        
          | 295 | 
                          tables      => { | 
          300 | 
                          tables      => { | 
        
        
          | 296 | 
                              borrowers => $patron->borrowernumber,  | 
          301 | 
                              borrowers => $patron->borrowernumber,  | 
        
        
          | 297 | 
                          },  | 
          302 | 
                          },  | 
        
            
              | 298 | 
              -   | 
               | 
               |