diff --git a/installer/data/mysql/atomicupdate/add-system-preference-EmailOverduesNoEmail.perl b/installer/data/mysql/atomicupdate/add-system-preference-EmailOverduesNoEmail.perl new file mode 100644 index 0000000000..783e22d80d --- /dev/null +++ b/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'); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 68877bbbce..c048130ab2 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/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'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 3263d6d031..8ceb44640b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/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: " diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index a1c2211628..b704d55468 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -376,6 +376,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"; @@ -849,25 +850,28 @@ END_SQL } $content .= join( "\n", @output_chunks ); - my $attachment = { - filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt', - type => 'text/plain', - content => $content, - }; + 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.', - }; + 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; + C4::Letters::EnqueueLetter( + { letter => $letter, + borrowernumber => undef, + message_transport_type => 'email', + attachments => [$attachment], + to_address => $branch_email_address, + } + ) unless $test_mode; + } } }