Bug 19743: Update header and footer on each item for checkin / checkout / renewal...
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 4 Dec 2017 16:16:52 +0000 (16:16 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 14 Aug 2018 11:55:07 +0000 (11:55 +0000)
When generating the checkout notice for a patron we only update the
section in between the '---' tags

For template toolkit purposes it means we cannot affect the content
based on more than a single item. For instance, we want to add the total
cost of all items checked out.

Test Plan:
1) Add "Thank you for visiting <<branches.branchname>>." to the bottom of the checkout notice. Below the second '----'.
2) Check out an item to a patron to generate that notice
3) Note the branch name in the notice
4) Update the branch name in the branches editor, change it to something else
5) Check out a 2nd item to that patron
6) Notice the items list updated, but the branch name did not
7) Apply this patch
8) Check out a 3rd item to that patron
9) Notice the branch name updated this time

Signed-off-by: Te Rauhina Jackson <terauhina.jackson@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/Message.pm

index 30b71c8..3783ce8 100644 (file)
@@ -311,10 +311,12 @@ If passed a string, it'll append the string to the message.
 # $object->append($letter_or_item) -- add a new item to a message's content
 sub append {
     my ($self, $letter_or_item, $format) = @_;
-    my $item;
+    my ( $item, $header, $footer );
     if (ref($letter_or_item)) {
         my $letter   = $letter_or_item;
         my $metadata = _metadata($letter);
+        $header = $metadata->{header};
+        $footer = $metadata->{footer};
         $item = $metadata->{body}->[0];
     } else {
         $item = $letter_or_item;
@@ -325,6 +327,8 @@ sub append {
     }
     my $metadata = $self->metadata;
     push @{$metadata->{body}}, $item;
+    $metadata->{header} = $header;
+    $metadata->{footer} = $footer;
     $self->metadata($metadata);
     my $new_content = $self->render_metadata($format);
     return $self->content($new_content);