View | Details | Raw Unified | Return to bug 6835
Collapse All | Expand All

(-)a/C4/Members.pm (+33 lines)
Lines 59-64 BEGIN { Link Here
59
		&getidcity
59
		&getidcity
60
60
61
                &GetFirstValidEmailAddress
61
                &GetFirstValidEmailAddress
62
        &GetValidEmailAddresses
62
63
63
		&GetAge 
64
		&GetAge 
64
		&GetCities 
65
		&GetCities 
Lines 1324-1329 sub GetFirstValidEmailAddress { Link Here
1324
    }
1325
    }
1325
}
1326
}
1326
1327
1328
1329
=head2 GetValidEmailAddresses
1330
1331
  $email = GetValidEmailAddresses($borrowernumber);
1332
1333
Return all the valid email address for a borrower, given the borrowernumber. Returns an hash.
1334
1335
=cut
1336
1337
sub GetValidEmailAddresses {
1338
    my $borrowernumber = shift;
1339
    my $dbh            = C4::Context->dbh;
1340
    my $sth            = $dbh->prepare(
1341
"SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? "
1342
    );
1343
    $sth->execute($borrowernumber);
1344
    my $data = $sth->fetchrow_hashref;
1345
    my %mailhash;
1346
1347
    if ( $data->{'email'} ) {
1348
        $mailhash{'email'} = $data->{'email'};
1349
    }
1350
    if ( $data->{'emailpro'} ) {
1351
        $mailhash{'emailpro'} = $data->{'emailpro'};
1352
    }
1353
    if ( $data->{'B_email'} ) {
1354
        $mailhash{'B_email'} = $data->{'B_email'};
1355
    }
1356
    return \%mailhash;
1357
}
1358
1359
1327
=head2 GetExpiryDate 
1360
=head2 GetExpiryDate 
1328
1361
1329
  $expirydate = GetExpiryDate($categorycode, $dateenrolled);
1362
  $expirydate = GetExpiryDate($categorycode, $dateenrolled);
(-)a/misc/cronjobs/overdue_notices.pl (-3 / +30 lines)
Lines 47-53 overdue_notices.pl - prepare messages to be sent to patrons for overdue items Link Here
47
47
48
=head1 SYNOPSIS
48
=head1 SYNOPSIS
49
49
50
overdue_notices.pl [ -n ] [ -library <branchcode> ] [ -library <branchcode>...] [ -max <number of days> ] [ -csv [ <filename> ] ] [ -itemscontent <field list> ]
50
overdue_notices
51
  . pl [ -n ][ -library <branchcode> ][ -library <branchcode> ... ]
52
  [ -max <number of days> ][ -csv [<filename>] ][ -itemscontent <field list> ]
53
  [ -email <email_type> ... ]
51
54
52
 Options:
55
 Options:
53
   -help                          brief help message
56
   -help                          brief help message
Lines 60-65 overdue_notices.pl [ -n ] [ -library <branchcode> ] [ -library <branchcode>...] Link Here
60
   -itemscontent <list of fields> item information in templates
63
   -itemscontent <list of fields> item information in templates
61
   -borcat       <categorycode>   category code that must be included
64
   -borcat       <categorycode>   category code that must be included
62
   -borcatout    <categorycode>   category code that must be excluded
65
   -borcatout    <categorycode>   category code that must be excluded
66
   -email        <email_type>     type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable.
63
67
64
=head1 OPTIONS
68
=head1 OPTIONS
65
69
Lines 143-148 Default items.content lists only those items that fall in the Link Here
143
range of the currently processing notice.
147
range of the currently processing notice.
144
Choose list-all to include all overdue items in the list (limited by B<-max> setting).
148
Choose list-all to include all overdue items in the list (limited by B<-max> setting).
145
149
150
=item B<-email>
151
152
Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable.
153
146
=back
154
=back
147
155
148
=head1 DESCRIPTION
156
=head1 DESCRIPTION
Lines 252-257 my $verbose = 0; Link Here
252
my $nomail  = 0;
260
my $nomail  = 0;
253
my $MAX     = 90;
261
my $MAX     = 90;
254
my @branchcodes; # Branch(es) passed as parameter
262
my @branchcodes; # Branch(es) passed as parameter
263
my @emails_to_use;    # Emails to use for messaging
264
my @emails;           # Emails given in command-line parameters
255
my $csvfilename;
265
my $csvfilename;
256
my $htmlfilename;
266
my $htmlfilename;
257
my $triggered = 0;
267
my $triggered = 0;
Lines 274-279 GetOptions( Link Here
274
    't|triggered'             => \$triggered,
284
    't|triggered'             => \$triggered,
275
    'borcat=s'      => \@myborcat,
285
    'borcat=s'      => \@myborcat,
276
    'borcatout=s'   => \@myborcatout,
286
    'borcatout=s'   => \@myborcatout,
287
    'email=s' => \@emails,
277
) or pod2usage(2);
288
) or pod2usage(2);
278
pod2usage(1) if $help;
289
pod2usage(1) if $help;
279
pod2usage( -verbose => 2 ) if $man;
290
pod2usage( -verbose => 2 ) if $man;
Lines 458-463 END_SQL Link Here
458
                    $address1, $address2, $city, $postcode, $country, $email,
469
                    $address1, $address2, $city, $postcode, $country, $email,
459
                    $longest_issue ) = $sth->fetchrow )
470
                    $longest_issue ) = $sth->fetchrow )
460
            {
471
            {
472
                @emails_to_use = ();
473
                if ( @emails && !$nomail ) {
474
                    my $validemails =
475
                      C4::Members::GetValidEmailAddresses($borrowernumber);
476
                    foreach (@emails) {
477
                        push @emails_to_use, $validemails->{$_}
478
                          if ( defined $validemails->{$_} );
479
                    }
480
                    $email = 1 if (@emails_to_use);
481
                }
482
                else {
483
                    $email =
484
                      C4::Members::GetFirstValidEmailAddress($borrowernumber);
485
                    push @emails_to_use, $email;
486
                }
487
461
                $verbose and warn "borrower $firstname, $lastname ($borrowernumber) has $itemcount items triggering level $i.";
488
                $verbose and warn "borrower $firstname, $lastname ($borrowernumber) has $itemcount items triggering level $i.";
462
    
489
    
463
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"} );
490
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"} );
Lines 539-550 END_SQL Link Here
539
                        }
566
                        }
540
                      );
567
                      );
541
                } else {
568
                } else {
542
                    if ($email) {
569
                    if (scalar(@emails_to_use) > 0 ) {
543
                        C4::Letters::EnqueueLetter(
570
                        C4::Letters::EnqueueLetter(
544
                            {   letter                 => $letter,
571
                            {   letter                 => $letter,
545
                                borrowernumber         => $borrowernumber,
572
                                borrowernumber         => $borrowernumber,
546
                                message_transport_type => 'email',
573
                                message_transport_type => 'email',
547
                                from_address           => $admin_email_address,
574
                                from_address           => $admin_email_address,
575
                                to_address             => join(',', @emails_to_use),
548
                            }
576
                            }
549
                        );
577
                        );
550
                    } else {
578
                    } else {
551
- 

Return to bug 6835