my (
$barcodetype, $title, $subtitle, $isbn, $issn,
- $itemtype, $bcn, $dcn, $classif,
- $subclass, $itemcallnumber, $author, $tmpl_id,
+ $itemtype, $bcn, $text_justify, $callnum_split,
+ $itemcallnumber, $author, $tmpl_id,
$printingtype, $guidebox, $startlabel, $layoutname, $formatstring
) = @_;
$sth2->execute();
$query2 = "INSERT INTO labels_conf
( barcodetype, title, subtitle, isbn,issn, itemtype, barcode,
- dewey, classification, subclass, itemcallnumber, author, printingtype,
+ text_justify, callnum_split, itemcallnumber, author, printingtype,
guidebox, startlabel, layoutname, formatstring, active )
- values ( ?, ?,?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?,?,?, 1 )";
+ values ( ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?, 1 )";
$sth2 = $dbh->prepare($query2);
$sth2->execute(
$barcodetype, $title, $subtitle, $isbn, $issn,
- $itemtype, $bcn, $dcn, $classif,
- $subclass, $itemcallnumber, $author, $printingtype,
+ $itemtype, $bcn, $text_justify, $callnum_split,
+ $itemcallnumber, $author, $printingtype,
$guidebox, $startlabel, $layoutname, $formatstring
);
$sth2->finish;
my (
$barcodetype, $title, $subtitle, $isbn, $issn,
- $itemtype, $bcn, $dcn, $classif,
- $subclass, $itemcallnumber, $author, $tmpl_id,
+ $itemtype, $bcn, $text_justify, $callnum_split,
+ $itemcallnumber, $author, $tmpl_id,
$printingtype, $guidebox, $startlabel, $layoutname, $formatstring,
$layout_id
) = @_;
my $dbh = C4::Context->dbh;
my $query2 = "update labels_conf set
barcodetype=?, title=?, subtitle=?, isbn=?,issn=?,
- itemtype=?, barcode=?, dewey=?, classification=?,
- subclass=?, itemcallnumber=?, author=?, printingtype=?,
+ itemtype=?, barcode=?, text_justify=?, callnum_split=?,
+ itemcallnumber=?, author=?, printingtype=?,
guidebox=?, startlabel=?, layoutname=?, formatstring=? where id = ?";
my $sth2 = $dbh->prepare($query2);
$sth2->execute(
$barcodetype, $title, $subtitle, $isbn, $issn,
- $itemtype, $bcn, $dcn, $classif,
- $subclass, $itemcallnumber, $author, $printingtype,
+ $itemtype, $bcn, $text_justify, $callnum_split,
+ $itemcallnumber, $author, $printingtype,
$guidebox, $startlabel, $layoutname, $formatstring, $layout_id
);
$sth2->finish;
sub GetBarcodeData {
my ( $f, $item, $record ) = @_;
my $kohatables = &_descKohaTables();
+use Data::Dumper;
+warn Dumper($kohatables);
my $datastring = '';
my $match_kohatable = join(
'|',
@{ $kohatables->{items} }
)
);
- while ($f) {
+ while ($f) { warn $f;
$f =~ s/^\s?//;
if ( $f =~ /^'(.*)'.*/ ) {
# single quotes indicate a static text string.
}
elsif ( $f =~ /^([0-9a-z]{3})(\w)(\W?).*?/ ) {
my $marc_field = $1;
+ $datastring .= $record->subfield($1,$2) . $3 if($record->subfield($1,$2)) ;
foreach my $subfield ($record->field($marc_field)) {
if ( $subfield->subfield('9') eq $item->{'itemnumber'} ) {
$datastring .= $subfield->subfield($2 ) . $3;
$f = $';
}
else {
+ warn "failed to parse label formatstring: $f";
last; # Failed to match
}
}
my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
- my @str_fields = get_text_fields($layout_id, 'codes' );
+ my @str_fields = get_text_fields($layout_id, 'codes' );
my $record = GetMarcBiblio($$item->{biblionumber});
# FIXME - returns all items, so you can't get data from an embedded holdings field.
# TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum).
# Grab the cn_source and if that is NULL, the DefaultClassificationSource syspref
my $cn_source = ($$item->{'cn_source'} ? $$item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource'));
-
for my $field (@str_fields) {
$field->{'code'} or warn "get_text_fields($layout_id, 'codes') element missing 'code' field";
- if ($$conf_data->{'formatstring'}) {
- $field->{'data'} = GetBarcodeData($field->{'code'},$$item,$record) ;
- }
- elsif ($field->{'code'} eq 'itemtype') {
+ if ($field->{'code'} eq 'itemtype') {
$field->{'data'} = C4::Context->preference('item-level_itypes') ? $$item->{'itype'} : $$item->{'itemtype'};
}
+ elsif ($$conf_data->{'formatstring'}) {
+ # if labels_conf.formatstring has a value, then it overrides the hardcoded option.
+ $field->{'data'} = GetBarcodeData($field->{'code'},$$item,$record) ;
+ }
else {
$field->{data} = $$item->{$field->{'code'}} ;
}
$str =~ s/\n//g;
$str =~ s/\r//g;
my @strings;
- my @callnumber_list = ('itemcallnumber', '050a', '050b', '082a', '952o'); # Fields which hold call number data
- if ((grep {$field->{code} =~ m/$_/} @callnumber_list) and ($printingtype eq 'BIB')) { # If the field contains the call number, we do some sp
+ my @callnumber_list = ('itemcallnumber', '050a', '050b', '082a', '952o'); # Fields which hold call number data ( 060? 090? 092? 099? )
+ if ((grep {$field->{code} =~ m/$_/} @callnumber_list) and ($printingtype eq 'BIB') and ($$conf_data->{'callnum_split'})) { # If the field contains the call number, we do some sp
if ($cn_source eq 'lcc') {
@strings = split_lccn($str);
@strings = split_fcn($str) if !@strings; # If it was not a true lccn, try it as a fiction call number
# loop for each string line
foreach my $str (@strings) {
my $hPos = 0;
- if ( $printingtype eq 'BIB' ) { #FIXME: This is a hack and needs to be implimented as a text justification option in the template...
- # some code to try and center each line on the label based on font size and string point width...
- my $stringwidth = prStrWidth($str, $fontname, $fontsize);
- my $whitespace = ( $label_width - ( $stringwidth + (2 * $left_text_margin) ) );
- $hPos = ( ( $whitespace / 2 ) + $x_pos + $left_text_margin );
- #warn "\$label_width=$label_width \$stringwidth=$stringwidth \$whitespace=$whitespace \$left_text_margin=$left_text_margin for $str\n";
+ my $stringwidth = prStrWidth($str, $fontname, $fontsize);
+ if ( $$conf_data->{'text_justify'} eq 'R' ) {
+ $hPos = $x_pos + $label_width - ( $left_text_margin + $stringwidth );
+ } elsif($$conf_data->{'text_justify'} eq 'C') {
+ # some code to try and center each line on the label based on font size and string point width...
+ my $whitespace = ( $label_width - ( $stringwidth + (2 * $left_text_margin) ) );
+ $hPos = ( ( $whitespace / 2 ) + $x_pos + $left_text_margin );
+ #warn "\$label_width=$label_width \$stringwidth=$stringwidth \$whitespace=$whitespace \$left_text_margin=$left_text_margin for $str\n";
} else {
$hPos = ( $x_pos + $left_text_margin );
}
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha › Tools › Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script>
-function jscss(action,o,c1,c2)
-{
- // from: http://onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html
- switch (action){
- case 'swap':
- o.className=!jscss('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
- break;
- case 'add':
- if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
- break;
- case 'remove':
- var rep=o.className.match(' '+c1)?' '+c1:c1;
- o.className=o.className.replace(rep,'');
- break;
- case 'check':
- return new RegExp('\\b'+c1+'\\b').test(o.className)
- break;
- }
-}
-function chooselayoutspec(rb) {
- stringspec=document.getElementById("formatstring");
- if(rb.value == 'layout_string') {
- stringspec.disabled=0;
- jscss('remove',document.getElementById('layout_string'),'disabled','');
- jscss('add',document.getElementById('layout_tx'),'disabled','');
- } else {
- stringspec.disabled=1;
- jscss('remove',document.getElementById('layout_tx'),'disabled','');
- jscss('add',document.getElementById('layout_string'),'disabled','');
- }
+$(document).ready(function() {
+ $("input[@name='layoutchoice']").change( function() { layout_method() } );
+ layout_method();
+});
+function layout_method() {
+ if( $("input[@name='layoutchoice']:checked").val() == 'layout_string' ) {
+ $('#layout_tx').hide();
+ $('#layout_string').show();
+ } else {
+ $('#layout_tx').show();
+ $('#layout_string').hide();
+ }
+
}
</script>
</head>
<legend>
Bibliographic Data to Print
</legend>
-<input type="radio" name="layoutchoice" value="layout_tx" <!-- TMPL_UNLESS NAME="layout_string" -->checked="checked"<!-- /TMPL_UNLESS --> onclick="chooselayoutspec(this);" >Choose Order Of Text Fields to Print</input>
-<fieldset id="layout_tx" <!-- TMPL_IF NAME="layout_string" -->class="disabled"<!-- /TMPL_IF -->>
+<input type="radio" name="layoutchoice" value="layout_tx" <!-- TMPL_UNLESS NAME="layout_string" -->checked="checked"<!-- /TMPL_UNLESS -->" >Choose Order Of Text Fields to Print</input>
+<br />
+<fieldset id="layout_tx">
<table summary="fields to print">
<tr>
<td>
<td> </td>
</tr>
</table>
+<br />
</fieldset>
<br />
-<input type="radio" name="layoutchoice" value="layout_string" <!-- TMPL_IF NAME="layout_string" -->checked="checked"<!-- /TMPL_IF --> onclick="chooselayoutspec(this);"> List Fields </input>
-<!-- TMPL_IF NAME="layout_string" --><fieldset id="layout_string"><!-- TMPL_ELSE --><fieldset id="layout_string" class="disabled"><!-- /TMPL_IF -->
+<input type="radio" name="layoutchoice" value="layout_string" <!-- TMPL_IF NAME="formatstring" -->checked="checked"<!-- /TMPL_IF -->"> List Fields </input>
+<fieldset id="layout_string" class="brief">
<label for="layoutname">Data Fields</label>
-<!-- TMPL_IF NAME="layout_string" --><input type="text" name="formatstring" id="formatstring" size="60" value="<!-- TMPL_VAR NAME="formatstring" -->" /><!-- TMPL_ELSE --><input type="text" name="formatstring" id="formatstring" size="60" value="<!-- TMPL_VAR NAME="formatstring" -->" disabled="disabled" /><!-- /TMPL_IF -->
+<input type="text" name="formatstring" id="formatstring" size="80" value="<!-- TMPL_VAR ESCAPE='HTML' NAME="formatstring" -->" />
<div class="help">
<p>Enter a comma separated list of fields to print. You may include any <em>Koha field</em> or MARC subfield.</p>
<input type="checkbox" name="guidebox" id="guidebox" value="1" />
<!-- /TMPL_IF --></li>
+<li><label for="callnum_split">Split Call Numbers</label>
+<!-- TMPL_IF NAME="callnum_split"-->
+<input type="checkbox" name="callnum_split" id="callnum_split" value="1" checked="checked" />
+<!-- TMPL_ELSE -->
+<input type="checkbox" name="callnum_split" id="callnum_split" value="1" />
+<!-- /TMPL_IF --></li>
+
+<li><label for="text_justify">Text Justification</label>
+<select name="text_justify">
+<!-- TMPL_IF NAME="justify_L" --><option value='L' selected="selected">Left</option>
+<!-- TMPL_ELSE --><option value='L'>Left</option>
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="justify_C" --><option value='C' selected="selected">Center</option>
+<!-- TMPL_ELSE --><option value='C'>Center</option>
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="justify_R" --><option value='R' selected="selected">Right</option>
+<!-- TMPL_ELSE --><option value='R'>Right</option>
+<!-- /TMPL_IF -->
+</select>
+</li>
+
</ol>
</fieldset>
<fieldset class="action">
my $isbn = $query->param('tx_isbn');
my $issn = $query->param('tx_issn');
my $itemtype = $query->param('tx_itemtype');
-my $dcn = $query->param('tx_dewey');
-my $classif = $query->param('tx_classif');
my $itemcallnumber = $query->param('tx_itemcallnumber');
-my $subclass = $query->param('tx_subclass');
my $author = $query->param('tx_author');
my $tmpl_id = $query->param('tmpl_id');
my $summary = $query->param('summary');
my $printingtype = $query->param('printingtype');
my $guidebox = $query->param('guidebox');
my $fontsize = $query->param('fontsize');
+my $callnum_split = $query->param('callnum_split');
+my $text_justify = $query->param('text_justify');
my $formatstring = $query->param('formatstring');
my $batch_type = $query->param('type');
($batch_type and $batch_type eq 'patroncards') or $batch_type = 'labels';
}
);
-#if ( $op eq 'save_conf' ) { # this early sub is depreciated, use save_layout()
-# SaveConf(
-# $barcodetype, $title, $isbn,
-# $issn, $itemtype, $bcn, $dcn,
-# $classif, $subclass, $itemcallnumber, $author,
-# $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname
-# );
-# print $query->redirect("label-home.pl");
-# exit;
-#}
-#elsif ( $op eq 'save_layout' ) {
if ( $op eq 'save_layout' ) {
save_layout(
$barcodetype, $title, $subtitle, $isbn,
- $issn, $itemtype, $bcn, $dcn,
- $classif, $subclass, $itemcallnumber, $author,
+ $issn, $itemtype, $bcn, $text_justify,
+ $callnum_split, $itemcallnumber, $author,
$tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
, $formatstring , $layout_id
);
elsif ( $op eq 'add_layout' ) {
add_layout(
$barcodetype, $title, $subtitle, $isbn,
- $issn, $itemtype, $bcn, $dcn,
- $classif, $subclass, $itemcallnumber, $author,
+ $issn, $itemtype, $bcn, $text_justify,
+ $callnum_split, $itemcallnumber, $author,
$tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
$formatstring , $layout_id
);