@@ -, +, @@ email to staff if user has no email address With the following SQL query (using an SQL report if you want) SELECT COUNT(*) FROM message_queue; To ensure that no other overdues will create noise in this test plan. Or you can take them into account. and set a date in the past which is compatible with what you find in staff:/cgi-bin/koha/tools/overduerules.pl SELECT * FROM message_queue ORDER BY time_queued DESC LIMIT 2 \G 1. One has the type "print" and the borrowernumber matching the patron. 2. The other has subject: Overdue Notices borrowernumber: NULL message_transport_type: email and contains "These messages were not sent directly to the patrons." This is the one we don't want anymore. Because it's now obsolete due to the first message. "Overdue Notices" one. --- ...add-system-preference-EmailOverduesNoEmail.perl | 9 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/admin.pref | 8 +++++ misc/cronjobs/overdue_notices.pl | 42 ++++++++++++---------- 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/add-system-preference-EmailOverduesNoEmail.perl --- a/installer/data/mysql/atomicupdate/add-system-preference-EmailOverduesNoEmail.perl +++ a/installer/data/mysql/atomicupdate/add-system-preference-EmailOverduesNoEmail.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if ( CheckVersion($DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) + VALUES ('EmailOverduesNoEmail','0','','Set mail sending to staff for patron has overdues but no email address', 'YesNo') + }); + + NewVersion( $DBversion,'20076','Add system preference EmailOverduesNoEmail'); +} --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/installer/data/mysql/mandatory/sysprefs.sql @@ -193,6 +193,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ElasticsearchCrossFields', '1', '', 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo'), ('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'), ('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'), +('EmailOverduesNoEmail','0',NULL,'Set mail sending to staff for patron has overdues but no email address','YesNo'), ('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'), ('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'), ('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -76,6 +76,14 @@ Administration: choices: 1: "The logged-in library" 0: "All libraries" + + - + - pref: EmailOverduesNoEmail + choices: + 1: "Don't send" + 0: "Send" + - "mail to staff for patron has overdues but no email address" + Login options: - - "Inactivity timeout in seconds to automatically log out users: " --- a/misc/cronjobs/overdue_notices.pl +++ a/misc/cronjobs/overdue_notices.pl @@ -368,6 +368,7 @@ if (@branchcodes) { my $branch_word = scalar @branches > 1 ? 'branches' : 'branch'; $verbose and warn "$branch_word @branches have overdue rules\n"; + } else { $verbose and warn "No active overduerules for $branchcodes_word '@branchcodes'\n"; @@ -841,25 +842,28 @@ END_SQL } $content .= join( "\n", @output_chunks ); - my $attachment = { - filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt', - type => 'text/plain', - content => $content, - }; - - my $letter = { - title => 'Overdue Notices', - content => 'These messages were not sent directly to the patrons.', - }; - - C4::Letters::EnqueueLetter( - { letter => $letter, - borrowernumber => undef, - message_transport_type => 'email', - attachments => [$attachment], - to_address => $branch_email_address, - } - ) unless $test_mode; + my $EmailOverduesNoEmail = C4::Context->preference('EmailOverduesNoEmail'); + if ( $EmailOverduesNoEmail == 0) { + my $attachment = { + filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt', + type => 'text/plain', + content => $content, + }; + + my $letter = { + title => 'Overdue Notices', + content => 'These messages were not sent directly to the patrons.', + }; + + C4::Letters::EnqueueLetter( + { letter => $letter, + borrowernumber => undef, + message_transport_type => 'email', + attachments => [$attachment], + to_address => $branch_email_address, + } + ) unless $test_mode; + } } } --