From ff3cba4f9fe7ec77ad114af70bf2805db9e9c04c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 29 Mar 2012 11:35:33 -0400 Subject: [PATCH] Bug 7848 - Issues data missing from circulation notices For the CHECKIN and CHECKOUT notices, any data that is issue specific does not show. For example, date due. For CHECKOUT, this is caused not passing in the issues table as part of the 'table' hash used by C4::Letters::GetPreparedLetter. For CHECKIN notices, we need the old_issues table instead, as the item has already been returned. Signed-off-by: Liz Rea passes tests, correct information shows in notices. Signed-off-by: Paul Poulain Signed-off-by: Chris Cormack --- C4/Circulation.pm | 3 +++ C4/Letters.pm | 23 ++++++++++++----------- tools/letter.pl | 9 ++++++++- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index d41da1f1c5..39006e92e9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2740,11 +2740,14 @@ sub SendCirculationAlert { borrowernumber => $borrower->{borrowernumber}, message_name => $message_name{$type}, }); + my $issues_table = ( $type eq 'CHECKOUT' ) ? 'issues' : 'old_issues'; my $letter = C4::Letters::GetPreparedLetter ( module => 'circulation', letter_code => $type, branchcode => $branch, tables => { + $issues_table => $item->{itemnumber}, + 'items' => $item->{itemnumber}, 'biblio' => $item->{biblionumber}, 'biblioitems' => $item->{biblionumber}, 'borrowers' => $borrower, diff --git a/C4/Letters.pm b/C4/Letters.pm index b2fabde8d3..2c0e34c6d4 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -552,17 +552,18 @@ sub _parseletter_sth { # check cache first (defined $handles{$table}) and return $handles{$table}; my $query = - ($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : - ($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : - ($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : - ($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : - ($table eq 'reserves' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : - ($table eq 'borrowers' ) ? "SELECT * FROM $table WHERE borrowernumber = ?" : - ($table eq 'branches' ) ? "SELECT * FROM $table WHERE branchcode = ?" : - ($table eq 'suggestions' ) ? "SELECT * FROM $table WHERE suggestionid = ?" : - ($table eq 'aqbooksellers') ? "SELECT * FROM $table WHERE id = ?" : - ($table eq 'aqorders' ) ? "SELECT * FROM $table WHERE ordernumber = ?" : - ($table eq 'opac_news' ) ? "SELECT * FROM $table WHERE idnew = ?" : + ($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : + ($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : + ($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : + ($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : + ($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE itemnumber = ? ORDER BY timestamp DESC LIMIT 1" : + ($table eq 'reserves' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : + ($table eq 'borrowers' ) ? "SELECT * FROM $table WHERE borrowernumber = ?" : + ($table eq 'branches' ) ? "SELECT * FROM $table WHERE branchcode = ?" : + ($table eq 'suggestions' ) ? "SELECT * FROM $table WHERE suggestionid = ?" : + ($table eq 'aqbooksellers') ? "SELECT * FROM $table WHERE id = ?" : + ($table eq 'aqorders' ) ? "SELECT * FROM $table WHERE ordernumber = ?" : + ($table eq 'opac_news' ) ? "SELECT * FROM $table WHERE idnew = ?" : undef ; unless ($query) { warn "ERROR: No _parseletter_sth query for table '$table'"; diff --git a/tools/letter.pl b/tools/letter.pl index 44f21abce4..317ea837b2 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -196,9 +196,16 @@ sub add_form { push @{$field_selection}, add_fields('biblio','biblioitems'), {value => q{}, text => '---ITEMS---' }, {value => 'items.content', text => 'items.content'}, - add_fields('issues','borrowers'); + add_fields('borrowers'); if ($module eq 'circulation') { push @{$field_selection}, add_fields('opac_news'); + + } + + if ( $module eq 'circulation' && $code eq "CHECKIN" ) { + push @{$field_selection}, add_fields('old_issues'); + } else { + push @{$field_selection}, add_fields('issues'); } } -- 2.39.5