From a9d792257955866e7db9db7e4311d653e37eebde 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. --- C4/Circulation.pm | 5 +++++ C4/Letters.pm | 23 ++++++++++++----------- tools/letter.pl | 9 ++++++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c26de76..24c7caf 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2738,11 +2738,16 @@ sub SendCirculationAlert { borrowernumber => $borrower->{borrowernumber}, message_name => $message_name{$type}, }); + my $issues_table = ( $type eq 'CHECKOUT' ) ? 'issues' : 'old_issues'; + warn "TYPE: $type"; + warn "ISSUES TABLE: $issues_table"; 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 89213fe..742994d 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 44f21ab..6363f8c 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'); } } -- 1.7.2.5