From fd23761d4d78ccb58baf168b6ffd523d90163a8b 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. Signed-off-by: Katrin Fischer I like the idea to show a warning, but I would perhaps move it under the message body label to be more obvious. Patch works nicely, branch data of my user's home library is displayed in the notice. --- .../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 374b2f1ce6..c156e01835 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 e89b8ae830..fac95dbb80 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__ -- 2.39.5