From 57155db21305264404f5afd2788233103d038cb6 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Wed, 29 Sep 2010 09:27:30 -0400 Subject: [PATCH] Bug 5263 - Add support for including fields from the ISSUES table in advanced due notices Adding support for including fields from the Issues table in advanced due notices. This is primarily to allow the inclusion of the due date for each item in the advanced due notice, but will allow the inclusion of any field from the ISSUES table. This also adds code to exclude timestamp fields as these are irrelevant to the end user in this context. Note: Documentation should be updated to reflect the availability of the additional fields in all circulation notices. Signed-off-by: Katrin Fischer Signed-off-by: Chris Cormack --- C4/Letters.pm | 2 ++ misc/cronjobs/advance_notices.pl | 7 ++++++- tools/letter.pl | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index cb47c7ec79..6846a00e98 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -489,6 +489,8 @@ sub parseletter_sth { ($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 'suggestions' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : ($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 = ?" : diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index a573e96588..3ca483569f 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -170,6 +170,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { borrowernumber => $upcoming->{'borrowernumber'}, branchcode => $upcoming->{'branchcode'}, biblionumber => $biblio->{'biblionumber'}, + itemnumber => $upcoming->{'itemnumber'}, substitute => { 'items.content' => $titles } } ); } @@ -201,6 +202,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { borrowernumber => $upcoming->{'borrowernumber'}, branchcode => $upcoming->{'branchcode'}, biblionumber => $biblio->{'biblionumber'}, + itemnumber => $upcoming->{'itemnumber'}, substitute => { 'items.content' => $titles } } ); } @@ -345,10 +347,13 @@ sub parse_letter { if ( $params->{'branchcode'} ) { C4::Letters::parseletter( $params->{'letter'}, 'branches', $params->{'branchcode'} ); } - + if ( $params->{'itemnumber'} ) { + C4::Letters::parseletter( $params->{'letter'}, 'issues', $params->{'itemnumber'} ); + } if ( $params->{'biblionumber'} ) { C4::Letters::parseletter( $params->{'letter'}, 'biblio', $params->{'biblionumber'} ); C4::Letters::parseletter( $params->{'letter'}, 'biblioitems', $params->{'biblionumber'} ); + C4::Letters::parseletter( $params->{'letter'}, 'items', $params->{'biblionumber'} ); } return $params->{'letter'}; diff --git a/tools/letter.pl b/tools/letter.pl index ab6039c6d2..39c2ffb3ba 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -172,7 +172,7 @@ sub add_form { push @{$field_selection}, add_fields('biblio','biblioitems'), {value => q{}, text => '---ITEMS---' }, {value => 'items.content', text => 'items.content'}, - add_fields('borrowers'); + add_fields('issues','borrowers'); } $template->param( @@ -309,6 +309,7 @@ sub get_columns_for { my $table_prefix = $table . q|.|; my $rows = C4::Context->dbh->selectall_arrayref($sql, { Slice => {} }); for my $row (@{$rows}) { + next if $row->{'Field'} eq 'timestamp'; # this is really an irrelevant field and there may be other common fields that should be excluded from the list push @fields, { value => $table_prefix . $row->{Field}, text => $table_prefix . $row->{Field}, -- 2.39.5