Bugzilla – Attachment 31952 Details for
Bug 13014
Sent an email to the fund owner when a suggestion can be treated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13014: Notify budget owner on new suggestion - cronjob
Bug-13014-Notify-budget-owner-on-new-suggestion---.patch (text/plain), 5.15 KB, created by
Jonathan Druart
on 2014-09-30 15:06:23 UTC
(
hide
)
Description:
Bug 13014: Notify budget owner on new suggestion - cronjob
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-09-30 15:06:23 UTC
Size:
5.15 KB
patch
obsolete
>From e4b28fafa1b093965c416bd6c1902385a8719857 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 30 Sep 2014 16:59:50 +0200 >Subject: [PATCH] Bug 13014: Notify budget owner on new suggestion - cronjob > >Test plan: >0/ Create a new notice suggestions > TO_PROCESS >You can use the one defined in the other patch. >1/ Create a suggestion and link it to a fund >2/ Add a owner to this fund and make sure this patron has an email >address (the email address used should be the one defined in the >AutoEmailPrimaryAddress syspref). >3/ Execute the cronjob script with the -v and without the -c argument >4/ The output should tell you that an email will be sent >5/ Execute the cronjob script with the -v and with the -c argument >6/ Verify the notice is generated in the message_queue table and it is >correctly formatted. >--- > misc/cronjobs/notice_unprocessed_suggestions.pl | 135 ++++++++++++++++++++++++ > 1 file changed, 135 insertions(+) > create mode 100644 misc/cronjobs/notice_unprocessed_suggestions.pl > >diff --git a/misc/cronjobs/notice_unprocessed_suggestions.pl b/misc/cronjobs/notice_unprocessed_suggestions.pl >new file mode 100644 >index 0000000..866c32c >--- /dev/null >+++ b/misc/cronjobs/notice_unprocessed_suggestions.pl >@@ -0,0 +1,135 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Pod::Usage; >+use Getopt::Long; >+ >+use C4::Budgets qw( GetBudget ); >+use C4::Members qw( GetMember ); >+use C4::Suggestions qw( GetUnprocessedSuggestions ); >+ >+my ( $help, $verbose, $confirm, @days ); >+GetOptions( >+ 'h|help' => \$help, >+ 'v|verbose' => \$verbose, >+ 'days:s' => \@days, >+ 'c|confirm' => \$confirm, >+) || pod2usage(1); >+ >+if ($help) { >+ pod2usage(1); >+} >+ >+unless (@days) { >+ pod2usage(q{At least one day should be given}); >+ exit; >+} >+ >+unless ($confirm) { >+ say "Doing a dry run; no email will be sent."; >+ say "Run again with --confirm to sent emails."; >+} >+ >+for my $number_of_days (@days) { >+ say "Searching suggestions suggested $number_of_days ago" if $verbose; >+ >+ my $suggestions = C4::Suggestions::GetUnprocessedSuggestions($number_of_days); >+ >+ say "No suggestion found" if $verbose and not @$suggestions; >+ >+ for my $suggestion (@$suggestions) { >+ >+ 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'); >+ >+ if ($email_address) { >+ 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}, >+ tables => { >+ suggestions => $suggestion->{suggestionid}, >+ branches => $patron->{branchcode}, >+ }, >+ ); >+ if ( $confirm ) { >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->{borrowernumber}, >+ message_transport_type => 'email', >+ from_address => $admin_email_address, >+ } >+ ); >+ } >+ } else { >+ say "Patron $patron->{borrowernumber} does not have an email address" if $verbose; >+ } >+ } >+ >+} >+ >+=head1 NAME >+ >+notice_unprocessed_suggestions.pl - Generate notification for unprocessed suggestions. >+ >+The budget owner will be notified. >+ >+=head1 SYNOPSIS >+ >+notice_unprocessed_suggestions.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--days=NUMBER_OF_DAYS] >+ >+=head1 OPTIONS >+ >+=over >+ >+=item B<-h|--help> >+ >+Print a brief help message >+ >+=item B<-c|--confirm> >+ >+This flag must be provided in order for the script to actually >+generate notices. If it is not supplied, the script will >+only report on the patron it would have noticed. >+ >+=item B<--days> >+ >+This parameter is mandatory. >+It must contain an integer representing the number of days elapsed since the last modification of suggestions to process. >+ >+=item B<-v|--verbose> >+ >+Verbose mode. >+ >+=back >+ >+=head1 AUTHOR >+ >+Jonathan Druart <jonathan.druart@biblibre.com> >+ >+=head1 COPYRIGHT >+ >+Copyright 2014 BibLibre >+ >+=head1 LICENSE >+ >+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. >+ >+=cut >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13014
:
31950
|
31951
|
31952
|
33247
|
33265
|
33266
|
33267
|
33293
|
33294
|
34792
|
34793
|
34794
|
34795
|
34796
|
35603
|
35604
|
35605
|
35606
|
35607
|
36272
|
36273
|
36275
|
36276
|
36277
|
38006
|
38007
|
38009
|
38012
|
38013
|
38014
|
38015
|
38016
|
38017
|
40597