From 3b9bcfec1a7a12c11aa0f4eaf845dc5fe28b679d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 4 Apr 2012 09:56:11 -0400 Subject: [PATCH] Bug 3383 - Item due reminder digests - cannot display title information Adds the ability to use branches.* fields in digest notices and have them be parsed correctly. Also adds a warning to the notices editor for digests. --- .../intranet-tmpl/prog/en/modules/tools/letter.tt | 1 + misc/cronjobs/advance_notices.pl | 39 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index a0c2c37..01cc70f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -319,6 +319,7 @@ $(document).ready(function() { + [% IF code.search('DGST') %] Warning, this is a template for a Digest, as such, any references to branch data ( e.g. branches.branchname ) will refer to the borrower's home branch. [% END %]
Cancel
diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index de00846..17d0a7d 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -160,7 +160,8 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields; $titles .= join("\t",@item_info) . "\n"; } - + + ## Get branch info for borrowers home library. $letter = parse_letter( { letter_code => $letter_type, borrowernumber => $upcoming->{'borrowernumber'}, branchcode => $upcoming->{'branchcode'}, @@ -191,7 +192,8 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields; $titles .= join("\t",@item_info) . "\n"; } - + + ## Get branch info for borrowers home library. $letter = parse_letter( { letter_code => $letter_type, borrowernumber => $upcoming->{'borrowernumber'}, branchcode => $upcoming->{'branchcode'}, @@ -252,10 +254,15 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields; $titles .= join("\t",@item_info) . "\n"; } + + ## Get branch info for borrowers home library. + my %branch_info = get_branch_info( $borrowernumber ); + my $letter = parse_letter( { letter_code => $letter_type, borrowernumber => $borrowernumber, substitute => { count => $count, - 'items.content' => $titles + 'items.content' => $titles, + %branch_info, } } ) or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; @@ -290,10 +297,15 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields; $titles .= join("\t",@item_info) . "\n"; } + + ## Get branch info for borrowers home library. + my %branch_info = get_branch_info( $borrowernumber ); + my $letter = parse_letter( { letter_code => $letter_type, borrowernumber => $borrowernumber, substitute => { count => $count, - 'items.content' => $titles + 'items.content' => $titles, + %branch_info, } } ) or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; @@ -353,6 +365,25 @@ sub format_date { return output_pref($dt); } +=head2 get_branch_info + +=cut + +sub get_branch_info { + my ( $borrowernumber ) = @_; + + ## Get branch info for borrowers home library. + my $borrower_details = C4::Members::GetMemberDetails( $borrowernumber ); + my $borrower_branchcode = $borrower_details->{'branchcode'}; + my $branch = C4::Branch::GetBranchDetail( $borrower_branchcode ); + my %branch_info; + foreach my $key( keys %$branch ) { + $branch_info{"branches.$key"} = $branch->{$key}; + } + + return %branch_info; +} + 1; __END__ -- 1.7.2.5