my $format_string = shift;
my $csv = Text::CSV_XS->new({allow_whitespace => 1});
my $status = $csv->parse($format_string);
- my @sorted_fields = map {{ 'code' => $_, desc => $_ }} $csv->fields();
+ my @sorted_fields = map {{ 'code' => $_, desc => $_ }}
+ map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
+ $csv->fields();
my $error = $csv->error_input();
warn sprintf('Text field sort failed with this error: %s', $error) if $error;
return \@sorted_fields;
LOCK TABLES `creator_layouts` WRITE;
/*!40000 ALTER TABLE `creator_layouts` DISABLE KEYS */;
-INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','<opt></opt>','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','<opt></opt>','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','<opt></opt>','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','<opt page_side="F" units="POINT">
+INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','<opt></opt>','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','<opt></opt>','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','<opt></opt>','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','<opt page_side="F" units="POINT">
<images name="image_1" Dx="72" Ox="0" Oy="0" Sx="0" Sy="0" Tx="4.5" Ty="63">
<data_source image_name="none" image_source="patronimages" />
</images>
LOCK TABLES `creator_layouts` WRITE;
/*!40000 ALTER TABLE `creator_layouts` DISABLE KEYS */;
-INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','<opt></opt>','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','<opt></opt>','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','<opt></opt>','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','<opt page_side="F" units="POINT">
+INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','<opt></opt>','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','<opt></opt>','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','<opt></opt>','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','<opt page_side="F" units="POINT">
<images name="image_1" Dx="72" Ox="0" Oy="0" Sx="0" Sy="0" Tx="4.5" Ty="63">
<data_source image_name="none" image_source="patronimages" />
</images>
format_string => $layout->get_attr('format_string'),
);
my $format_string = $layout->get_attr('format_string');
- my @data_fields = split(/, /, $format_string);
+ my @data_fields = map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
+ split(/, /, $format_string);
my $csv_data = $label->csv_data();
- for (my $i = 0; $i < (scalar(@data_fields) - 1); $i++) {
+ for (my $i = 0; $i <= (scalar(@data_fields) - 1); $i++) {
push(@{$xml_data->{'label'}[$item_count]->{$data_fields[$i]}}, $$csv_data[$i]);
}
$item_count++;
font_size => $cgi->param('font_size') || 3,
callnum_split => ($cgi->param('callnum_split') ? 1 : 0),
text_justify => $cgi->param('text_justify') || 'L',
- format_string => $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, callnumber',
+ format_string => $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber',
);
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);
--- /dev/null
+#!/usr/bin/perl
+#
+# 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.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# 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
+#
+# for context, see http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=2691
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+BEGIN {
+ use_ok('C4::Labels::Label');
+}
+
+my $format_string = "title, callnumber";
+my $parsed_fields = C4::Labels::Label::_get_text_fields($format_string);
+my $expected_fields = [
+ { code => 'title', desc => 'title' },
+ { code => 'itemcallnumber', desc => 'itemcallnumber' },
+];
+is_deeply($parsed_fields, $expected_fields, '"callnumber" in label layout alias for "itemcallnumber" per bug 5653');