[Koha-patches] [PATCH] [SIGNED-OFF] Bug 5263 - Add support for including fields from the ISSUES table in advanced due notices

Katrin Fischer Katrin.Fischer.83 at web.de
Sun Jul 17 23:43:55 CEST 2011


From: Chris Nighswonger <cnighswonger at foundations.edu>

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 <Katrin.Fischer.83 at web.de>
---
 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 cb47c7e..6846a00 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 a573e96..3ca4835 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 ab6039c..39c2ffb 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},
-- 
1.7.4.1



More information about the Koha-patches mailing list