use Modern::Perl;
-use Pod::Usage;
-use Getopt::Long;
+use Pod::Usage qw( pod2usage );
+use Getopt::Long qw( GetOptions );
-use C4::Budgets qw( GetBudget );
-use C4::Members qw( GetMember );
-use C4::Suggestions qw( GetUnprocessedSuggestions );
+use Koha::Script -cron;
+use C4::Budgets;
+use C4::Suggestions;
+use Koha::Libraries;
+use Koha::Patrons;
my ( $help, $verbose, $confirm, @days );
GetOptions(
unless ($confirm) {
say "Doing a dry run; no email will be sent.";
- say "Run again with --confirm to sent emails.";
+ say "Run again with --confirm to send emails.";
$verbose = 1 unless $verbose;
}
for my $number_of_days (@days) {
- say "Searching suggestions suggested $number_of_days ago" if $verbose;
+ say "Searching suggestions suggested $number_of_days days ago" if $verbose;
my $suggestions = C4::Suggestions::GetUnprocessedSuggestions($number_of_days);
say "Suggestion $suggestion->{suggestionid} should be processed" if $verbose;
my $budget = C4::Budgets::GetBudget( $suggestion->{budgetid} );
- my $patron = C4::Members::GetMember( borrowernumber => $budget->{budget_owner_id} );
- my $email_address =
- C4::Members::GetNoticeEmailAddress( $budget->{budget_owner_id} );
- my $library = C4::Branch::GetBranchDetail( $patron->{branchcode} );
- my $admin_email_address = $library->{branchemail}
- || C4::Context->preference('KohaAdminEmailAddress');
+ my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
+ my $email_address = $patron->notice_email_address;
if ($email_address) {
- say "Patron $patron->{borrowernumber} is going to be notified" if $verbose;
+ say "Patron " . $patron->borrowernumber . " is going to be notified" if $verbose;
my $letter = C4::Letters::GetPreparedLetter(
module => 'suggestions',
letter_code => 'TO_PROCESS',
- branchcode => $patron->{branchcode},
+ branchcode => $patron->branchcode,
+ lang => $patron->lang,
tables => {
suggestions => $suggestion->{suggestionid},
- branches => $patron->{branchcode},
- borrowers => $patron->{borrowernumber},
+ branches => $patron->branchcode,
+ borrowers => $patron->borrowernumber,
},
);
if ( $confirm ) {
C4::Letters::EnqueueLetter(
{
letter => $letter,
- borrowernumber => $patron->{borrowernumber},
- message_transport_type => 'email',
- from_address => $admin_email_address,
+ borrowernumber => $patron->borrowernumber,
+ message_transport_type => 'email'
}
);
}
} else {
- say "Patron $patron->{borrowernumber} does not have an email address" if $verbose;
+ say "Patron " . $patron->borrowernumber . " does not have an email address" if $verbose;
}
}
This file is part of Koha.
-Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
-Foundation; either version 3 of the License, or (at your option) any later version.
-
-You should have received a copy of the GNU General Public License along
-with Koha; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
=cut