From a46714b1d7afb5bec1f40503e26cb7c1d61d400a Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Mon, 12 Oct 2009 11:50:59 -0400 Subject: [PATCH] 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 --- C4/Labels/Profile.pm | 8 ++++---- .../prog/en/modules/labels/label-edit-layout.tmpl | 8 ++++---- labels/label-edit-layout.pl | 6 ++++-- labels/label-edit-template.pl | 11 +++++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/C4/Labels/Profile.pm b/C4/Labels/Profile.pm index 5cc4f73037..bfaae55ad2 100644 --- a/C4/Labels/Profile.pm +++ b/C4/Labels/Profile.pm @@ -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. # diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tmpl index 425383fef1..a9f1ff3972 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tmpl @@ -65,7 +65,7 @@ -
  • +
  • Bibliographic Data to Print
      @@ -96,11 +96,11 @@ - +
    1. - +
    2. " /> @@ -111,7 +111,7 @@
    -
    +
  • diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index f47e8e61d8..5bb8fc6404 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -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; diff --git a/labels/label-edit-template.pl b/labels/label-edit-template.pl index 038a164d34..cc539c5e68 100755 --- a/labels/label-edit-template.pl +++ b/labels/label-edit-template.pl @@ -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; -- 2.39.5