From ec82a1fabbd80eafcbd23401b68d802e2aeafb6b Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Fri, 21 Nov 2014 10:28:02 +0100
Subject: [PATCH] [PASSED QA] Bug 13215: Fix notice deletion

This patch could have only been
-        name => $values[0]->{name},
+        name => $letter->{name},

Other changes are just indentation and variable names (send an hashref
$letter to the template and use the Branches TT plugin to display the
branch name)

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
 .../intranet-tmpl/prog/en/modules/tools/letter.tt  | 63 +++++++++++-----------
 tools/letter.pl                                    |  6 +--
 2 files changed, 33 insertions(+), 36 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
index 7c68f22..cfda11c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
@@ -1,4 +1,5 @@
 [% USE Koha %]
+[% USE Branches %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm deletion[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -424,40 +425,40 @@ $(document).ready(function() {
 	<input type="submit" value="OK" />
 	</form>
 [% END %]
-	
-[% IF ( delete_confirm ) %]
-    <div class="dialog alert"><h3>Delete notice?</h3>
-	<table>
-        <thead>
-		<tr>
-			<th>Library</th>
-			<th>Module</th>
-			<th>Code</th>
-			<th>Name</th>
-		</tr>
-        </thead>
-		<tr>
-			<td>[% branchname %]</td>
-			<td>[% module %]</td>
-            <td>[% code %]</td>
-			<td>[% name %]</td>
-		</tr>
-	</table>
-		<form action="[% action %]" method="post">
-		<input type="hidden" name="op" value="delete_confirmed">
-		<input type="hidden" name="branchcode" value="[% branchcode %]" />
-		<input type="hidden" name="code" value="[% code %]" />
-		<input type="hidden" name="module" value="[% module %]" />
-                <input type="submit" value="Yes, delete" class="approve" />
-				</form>
 
-				<form action="[% action %]" method="get">
-                    <input type="submit" value="No, do not delete" class="deny" />
-				</form>
-		</div>
+[% IF ( delete_confirm ) %]
+    <div class="dialog alert">
+        <h3>Delete notice?</h3>
+        <table>
+            <thead>
+            <tr>
+                <th>Library</th>
+                <th>Module</th>
+                <th>Code</th>
+                <th>Name</th>
+            </tr>
+            </thead>
+            <tr>
+                <td>[% Branches.GetName( letter.branchcode ) %]</td>
+                <td>[% letter.module %]</td>
+                <td>[% letter.code %]</td>
+                <td>[% letter.name %]</td>
+            </tr>
+        </table>
+            <form action="[% action %]" method="post">
+            <input type="hidden" name="op" value="delete_confirmed">
+            <input type="hidden" name="branchcode" value="[% letter.branchcode %]" />
+            <input type="hidden" name="code" value="[% letter.code %]" />
+            <input type="hidden" name="module" value="[% letter.module %]" />
+            <input type="submit" value="Yes, delete" class="approve" />
+        </form>
 
+        <form action="[% action %]" method="get">
+            <input type="submit" value="No, do not delete" class="deny" />
+        </form>
+    </div>
 [% END %]
-	
+
 [% IF ( delete_confirmed ) %]
 	Data deleted
 	<form action="[% action %]" method="post">
diff --git a/tools/letter.pl b/tools/letter.pl
index 66d78be..4fcd8a8 100755
--- a/tools/letter.pl
+++ b/tools/letter.pl
@@ -289,11 +289,7 @@ sub delete_confirm {
     my $letter = C4::Letters::getletter($module, $code, $branchcode);
     my @values = values %$letter;
     $template->param(
-        branchcode => $branchcode,
-        branchname => GetBranchName($branchcode),
-        code => $code,
-        module => $module,
-        name => $values[0]->{name},
+        letter => $letter,
     );
     return;
 }
-- 
1.9.1