# 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
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
+
use CGI;
-use HTML::Template::Pro;
-use Data::Dumper;
use POSIX;
use Text::CSV_XS;
-use C4::Auth;
-use C4::Output;
-use C4::Context;
-use C4::Debug;
-use C4::Labels::Lib 1.000000 qw(get_barcode_types get_label_types get_font_types get_text_justification_types);
-use C4::Labels::Layout 1.000000;
+use C4::Auth qw(get_template_and_user);
+use C4::Output qw(output_html_with_http_headers);
+use C4::Creators 1.000000;
+use C4::Labels 1.000000;
my $cgi = new CGI;
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 {
my $csv = Text::CSV_XS->new({ allow_whitespace => 1 });
my $status = $csv->parse($format_string);
my @text_fields = $csv->fields();
- syslog("LOG_ERR", "labels/label-edit-layout.pl : Error parsing format_string. Parser returned: %s",$csv->error_input()) if $csv->error_input();
+ warn sprintf('Error parsing format_string. Parser returned: %s', $csv->error_input()) if $csv->error_input();
my $field_count = $#text_fields + 1;
POPULATE_TABLE:
foreach my $text_field (@text_fields) {
}
if ($op eq 'edit') {
- syslog("LOG_ERR", "labels/label-edit-layout.pl : Error performing '%s': No 'layout_id' passed in.", $op) unless ($layout);
+ warn sprintf("Error performing '%s': No 'layout_id' passed in.", $op) unless ($layout_id);
$layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
}
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))) {
$cgi->param('format_string', $format_string);
}
my @params = (
- barcode_type => $cgi->param('barcode_type'),
- printing_type => $cgi->param('printing_type'),
- layout_name => $cgi->param('layout_name'),
+ barcode_type => $cgi->param('barcode_type') || 'CODE39',
+ printing_type => $cgi->param('printing_type') || 'BAR',
+ layout_name => $cgi->param('layout_name') || 'DEFAULT',
guidebox => ($cgi->param('guidebox') ? 1 : 0),
- font => $cgi->param('font'),
- font_size => $cgi->param('font_size'),
+ font => $cgi->param('font') || 'TR',
+ font_size => $cgi->param('font_size') || 3,
callnum_split => ($cgi->param('callnum_split') ? 1 : 0),
- text_justify => $cgi->param('text_justify'),
- format_string => $cgi->param('format_string'),
+ text_justify => $cgi->param('text_justify') || 'L',
+ format_string => $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, callnumber',
);
if ($layout_id) { # if a label_id was passed in, this is an update to an existing layout
$layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
$layout->set_attr(@params);
- $layout->save();
+ $layout_id = $layout->save();
}
else { # if no label_id, this is a new layout so insert it
$layout = C4::Labels::Layout->new(@params);
- $layout->save();
+ $layout_id = $layout->save();
}
- print $cgi->redirect("label-manage.pl?label_element=layout");
+ print $cgi->redirect("label-manage.pl?label_element=layout" . ($layout_id == -1 ? "&element_id=$layout_id&op=$op&error=1" : ''));
exit;
}
else { # if we get here, this is a new layout
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;