Bugzilla – Attachment 40644 Details for
Bug 6810
Send membership expiry reminder notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6810 - Fix QA failures
0006-Bug-6810-Fix-QA-failures.patch (text/plain), 7.23 KB, created by
Amit Gupta
on 2015-06-26 06:40:25 UTC
(
hide
)
Description:
Bug 6810 - Fix QA failures
Filename:
MIME Type:
Creator:
Amit Gupta
Created:
2015-06-26 06:40:25 UTC
Size:
7.23 KB
patch
obsolete
>From 7e5778dfb13c64e0f9c4ff028f6e0d4ba19a246a Mon Sep 17 00:00:00 2001 >From: Amit Gupta <amit.gupta@informaticsglobal.com> >Date: Fri, 26 Jun 2015 10:52:01 +0530 >Subject: [PATCH 6/8] Bug 6810 - Fix QA failures > > - remove DateTime->now() > - use Koha::DateUtils->dt_from_string; > - use Pod2usage for the usage > - use Modern::Perl > - use branches table > - Change letter code from MEMEXP to MEMBERSHIP_EXPIRY >--- > C4/Members.pm | 6 +- > misc/cronjobs/membership_expiry.pl | 133 +++++++++++++++++++++++++++++++----- > 2 files changed, 120 insertions(+), 19 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index b0bd3be..f36d010 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -42,6 +42,8 @@ use Text::Unaccent qw( unac_string ); > use Koha::AuthUtils qw(hash_password); > use Koha::Database; > use Module::Load; >+use DateTime::Duration; >+ > if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { > load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync ); > } >@@ -1489,8 +1491,8 @@ sub GetExpiryDate { > > sub GetUpcomingMembershipExpires { > my $dbh = C4::Context->dbh; >- my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0; >- my $dateexpiry = DateTime->now()->add(days => $days)->ymd(); >+ my $days = DateTime::Duration->new(days => C4::Context->preference("MembershipExpiryDaysNotice") || 0); >+ my $dateexpiry = output_pref({ dt => (dt_from_string() + $days), dateformat => 'iso', dateonly => 1 }); > > my $query = " > SELECT borrowers.*, categories.description, >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index f92b77f..175e55e 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -2,7 +2,7 @@ > > # This file is part of Koha. > # >-# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com) >+# Copyright (C) 2015 Amit Gupta (amitddng135@gmail.com) > # > # Koha is free software; you can redistribute it and/or modify it > # under the terms of the GNU General Public License as published by >@@ -19,21 +19,28 @@ > > =head1 NAME > >-membership_expires.pl - cron script to put membership expiry reminders into message queue >+membership_expiry.pl - cron script to put memberships expires reminders into message queue > > =head1 SYNOPSIS > >-./membership_expires.pl -c >+./membership_expiry.pl -c > > or, in crontab: > >-0 1 * * * membership_expires.pl -c >+0 1 * * * membership_expiry.pl -c >+ >+=head1 DESCRIPTION >+ >+This script send memberships expires reminder notices to be sent to >+patrons. It queues them in the message queue, which is processed by >+the process_message_queue.pl cronjob. > > =cut > >-use strict; >-use warnings; >+ >+use Modern::Perl; > use Getopt::Long; >+use Pod::Usage; > use Data::Dumper; > BEGIN { > # find Koha's Perl modules >@@ -47,18 +54,109 @@ use C4::Letters; > use C4::Dates qw/format_date/; > use C4::Log; > >-cronlogaction(); >+ >+=head1 NAME >+ >+membership_expiry.pl - prepare messages to be sent to patrons for nearly memberships are going expires >+ >+=head1 SYNOPSIS >+ >+membership_expiry.pl [-c] >+ >+=head1 OPTIONS >+ >+=over 8 >+ >+=item B<--help> >+ >+Print a brief help message and exits. >+ >+=item B<--man> >+ >+Prints the manual page and exits. >+ >+=item B<-v> >+ >+Verbose. Without this flag set, only fatal errors are reported. >+ >+=item B<-n> >+ >+Do not send any email. Memberships expires notices that would have been sent to >+the patrons are printed to standard out. >+ >+=item B<-c> >+ >+Confirm flag: Add this option. The script will only print a usage >+statement otherwise. >+ >+=back >+ >+=head1 DESCRIPTION >+ >+This script is designed to alert send memberships expires notice >+ >+=head2 Configuration >+ >+This script pays attention to send the memberships expires notice >+The content of the messages is configured in Tools -> Notices and slips. Use the MEMBERSHIP_EXPIRY template >+ >+=head2 Outgoing emails >+ >+Typically, messages are prepared for each patron when the memberships are going to expires >+ >+ >+These emails are staged in the outgoing message queue, as are messages >+produced by other features of Koha. This message queue must be >+processed regularly by the >+F<misc/cronjobs/process_message_queue.pl> program. >+ >+In the event that the C<-n> flag is passed to this program, no emails >+are sent. Instead, messages are sent on standard output from this >+program. >+ >+=head2 Templates >+ >+Templates can contain variables enclosed in double angle brackets like >+E<lt>E<lt>thisE<gt>E<gt>. Those variables will be replaced with values >+specific to the members there membership expiry date is coming. >+Available variables are: >+ >+=over >+ >+=item E<lt>E<lt>borrowers.*E<gt>E<gt> >+ >+any field from the borrowers table >+ >+=item E<lt>E<lt>branches.*E<gt>E<gt> >+ >+any field from the branches table >+ >+=back >+ >+=head1 SEE ALSO >+ >+The F<misc/cronjobs/membership_expiry.pl> program allows you to send >+messages to patrons when the memberships are going to expires. >+=cut > > # These are defaults for command line options. >+ > my $confirm; # -c: Confirm that the user has read and configured this script. > my $nomail; # -n: No mail. Will not send any emails. > my $verbose= 0; # -v: verbose > >-GetOptions( 'c' => \$confirm, >- 'n' => \$nomail, >- 'v' => \$verbose, >- ); >+my $help = 0; >+my $man = 0; > >+GetOptions( >+ 'help|?' => \$help, >+ 'man' => \$man, >+ 'c' => \$confirm, >+ 'n' => \$nomail, >+ 'v' => \$verbose, >+ ) or pod2usage(2); >+pod2usage(1) if $help; >+pod2usage( -verbose => 2 ) if $man;; > > my $usage = << 'ENDUSAGE'; > This script prepares for membership expiry reminders to be sent to >@@ -71,13 +169,15 @@ This script has the following parameters : > -v verbose > ENDUSAGE > >-unless ($confirm) { >+unless ($confirm) { > print $usage; > print "Do you wish to continue? (y/n)"; > chomp($_ = <STDIN>); >- exit unless (/^y/i); >+ exit unless (/^y/i); > } > >+cronlogaction(); >+ > my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); > warn 'getting upcoming membership expires' if $verbose; > my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires(); >@@ -86,7 +186,7 @@ warn 'found ' . scalar( @$upcoming_mem_expires ) . ' issues' if $verbose; > > UPCOMINGMEMEXP: foreach my $recent ( @$upcoming_mem_expires ) { > my $from_address = $recent->{'branchemail'} || $admin_adress; >- my $letter_type = 'MEMEXP'; >+ my $letter_type = 'MEMBERSHIP_EXPIRY'; > my $letter = C4::Letters::getletter( 'members', $letter_type, $recent->{'branchcode'} ); > die "no letter of type '$letter_type' found. Please see sample_notices.sql" unless $letter; > >@@ -123,9 +223,8 @@ sub parse_letter { > } > my $letter = C4::Letters::GetPreparedLetter ( > module => 'members', >- letter_code => 'MEMEXP', >- branchcode => $params->{'branchcode'}, >- tables => {'borrowers', $params->{'borrowernumber'},}, >+ letter_code => 'MEMBERSHIP_EXPIRY', >+ tables => {'borrowers', $params->{'borrowernumber'}, 'branches', $params->{'branchcode'}}, > ); > } > >-- >1.7.9.5 >
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 6810
:
5375
|
9751
|
21870
|
21871
|
21872
|
22459
|
32683
|
32684
|
32689
|
32692
|
33954
|
40090
|
40091
|
40100
|
40120
|
40121
|
40122
|
40179
|
40180
|
40641
|
40642
|
40643
|
40644
|
40645
|
40646
|
40649
|
40665
|
40666
|
40667
|
40685
|
40686
|
40687
|
40688
|
40689
|
40690
|
40700
|
40701
|
40766
|
41916
|
42609
|
42610
|
42611
|
42612
|
42613
|
42700