[Koha-patches] [PATCH] [SIGNED-OFF] Fix for Bug 4419 - cannot change module for notice templates
Nicole C. Engard
nengard at bywatersolutions.com
Sun Aug 21 11:57:35 CEST 2011
From: Owen Leonard <oleonard at myacpl.org>
Adding a hidden form field to contain the original module
so that it can be used in the check for an existing entry.
Signed-off-by: Nicole C. Engard <nengard at bywatersolutions.com>
---
.../intranet-tmpl/prog/en/modules/tools/letter.tt | 1 +
tools/letter.pl | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 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 1ec73c5..063236e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
@@ -184,6 +184,7 @@ $(document).ready(function() {
<ol>
<li>
<label for="module">Koha module:</label>
+ <input type="hidden" name="oldmodule" value="[% module %]" />
[% IF ( modify ) %]<select name="module" id="module">[% END %] [% IF ( adding ) %] <select name="module" id="module" onchange="javascript:window.location.href = unescape(window.location.pathname)+'?op=add_form&module='+this.value+'&content='+window.document.forms['Aform'].elements['content'].value;">[% END %]
[% IF ( catalogue ) %]
<option value="catalogue" selected="selected">Catalog</option>
diff --git a/tools/letter.pl b/tools/letter.pl
index 39c2ffb..f5dc0c6 100755
--- a/tools/letter.pl
+++ b/tools/letter.pl
@@ -179,6 +179,7 @@ sub add_form {
name => $letter->{name},
title => $letter->{title},
content => $letter->{content},
+ module => $module,
$module => 1,
SQLfieldname => $field_selection,
);
@@ -186,18 +187,19 @@ sub add_form {
}
sub add_validate {
- my $dbh = C4::Context->dbh;
- my $module = $input->param('module');
- my $code = $input->param('code');
- my $name = $input->param('name');
- my $title = $input->param('title');
- my $content = $input->param('content');
- if (letter_exists($module, $code)) {
+ my $dbh = C4::Context->dbh;
+ my $module = $input->param('module');
+ my $oldmodule = $input->param('oldmodule');
+ my $code = $input->param('code');
+ my $name = $input->param('name');
+ my $title = $input->param('title');
+ my $content = $input->param('content');
+ if (letter_exists($oldmodule, $code)) {
$dbh->do(
q{UPDATE letter SET module = ?, code = ?, name = ?, title = ?, content = ? WHERE module = ? AND code = ?},
undef,
$module, $code, $name, $title, $content,
- $module, $code
+ $oldmodule, $code
);
} else {
$dbh->do(
--
1.7.2.3
More information about the Koha-patches
mailing list