From 994d6e2aac6092b7c852546eeca2253f59270e53 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 13 Nov 2010 15:43:27 -0500 Subject: [PATCH] bug 4211: more fixes to suggestion letter template handling * Now displays the correct list of fields to choose for suggestion letters. * Clean up mixture of old and new column selection code introduced in commit 88bb1b63, thereby restoring the intent of the patch for bug 3522. * Enable suggestion library to be used in suggestion letter templates Signed-off-by: Galen Charlton --- C4/Suggestions.pm | 1 + tools/letter.pl | 59 ++++------------------------------------------- 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 87a71e466a..d4529cb820 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -383,6 +383,7 @@ sub ModSuggestion { if ($$suggestion{STATUS}){ my $letter=C4::Letters::getletter('suggestions',$suggestion->{STATUS}); if ($letter){ + C4::Letters::parseletter($letter, 'branches', $suggestion->{branchcode}); C4::Letters::parseletter($letter, 'borrowers', $suggestion->{suggestedby}); C4::Letters::parseletter($letter, 'suggestions', $suggestion->{suggestionid}); C4::Letters::parseletter($letter, 'biblio', $suggestion->{biblionumber}); diff --git a/tools/letter.pl b/tools/letter.pl index 4416c3fee4..ab6039c6d2 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -47,42 +47,6 @@ use C4::Auth; use C4::Context; use C4::Output; -sub StringSearch { - my ($searchstring) = @_; - my $dbh = C4::Context->dbh; - $searchstring =~ s/\'/\\\'/g; - my @data = split( ' ', $searchstring ); - $data[0] = '' unless @data; - my $sth = $dbh->prepare("SELECT * FROM letter WHERE (code LIKE ?) ORDER BY module, code"); - $sth->execute("$data[0]%"); # slightly bogus, only searching on first string. - return $sth->fetchall_arrayref({}); -} - -# FIXME untranslateable -our %column_map = ( - aqbooksellers => 'BOOKSELLERS', - aqorders => 'ORDERS', - serial => 'SERIALS', - reserves => 'HOLDS', - suggestions => 'SUGGESTIONS', -); - -sub column_picks ($) { - # returns @array of values - my $table = shift or return (); - my $sth = C4::Context->dbh->prepare("SHOW COLUMNS FROM $table"); - $sth->execute; - my @SQLfieldname = (); - push @SQLfieldname, {'value' => "", 'text' => '---' . uc($column_map{$table} || $table) . '---'}; - while (my ($field) = $sth->fetchrow_array) { - push @SQLfieldname, { - value => $table . ".$field", - text => $table . ".$field" - }; - } - return @SQLfieldname; -} - # letter_exists($module, $code) # - return true if a letter with the given $module and $code exists sub letter_exists { @@ -182,26 +146,7 @@ sub add_form { $template->param( adding => 1 ); } - # add acquisition specific tables - my @SQLfieldname; my $field_selection; - if ( $module eq "suggestions" ) { - push @SQLfieldname, column_picks('borrowers'), - column_picks('suggestions'), - column_picks('aqbooksellers'), - column_picks('biblio'), - column_picks('items'); - } - elsif ( $module eq "reserves" ) { - push @SQLfieldname, column_picks('borrowers'), - column_picks('reserves'), - column_picks('biblio'), - column_picks('items'); - } - elsif ( index( $module, "acquisition" ) > 0 ) { # FIXME: imprecise comparison - push @SQLfieldname, column_picks('aqbooksellers'), column_picks('aqorders'); - # add issues specific tables - } push @{$field_selection}, add_fields('branches'); if ($module eq 'reserves') { push @{$field_selection}, add_fields('borrowers', 'reserves', 'biblio', 'items'); @@ -220,6 +165,9 @@ sub add_form { push @{$field_selection}, {value => "biblio.$_", text => ucfirst $_ }; } } + elsif ($module eq 'suggestions') { + push @{$field_selection}, add_fields('suggestions', 'borrowers', 'biblio'); + } else { push @{$field_selection}, add_fields('biblio','biblioitems'), {value => q{}, text => '---ITEMS---' }, @@ -340,6 +288,7 @@ sub get_columns_for { aqorders => '---ORDERS---', serial => '---SERIALS---', reserves => '---HOLDS---', + suggestions => '---SUGGESTIONS---', ); my @fields = (); if (exists $column_map{$table} ) { -- 2.39.5