Skip to content

Commit

Permalink
Bug 3706 Label templates/layouts do not save properly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cnighswonger authored and gmcharlt committed Oct 14, 2009
1 parent 3433edd commit 3bab38c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
8 changes: 4 additions & 4 deletions C4/Labels/Profile.pm
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -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.
#
Expand Down
Expand Up @@ -65,7 +65,7 @@
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<li>
<fieldset>
<legend>Bibliographic Data to Print</legend>
<ol>
Expand Down Expand Up @@ -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" -->" />
Expand All @@ -111,7 +111,7 @@
</div>
</fieldset></li>
</ol>
</fieldset>
</fieldset>
</li>
<li>
<label for="guidebox">Draw Guide Boxes</label>
Expand Down
6 changes: 4 additions & 2 deletions labels/label-edit-layout.pl
Expand Up @@ -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
Expand Down Expand Up @@ -44,6 +44,7 @@

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 {
Expand Down Expand Up @@ -108,7 +109,7 @@ sub _select_format_string { # generate field table based on format_string
}
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))) {
Expand Down Expand Up @@ -165,5 +166,6 @@ sub _select_format_string { # generate field table based on format_string
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;
11 changes: 7 additions & 4 deletions labels/label-edit-template.pl
Expand Up @@ -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
Expand Down Expand Up @@ -41,6 +41,7 @@
);

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;
Expand Down Expand Up @@ -85,9 +86,11 @@
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;
Expand Down

0 comments on commit 3bab38c

Please sign in to comment.