Bug 3706 Label templates/layouts do not save properly

Two issues here:

1. No radio box was selected by default in the format section of the layout editor. This actually needs some additional attention to allow the user
to establish a default method of entering the format string. As noted in comments in the code, this would probably be best implimented by adding yet
another syspref. However, I don't have time atm.

2. On saving a new template, if no profile was assigned to the new template, the script threw an error and died.

Both issues are addressed in this patch.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Chris Nighswonger 2009-10-12 11:50:59 -04:00 committed by Galen Charlton
parent 3433edd1c4
commit 3bab38c3fc
4 changed files with 19 additions and 14 deletions

View file

@ -77,7 +77,7 @@ sub retrieve {
my $invocant = shift;
my %opts = @_;
my $type = ref($invocant) || $invocant;
my $query = "SELECT * FROM printers_profile WHERE profile_id = ?";
my $query = "SELECT * FROM printers_profile WHERE profile_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{profile_id});
if ($sth->err) {
@ -109,7 +109,7 @@ sub delete {
warn sprintf('%s : Cannot delete layout as the profile id is invalid or non-existant.', $call_type);
return -1;
}
my $query = "DELETE FROM printers_profile WHERE profile_id = ?";
my $query = "DELETE FROM printers_profile WHERE profile_id = ?";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute($query_param);
@ -299,7 +299,7 @@ Copyright 2009 Foundations Bible College.
=head1 LICENSE
This file is part of Koha.
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version.
@ -319,7 +319,7 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#=head2 draw_boundaries
#
# sub draw_boundaries ($llx_spine, $llx_circ1, $llx_circ2,
# $lly, $spine_width, $label_height, $circ_width)
# $lly, $spine_width, $label_height, $circ_width)
#
#This sub draws boundary lines where the label outlines are, to aid in printer testing, and debugging.
#

View file

@ -65,7 +65,7 @@
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<li>
<fieldset>
<legend>Bibliographic Data to Print</legend>
<ol>
@ -96,11 +96,11 @@
<!-- /TMPL_LOOP -->
</div>
</li>
<!-- TMPL_IF NAME="layout_string" -->
<!-- TMPL_UNLESS NAME="layout_string" -->
<li class="radio"><input type="radio" id="layout_choice_list" name="layout_choice" value="layout_string" checked="checked" /> <label for="layout_choice_list">List Fields</label></li>
<!-- TMPL_ELSE -->
<li class="radio"><input type="radio" id="layout_choice_list" name="layout_choice" value="layout_string" /> <label for="layout_choice_list">List Fields</label></li>
<!-- /TMPL_IF -->
<!-- /TMPL_UNLESS -->
<li> <fieldset id="layout_string" class="brief">
<label for="format_string">Data Fields</label>
<input type="text" name="format_string" id="format_string" size="80" value="<!-- TMPL_VAR ESCAPE='HTML' NAME="format_string" -->" />
@ -111,7 +111,7 @@
</div>
</fieldset></li>
</ol>
</fieldset>
</fieldset>
</li>
<li>
<label for="guidebox">Draw Guide Boxes</label>

View file

@ -4,7 +4,7 @@
# Parts Copyright 2009 Foundations Bible College.
#
# This file is part of Koha.
#
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@ -44,6 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $op = $cgi->param('op') || $ARGV[0] || '';
my $layout_id = $cgi->param('layout_id') || $cgi->param('element_id') || $ARGV[1] || '';
my $layout_choice = $cgi->param('layout_choice') || '';
my $layout = '';
sub _set_selected {
@ -108,7 +109,7 @@ if ($op eq 'edit') {
}
elsif ($op eq 'save') {
my $format_string = '';
if ($cgi->param('layout_choice') eq 'layout_table') { # translate the field table into a format_string
if ($layout_choice eq 'layout_table') { # translate the field table into a format_string
my @layout_table = ();
foreach my $cgi_param ($cgi->param()) {
if (($cgi_param =~ m/^(.*)_tbl$/) && ($cgi->param($cgi_param))) {
@ -165,5 +166,6 @@ $template->param(
font_size => $layout->get_attr('font_size'),
callnum_split => $layout->get_attr('callnum_split'),
format_string => $layout->get_attr('format_string'),
layout_string => 1, # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
);
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -4,7 +4,7 @@
# Parts Copyright 2009 Foundations Bible College.
#
# This file is part of Koha.
#
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@ -41,6 +41,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
my $op = $cgi->param('op');
warn "operation = $op\n";
my $template_id = $cgi->param('template_id') || $cgi->param('element_id');
my $label_template = undef;
my $profile_list = undef;
@ -85,9 +86,11 @@ elsif ($op eq 'save') {
else { # if no label_id, this is a new layout so insert it
$label_template = C4::Labels::Template->new(@params);
my $template_id = $label_template->save();
my $profile = C4::Labels::Profile->retrieve(profile_id => $cgi->param('profile_id'));
$profile->set_attr(template_id => $template_id) if $template_id != $profile->get_attr('template_id');
$profile->save();
if ($cgi->param('profile_id')) {
my $profile = C4::Labels::Profile->retrieve(profile_id => $cgi->param('profile_id'));
$profile->set_attr(template_id => $template_id) if $template_id != $profile->get_attr('template_id');
$profile->save();
}
}
print $cgi->redirect("label-manage.pl?label_element=template");
exit;