Bug 7848 - Issues data missing from circulation notices
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 29 Mar 2012 15:35:33 +0000 (11:35 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 10 Jul 2012 11:50:10 +0000 (13:50 +0200)
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 <wizzyrea@gmail.com>
passes tests, correct information shows in notices.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Circulation.pm
C4/Letters.pm
tools/letter.pl

index ca2e94d..efb720b 100644 (file)
@@ -2747,11 +2747,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,
index 4bde166..893419c 100644 (file)
@@ -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'";
index 44f21ab..317ea83 100755 (executable)
@@ -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');
         }
     }