Merge branch 'labels_recon' into to-push

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Galen Charlton 2009-09-05 22:07:17 -04:00
commit 3b0c92c442
74 changed files with 6848 additions and 4601 deletions

View file

@ -45,7 +45,7 @@ BEGIN {
&DelBranch
&DelBranchCategory
);
@EXPORT_OK = qw( &onlymine &mybranch );
@EXPORT_OK = qw( &onlymine &mybranch get_branch_code_from_name );
}
=head1 NAME
@ -572,6 +572,15 @@ sub CheckBranchCategorycode {
return $total;
}
sub get_branch_code_from_name {
my @branch_name = @_;
my $query = "SELECT branchcode FROM branches WHERE branchname=?;";
my $dbh = C4::Context->dbh();
my $sth = $dbh->prepare($query);
$sth->execute(@branch_name);
return $sth->fetchrow_array;
}
1;
__END__

File diff suppressed because it is too large Load diff

307
C4/Labels/Batch.pm Normal file
View file

@ -0,0 +1,307 @@
package C4::Labels::Batch;
use strict;
use warnings;
use C4::Context;
use C4::Debug;
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
sub _check_params {
my $given_params = {};
my $exit_code = 0;
my @valid_template_params = (
'label_id',
'batch_id',
'item_number',
'branch_code',
);
if (scalar(@_) >1) {
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_template_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_template_params)) {
warn sprintf('Unrecognized parameter type of %s', $_);
$exit_code = 1;
}
}
return $exit_code;
}
sub new {
my ($invocant) = shift;
my $type = ref($invocant) || $invocant;
my $self = {
batch_id => 0,
items => [],
branch_code => 'NB',
batch_stat => 0, # False if any data has changed and the db has not been updated
@_,
};
my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM labels_batches;");
$sth->execute();
my $batch_id = $sth->fetchrow_array;
$self->{'batch_id'} = ++$batch_id unless $self->{'batch_id'} != 0; # this allows batch_id to be passed in for individual label printing
bless ($self, $type);
return $self;
}
sub add_item {
my $self = shift;
my $item_number = shift;
my $query = "INSERT INTO labels_batches (batch_id, item_number, branch_code) VALUES (?,?,?);";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute($self->{'batch_id'}, $item_number, $self->{'branch_code'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
return -1;
}
$query = "SELECT max(label_id) FROM labels_batches WHERE batch_id=? AND item_number=? AND branch_code=?;";
my $sth1 = C4::Context->dbh->prepare($query);
$sth1->execute($self->{'batch_id'}, $item_number, $self->{'branch_code'});
my $label_id = $sth1->fetchrow_array;
push (@{$self->{'items'}}, {item_number => $item_number, label_id => $label_id});
$self->{'batch_stat'} = 1;
return 0;
}
sub get_attr {
my $self = shift;
return $self->{$_[0]};
}
sub remove_item {
my $self = shift;
my $label_id = shift;
my $query = "DELETE FROM labels_batches WHERE label_id=? AND batch_id=?;";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute($label_id, $self->{'batch_id'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
return -1;
}
@{$self->{'items'}} = grep{$_->{'label_id'} != $label_id} @{$self->{'items'}};
$self->{'batch_stat'} = 1;
return 0;
}
# FIXME: This method is effectively useless the way the current add_item method is written. Ideally, the items should be added to the object
# and then the save method called. This does not work well in practice due to the inability to pass objects accross cgi script calls.
# I'm leaving it here because it should be here and for consistency's sake. -cnighswonger
#
#=head2 $batch->save()
#
# Invoking the I<save> method attempts to insert the batch into the database. The method returns
# the new record batch_id upon success and -1 upon failure (This avoids conflicting with a record
# batch_id of 1). Errors are logged to the Apache log.
#
# example:
# my $exitstat = $batch->save(); # to save the record behind the $batch object
#
#=cut
#
#sub save {
# my $self = shift;
# foreach my $item_number (@{$self->{'items'}}) {
# my $query = "INSERT INTO labels_batches (batch_id, item_number, branch_code) VALUES (?,?,?);";
# my $sth1 = C4::Context->dbh->prepare($query);
# $sth1->execute($self->{'batch_id'}, $item_number->{'item_number'}, $self->{'branch_code'});
# if ($sth1->err) {
# warn sprintf('Database returned the following error on attempted INSERT: %s', $sth1->errstr);
# return -1;
# }
# $self->{'batch_stat'} = 1;
# return $self->{'batch_id'};
# }
#}
sub retrieve {
my $invocant = shift;
my %opts = @_;
my $type = ref($invocant) || $invocant;
my $record_flag = 0;
my $query = "SELECT * FROM labels_batches WHERE batch_id = ? ORDER BY label_id";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute($opts{'batch_id'});
my $self = {
batch_id => $opts{'batch_id'},
items => [],
};
while (my $record = $sth->fetchrow_hashref) {
$self->{'branch_code'} = $record->{'branch_code'};
push (@{$self->{'items'}}, {item_number => $record->{'item_number'}, label_id => $record->{'label_id'}});
$record_flag = 1; # true if one or more rows were retrieved
}
return -2 if $record_flag == 0; # a hackish sort of way of indicating no such record exists
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
return -1;
}
$self->{'batch_stat'} = 1;
bless ($self, $type);
return $self;
}
sub delete {
my $self = {};
my %opts = ();
my $call_type = '';
my @query_params = ();
if (ref($_[0])) {
$self = shift; # check to see if this is a method call
$call_type = 'C4::Labels::Batch->delete';
@query_params = ($self->{'batch_id'}, $self->{'branch_code'});
}
else {
%opts = @_;
$call_type = 'C4::Labels::Batch::delete';
@query_params = ($opts{'batch_id'}, $opts{'branch_code'});
}
if ($query_params[0] eq '') { # If there is no template id then we cannot delete it
warn sprtinf('%s : Cannot delete batch as the batch id is invalid or non-existent.', $call_type);
return -1;
}
my $query = "DELETE FROM labels_batches WHERE batch_id = ? AND branch_code =?";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute(@query_params);
if ($sth->err) {
warn sprintf('%s : Database returned the following error on attempted INSERT: %s', $call_type, $sth->errstr);
return -1;
}
return 0;
}
sub remove_duplicates {
my $self = shift;
my %seen=();
my $query = "DELETE FROM labels_batches WHERE label_id = ?;"; # ORDER BY timestamp ASC LIMIT ?;";
my $sth = C4::Context->dbh->prepare($query);
my @duplicate_items = grep{$seen{$_->{'item_number'}}++} @{$self->{'items'}};
foreach my $item (@duplicate_items) {
$sth->execute($item->{'label_id'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted DELETE for label_id %s: %s', $item->{'label_id'}, $sth->errstr);
return -1;
}
$sth->finish(); # Per DBI.pm docs: "If execute() is called on a statement handle that's still active ($sth->{Active} is true) then it should effectively call finish() to tidy up the previous execution results before starting this new execution."
@{$self->{'items'}} = grep{$_->{'label_id'} != $item->{'label_id'}} @{$self->{'items'}}; # the correct label/item must be removed from the current batch object as well; this should be done *after* each sql DELETE in case the DELETE fails
}
return scalar(@duplicate_items);
}
1;
__END__
=head1 NAME
C4::Labels::Batch - A class for creating and manipulating batch objects in Koha
=head1 ABSTRACT
This module provides methods for creating, and otherwise manipulating batch objects used by Koha to create and export labels.
=head1 METHODS
=head2 new()
Invoking the I<new> method constructs a new batch object with no items. It is possible to pre-populate the batch with items and a branch code by passing them
as in the second example below.
B<NOTE:> The items list must be an arrayref pointing to an array of hashes containing a key/data pair after this fashion: {item_number => item_number}. The order of
the array elements determines the order of the items in the batch.
example:
C<my $batch = C4::Labels::Batch->new(); # Creates and returns a new batch object>
C<my $batch = C4::Labels::Batch->new(items => $arrayref, branch_code => branch_code) # Creates and returns a new batch object containing the items passed in
with the branch code passed in.>
B<NOTE:> This batch is I<not> written to the database until C<$batch->save()> is invoked. You have been warned!
=head2 $batch->add_item(item_number => $item_number, branch_code => $branch_code)
Invoking the I<add_item> method will add the supplied item to the batch object.
example:
$batch->add_item(item_number => $item_number, branch_code => $branch_code);
=head2 $batch->get_attr($attribute)
Invoking the I<get_attr> method will return the requested attribute.
example:
my @items = $batch->get_attr('items');
=head2 $batch->remove_item($item_number)
Invoking the I<remove_item> method will remove the supplied item number from the batch object.
example:
$batch->remove_item($item_number);
=head2 C4::Labels::Batch->retrieve(batch_id => $batch_id)
Invoking the I<retrieve> method constructs a new batch object containing the current values for batch_id. The method returns a new object upon success and 1 upon failure.
Errors are logged to the Apache log.
examples:
my $batch = C4::Labels::Batch->retrieve(batch_id => 1); # Retrieves batch 1 and returns an object containing the record
=head2 delete()
Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that batch from the database. See the example below.
examples:
my $exitstat = $batch->delete(); # to delete the record behind the $batch object
my $exitstat = C4::Labels::Batch->delete(batch_id => 1); # to delete batch 1
=head2 remove_duplicates()
Invoking the remove_duplicates method attempts to remove duplicate items in the batch from the database. The method returns the count of duplicate records removed upon
success and -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair removing duplicates in the batch passed in. See the example below.
examples:
my $remove_count = $batch->remove_duplicates(); # to remove duplicates the record behind the $batch object
my $remove_count = C4::Labels::Batch->remove_duplicates(batch_id => 1); # to remove duplicates in batch 1
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.
=cut

798
C4/Labels/Label.pm Normal file
View file

@ -0,0 +1,798 @@
package C4::Labels::Label;
use strict;
use warnings;
use Text::Wrap;
use Algorithm::CheckDigits;
use Text::CSV_XS;
use C4::Context;
use C4::Debug;
use C4::Biblio;
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
my $possible_decimal = qr/\d{3,}(?:\.\d+)?/; # at least three digits for a DDCN
sub _check_params {
my $given_params = {};
my $exit_code = 0;
my @valid_label_params = (
'batch_id',
'item_number',
'llx',
'lly',
'height',
'width',
'top_text_margin',
'left_text_margin',
'barcode_type',
'printing_type',
'guidebox',
'font',
'font_size',
'callnum_split',
'justify',
'format_string',
'text_wrap_cols',
'barcode',
);
if (scalar(@_) >1) {
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_label_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_label_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
return $exit_code;
}
sub _guide_box {
my ( $llx, $lly, $width, $height ) = @_;
my $obj_stream = "q\n"; # save the graphic state
$obj_stream .= "0.5 w\n"; # border line width
$obj_stream .= "1.0 0.0 0.0 RG\n"; # border color red
$obj_stream .= "1.0 1.0 1.0 rg\n"; # fill color white
$obj_stream .= "$llx $lly $width $height re\n"; # a rectangle
$obj_stream .= "B\n"; # fill (and a little more)
$obj_stream .= "Q\n"; # restore the graphic state
return $obj_stream;
}
sub _get_label_item {
my $item_number = shift;
my $barcode_only = shift || 0;
my $dbh = C4::Context->dbh;
# FIXME This makes for a very bulky data structure; data from tables w/duplicate col names also gets overwritten.
# Something like this, perhaps, but this also causes problems because we need more fields sometimes.
# SELECT i.barcode, i.itemcallnumber, i.itype, bi.isbn, bi.issn, b.title, b.author
my $sth = $dbh->prepare("SELECT bi.*, i.*, b.* FROM items AS i, biblioitems AS bi ,biblio AS b WHERE itemnumber=? AND i.biblioitemnumber=bi.biblioitemnumber AND bi.biblionumber=b.biblionumber;");
$sth->execute($item_number);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
}
my $data = $sth->fetchrow_hashref;
# Replaced item's itemtype with the more user-friendly description...
my $sth1 = $dbh->prepare("SELECT itemtype,description FROM itemtypes WHERE itemtype = ?");
$sth1->execute($data->{'itemtype'});
if ($sth1->err) {
warn sprintf('Database returned the following error: %s', $sth1->errstr);
}
my $data1 = $sth->fetchrow_hashref;
$data->{'itemtype'} = $data1->{'description'};
$data->{'itype'} = $data1->{'description'};
$barcode_only ? return $data->{'barcode'} : return $data;
}
sub _get_text_fields {
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 $error = $csv->error_input();
warn sprintf('Text field sort failed with this error: %s', $error) if $error;
return \@sorted_fields;
}
sub _split_lccn {
my ($lccn) = @_;
$_ = $lccn;
# lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996';
my (@parts) = m/
^([a-zA-Z]+) # HE # BS
(\d+(?:\.\d)*) # 8700.7 # 2545
\s*
(\.*\D+\d*) # .P6 # .E8
\s*
(.*) # T44 1983 # H39 1996 # everything else (except any bracketing spaces)
\s*
/x;
unless (scalar @parts) {
warn sprintf('regexp failed to match string: %s', $_);
push @parts, $_; # if no match, just push the whole string.
}
push @parts, split /\s+/, pop @parts; # split the last piece into an arbitrary number of pieces at spaces
$debug and warn "split_lccn array: ", join(" | ", @parts), "\n";
return @parts;
}
sub _split_ddcn {
my ($ddcn) = @_;
$_ = $ddcn;
s/\///g; # in theory we should be able to simply remove all segmentation markers and arrive at the correct call number...
my (@parts) = m/
^([a-zA-Z-]+(?:$possible_decimal)?) # R220.3 # BIO # first example will require extra splitting
\s+
(.+) # H2793Z H32 c.2 # R5c.1 # everything else (except bracketing spaces)
\s*
/x;
unless (scalar @parts) {
warn sprintf('regexp failed to match string: %s', $_);
push @parts, $_; # if no match, just push the whole string.
}
if ($parts[ 0] =~ /^([a-zA-Z]+)($possible_decimal)$/) {
shift @parts; # pull off the mathching first element, like example 1
unshift @parts, $1, $2; # replace it with the two pieces
}
push @parts, split /\s+/, pop @parts; # split the last piece into an arbitrary number of pieces at spaces
if ($parts[-1] !~ /^.*\d-\d.*$/ && $parts[-1] =~ /^(.*\d+)(\D.*)$/) {
pop @parts; # pull off the mathching last element, like example 2
push @parts, $1, $2; # replace it with the two pieces
}
$debug and print STDERR "split_ddcn array: ", join(" | ", @parts), "\n";
return @parts;
}
sub _split_fcn {
my ($fcn) = @_;
my @fcn_split = ();
# Split fiction call numbers based on spaces
SPLIT_FCN:
while ($fcn) {
if ($fcn =~ m/([A-Za-z0-9]+\.?[0-9]?)(\W?).*?/x) {
push (@fcn_split, $1);
$fcn = $';
}
else {
last SPLIT_FCN; # No match, break out of the loop
}
}
unless (scalar @fcn_split) {
warn sprintf('regexp failed to match string: %s', $_);
push (@fcn_split, $_);
}
return @fcn_split;
}
sub _get_barcode_data {
my ( $f, $item, $record ) = @_;
my $kohatables = _desc_koha_tables();
my $datastring = '';
my $match_kohatable = join(
'|',
(
@{ $kohatables->{'biblio'} },
@{ $kohatables->{'biblioitems'} },
@{ $kohatables->{'items'} }
)
);
FIELD_LIST:
while ($f) {
my $err = '';
$f =~ s/^\s?//;
if ( $f =~ /^'(.*)'.*/ ) {
# single quotes indicate a static text string.
$datastring .= $1;
$f = $';
next FIELD_LIST;
}
elsif ( $f =~ /^($match_kohatable).*/ ) {
if ($item->{$f}) {
$datastring .= $item->{$f};
} else {
$debug and warn sprintf("The '%s' field contains no data.", $f);
}
$f = $';
next FIELD_LIST;
}
elsif ( $f =~ /^([0-9a-z]{3})(\w)(\W?).*?/ ) {
my ($field,$subf,$ws) = ($1,$2,$3);
my $subf_data;
my ($itemtag, $itemsubfieldcode) = &GetMarcFromKohaField("items.itemnumber",'');
my @marcfield = $record->field($field);
if(@marcfield) {
if($field eq $itemtag) { # item-level data, we need to get the right item.
ITEM_FIELDS:
foreach my $itemfield (@marcfield) {
if ( $itemfield->subfield($itemsubfieldcode) eq $item->{'itemnumber'} ) {
if ($itemfield->subfield($subf)) {
$datastring .= $itemfield->subfield($subf) . $ws;
}
else {
warn sprintf("The '%s' field contains no data.", $f);
}
last ITEM_FIELDS;
}
}
} else { # bib-level data, we'll take the first matching tag/subfield.
if ($marcfield[0]->subfield($subf)) {
$datastring .= $marcfield[0]->subfield($subf) . $ws;
}
else {
warn sprintf("The '%s' field contains no data.", $f);
}
}
}
$f = $';
next FIELD_LIST;
}
else {
warn sprintf('Failed to parse label format string: %s', $f);
last FIELD_LIST; # Failed to match
}
}
return $datastring;
}
sub _desc_koha_tables {
my $dbh = C4::Context->dbh();
my $kohatables;
for my $table ( 'biblio','biblioitems','items' ) {
my $sth = $dbh->column_info(undef,undef,$table,'%');
while (my $info = $sth->fetchrow_hashref()){
push @{$kohatables->{$table}} , $info->{'COLUMN_NAME'} ;
}
$sth->finish;
}
return $kohatables;
}
### This series of functions calculates the position of text and barcode on individual labels
### Please *do not* add printing types which are non-atomic. Instead, build code which calls the necessary atomic printing types to form the non-atomic types. See the ALT type
### in labels/label-create-pdf.pl as an example.
### NOTE: Each function must be passed seven parameters and return seven even if some are 0 or undef
sub _BIB {
my $self = shift;
my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
my $text_lly = ($self->{'lly'} + ($self->{'height'} - $self->{'top_text_margin'}));
return $self->{'llx'}, $text_lly, $line_spacer, 0, 0, 0, 0;
}
sub _BAR {
my $self = shift;
my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the the left edge of the label ($llx)
my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly)
my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width
my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height
return 0, 0, 0, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
}
sub _BIBBAR {
my $self = shift;
my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the the left edge of the label ($self->{'llx'})
my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly)
my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width
my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height
my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
my $text_lly = ($self->{'lly'} + ($self->{'height'} - $self->{'top_text_margin'}));
return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
}
sub _BARBIB {
my $self = shift;
my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the the left edge of the label ($self->{'llx'})
my $barcode_lly = ($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance below the top of the label ($self->{'lly'})
my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width
my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height
my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
my $text_lly = (($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'} - (($self->{'lly'} + $self->{'height'}) - $barcode_lly));
return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
}
sub new {
my ($invocant, %params) = @_;
my $type = ref($invocant) || $invocant;
my $self = {
batch_id => $params{'batch_id'},
item_number => $params{'item_number'},
llx => $params{'llx'},
lly => $params{'lly'},
height => $params{'height'},
width => $params{'width'},
top_text_margin => $params{'top_text_margin'},
left_text_margin => $params{'left_text_margin'},
barcode_type => $params{'barcode_type'},
printing_type => $params{'printing_type'},
guidebox => $params{'guidebox'},
font => $params{'font'},
font_size => $params{'font_size'},
callnum_split => $params{'callnum_split'},
justify => $params{'justify'},
format_string => $params{'format_string'},
text_wrap_cols => $params{'text_wrap_cols'},
barcode => 0,
};
if ($self->{'guidebox'}) {
$self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
}
bless ($self, $type);
return $self;
}
sub get_label_type {
my $self = shift;
return $self->{'printing_type'};
}
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
else {
return -1;
}
return;
}
sub create_label {
my $self = shift;
my $label_text = '';
my ($text_llx, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor);
{
no strict 'refs';
($text_llx, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor) = &{"_$self->{'printing_type'}"}($self); # an obfuscated call to the correct printing type sub
}
if ($self->{'printing_type'} =~ /BIB/) {
$label_text = draw_label_text( $self,
llx => $text_llx,
lly => $text_lly,
line_spacer => $line_spacer,
);
}
if ($self->{'printing_type'} =~ /BAR/) {
barcode( $self,
llx => $barcode_llx,
lly => $barcode_lly,
width => $barcode_width,
y_scale_factor => $barcode_y_scale_factor,
);
}
return $label_text if $label_text;
return;
}
sub draw_label_text {
my ($self, %params) = @_;
my @label_text = ();
my $text_llx = 0;
my $text_lly = $params{'lly'};
my $font = $self->{'font'};
my $item = _get_label_item($self->{'item_number'});
my $label_fields = _get_text_fields($self->{'format_string'});
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).
my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource'));
LABEL_FIELDS: # process data for requested fields on current label
for my $field (@$label_fields) {
if ($field->{'code'} eq 'itemtype') {
$field->{'data'} = C4::Context->preference('item-level_itypes') ? $item->{'itype'} : $item->{'itemtype'};
}
else {
$field->{'data'} = _get_barcode_data($field->{'code'},$item,$record);
}
($field->{'code'} eq 'title') ? (($font =~ /T/) ? ($font = 'TI') : ($font = ($font . 'O'))) : ($font = $font);
my $field_data = $field->{'data'};
if ($field_data) {
$field_data =~ s/\n//g;
$field_data =~ s/\r//g;
}
my @label_lines;
my @callnumber_list = ('itemcallnumber', '050a', '050b', '082a', '952o'); # Fields which hold call number data FIXME: ( 060? 090? 092? 099? )
if ((grep {$field->{'code'} =~ m/$_/} @callnumber_list) and ($self->{'printing_type'} eq 'BIB') and ($self->{'callnum_split'})) { # If the field contains the call number, we do some sp
if ($cn_source eq 'lcc') {
@label_lines = _split_lccn($field_data);
@label_lines = _split_fcn($field_data) if !@label_lines; # If it was not a true lccn, try it as a fiction call number
push (@label_lines, $field_data) if !@label_lines; # If it was not that, send it on unsplit
} elsif ($cn_source eq 'ddc') {
@label_lines = _split_ddcn($field_data);
@label_lines = _split_fcn($field_data) if !@label_lines;
push (@label_lines, $field_data) if !@label_lines;
} else {
warn sprintf('Call number splitting failed for: %s. Please add this call number to bug #2500 at bugs.koha.org', $field_data);
push @label_lines, $field_data;
}
}
else {
if ($field_data) {
$field_data =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number...
$field_data =~ s/\(/\\\(/g; # Escape '(' and ')' for the pdf object stream...
$field_data =~ s/\)/\\\)/g;
}
eval{$Text::Wrap::columns = $self->{'text_wrap_cols'};};
my @line = split(/\n/ ,wrap('', '', $field_data));
# If this is a title field, limit to two lines; all others limit to one... FIXME: this is rather arbitrary
if ($field->{'code'} eq 'title' && scalar(@line) >= 2) {
while (scalar(@line) > 2) {
pop @line;
}
} else {
while (scalar(@line) > 1) {
pop @line;
}
}
push(@label_lines, @line);
}
LABEL_LINES: # generate lines of label text for current field
foreach my $line (@label_lines) {
next LABEL_LINES if $line eq '';
my $string_width = C4::Labels::PDF->StrWidth($line, $font, $self->{'font_size'});
if ($self->{'justify'} eq 'R') {
$text_llx = $params{'llx'} + $self->{'width'} - ($self->{'left_text_margin'} + $string_width);
}
elsif($self->{'justify'} eq 'C') {
# some code to try and center each line on the label based on font size and string point width...
my $whitespace = ($self->{'width'} - ($string_width + (2 * $self->{'left_text_margin'})));
$text_llx = (($whitespace / 2) + $params{'llx'} + $self->{'left_text_margin'});
}
else {
$text_llx = ($params{'llx'} + $self->{'left_text_margin'});
}
push @label_text, {
text_llx => $text_llx,
text_lly => $text_lly,
font => $font,
font_size => $self->{'font_size'},
line => $line,
};
$text_lly = $text_lly - $params{'line_spacer'};
}
$font = $self->{'font'}; # reset font for next field
} #foreach field
return \@label_text;
}
sub barcode {
my $self = shift;
my %params = @_;
$params{'barcode_data'} = _get_label_item($self->{'item_number'}, 1) if !$params{'barcode_data'};
$params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
my $x_scale_factor = 1;
my $num_of_bars = length($params{'barcode_data'});
my $tot_bar_length = 0;
my $bar_length = 0;
my $guard_length = 10;
my $hide_text = 'yes';
if ($params{'barcode_type'} =~ m/CODE39/) {
$bar_length = '17.5';
$tot_bar_length = ($bar_length * $num_of_bars) + ($guard_length * 2);
$x_scale_factor = ($params{'width'} / $tot_bar_length);
if ($params{'barcode_type'} eq 'CODE39MOD') {
my $c39 = CheckDigits('visa'); # get modulo43 checksum
$params{'barcode_data'} = $c39->complete($params{'barcode_data'});
}
elsif ($params{'barcode_type'} eq 'CODE39MOD10') {
my $c39_10 = CheckDigits('visa'); # get modulo43 checksum
$params{'barcode_data'} = $c39_10->complete($params{'barcode_data'});
$hide_text = '';
}
eval {
PDF::Reuse::Barcode::Code39(
x => $params{'llx'},
y => $params{'lly'},
value => "*$params{barcode_data}*",
xSize => $x_scale_factor,
ySize => $params{'y_scale_factor'},
hide_asterisk => 1,
text => $hide_text,
mode => 'graphic',
);
};
if ($@) {
warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@);
}
}
elsif ($params{'barcode_type'} eq 'COOP2OF5') {
$bar_length = '9.43333333333333';
$tot_bar_length = ($bar_length * $num_of_bars) + ($guard_length * 2);
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9;
eval {
PDF::Reuse::Barcode::COOP2of5(
x => $params{'llx'},
y => $params{'lly'},
value => "*$params{barcode_data}*",
xSize => $x_scale_factor,
ySize => $params{'y_scale_factor'},
mode => 'graphic',
);
};
if ($@) {
warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@);
}
}
elsif ( $params{'barcode_type'} eq 'INDUSTRIAL2OF5' ) {
$bar_length = '13.1333333333333';
$tot_bar_length = ($bar_length * $num_of_bars) + ($guard_length * 2);
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9;
eval {
PDF::Reuse::Barcode::Industrial2of5(
x => $params{'llx'},
y => $params{'lly'},
value => "*$params{barcode_data}*",
xSize => $x_scale_factor,
ySize => $params{'y_scale_factor'},
mode => 'graphic',
);
};
if ($@) {
warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@);
}
}
}
sub csv_data {
my $self = shift;
my $label_fields = _get_text_fields($self->{'format_string'});
my $item = _get_label_item($self->{'item_number'});
my $bib_record = GetMarcBiblio($item->{biblionumber});
my @csv_data = (map { _get_barcode_data($_->{'code'},$item,$bib_record) } @$label_fields);
return \@csv_data;
}
1;
__END__
=head1 NAME
C4::Labels::Label - A class for creating and manipulating label objects in Koha
=head1 ABSTRACT
This module provides methods for creating, and otherwise manipulating single label objects used by Koha to create and export labels.
=head1 METHODS
=head2 new()
Invoking the I<new> method constructs a new label object containing the supplied values. Depending on the final output format of the label data
the minimal required parameters change. (See the implimentation of this object type in labels/label-create-pdf.pl and labels/label-create-csv.pl
and labels/label-create-xml.pl for examples.) The following parameters are optionally accepted as key => value pairs:
C<batch_id> Batch id with which this label is associated
C<item_number> Item number of item to be the data source for this label
C<height> Height of this label (All measures passed to this method B<must> be supplied in postscript points)
C<width> Width of this label
C<top_text_margin> Top margin of this label
C<left_text_margin> Left margin of this label
C<barcode_type> Defines the barcode type to be used on labels. NOTE: At present only the following barcode types are supported in the label creator code:
=over 9
=item .
CODE39 = Code 3 of 9
=item .
CODE39MOD = Code 3 of 9 with modulo 43 checksum
=item .
CODE39MOD10 = Code 3 of 9 with modulo 10 checksum
=item .
COOP2OF5 = A varient of 2 of 5 barcode based on NEC's "Process 8000" code
=item .
INDUSTRIAL2OF5 = The standard 2 of 5 barcode (a binary level bar code developed by Identicon Corp. and Computer Identics Corp. in 1970)
=back
C<printing_type> Defines the general layout to be used on labels. NOTE: At present there are only five printing types supported in the label creator code:
=over 9
=item .
BIB = Only the bibliographic data is printed
=item .
BARBIB = Barcode proceeds bibliographic data
=item .
BIBBAR = Bibliographic data proceeds barcode
=item .
ALT = Barcode and bibliographic data are printed on alternating labels
=item .
BAR = Only the barcode is printed
=back
C<guidebox> Setting this to '1' will result in a guide box being drawn around the labels marking the edge of each label
C<font> Defines the type of font to be used on labels. NOTE: The following fonts are available by default on most systems:
=over 9
=item .
TR = Times-Roman
=item .
TB = Times Bold
=item .
TI = Times Italic
=item .
TBI = Times Bold Italic
=item .
C = Courier
=item .
CB = Courier Bold
=item .
CO = Courier Oblique (Italic)
=item .
CBO = Courier Bold Oblique
=item .
H = Helvetica
=item .
HB = Helvetica Bold
=item .
HBO = Helvetical Bold Oblique
=back
C<font_size> Defines the size of the font in postscript points to be used on labels
C<callnum_split> Setting this to '1' will enable call number splitting on labels
C<text_justify> Defines the text justification to be used on labels. NOTE: The following justification styles are currently supported by label creator code:
=over 9
=item .
L = Left
=item .
C = Center
=item .
R = Right
=back
C<format_string> Defines what fields will be printed and in what order they will be printed on labels. These include any of the data fields that may be mapped
to your MARC frameworks. Specify MARC subfields as a 4-character tag-subfield string: ie. 254a Enclose a whitespace-separated list of fields
to concatenate on one line in double quotes. ie. "099a 099b" or "itemcallnumber barcode" Static text strings may be entered in single-quotes:
ie. 'Some static text here.'
C<text_wrap_cols> Defines the column after which the text will wrap to the next line.
=head2 get_label_type()
Invoking the I<get_label_type> method will return the printing type of the label object.
example:
C<my $label_type = $label->get_label_type();>
=head2 get_attr($attribute)
Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $label->get_attr($attribute);>
=head2 create_label()
Invoking the I<create_label> method generates the text for that label and returns it as an arrayref of an array contianing the formatted text as well as creating the barcode
and writing it directly to the pdf stream. The handling of the barcode is not quite good OO form due to the linear format of PDF::Reuse::Barcode. Be aware that the instantiating
code is responsible to properly format the text for insertion into the pdf stream as well as the actual insertion.
example:
my $label_text = $label->create_label();
=head2 draw_label_text()
Invoking the I<draw_label_text> method generates the label text for the label object and returns it as an arrayref of an array containing the formatted text. The same caveats
apply to this method as to C<create_label()>. This method accepts the following parameters as key => value pairs: (NOTE: The unit is the postscript point - 72 per inch)
C<llx> The lower-left x coordinate for the text block (The point of origin for all PDF's is the lower left of the page per ISO 32000-1)
C<lly> The lower-left y coordinate for the text block
C<top_text_margin> The top margin for the text block.
C<line_spacer> The number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size)
C<font> The font to use for this label. See documentation on the new() method for supported fonts.
C<font_size> The font size in points to use for this label.
C<justify> The style of justification to use for this label. See documentation on the new() method for supported justification styles.
example:
C<my $label_text = $label->draw_label_text(
llx => $text_llx,
lly => $text_lly,
top_text_margin => $label_top_text_margin,
line_spacer => $text_leading,
font => $text_font,
font_size => $text_font_size,
justify => $text_justification,
);>
=head2 barcode()
Invoking the I<barcode> method generates a barcode for the label object and inserts it into the current pdf stream. This method accepts the following parameters as key => value
pairs (C<barcode_data> is optional and omitting it will cause the barcode from the current item to be used. C<barcode_type> is also optional. Omission results in the barcode
type of the current template being used.):
C<llx> The lower-left x coordinate for the barcode block (The point of origin for all PDF's is the lower left of the page per ISO 32000-1)
C<lly> The lower-left y coordinate for the barcode block
C<width> The width of the barcode block
C<y_scale_factor> The scale factor to be applied to the y axis of the barcode block
C<barcode_data> The data to be encoded in the barcode
C<barcode_type> The barcode type (See the C<new()> method for supported barcode types)
example:
C<$label->barcode(
llx => $barcode_llx,
lly => $barcode_lly,
width => $barcode_width,
y_scale_factor => $barcode_y_scale_factor,
barcode_data => $barcode,
barcode_type => $barcodetype,
);>
=head2 csv_data()
Invoking the I<csv_data> method returns an arrayref of an array containing the label data suitable for passing to Text::CSV_XS->combine() to produce csv output.
example:
C<my $csv_data = $label->csv_data();>
=head1 AUTHOR
Mason James <mason@katipo.co.nz>
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
Copyright 2006 Katipo Communications.
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.
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
=head1 DISCLAIMER OF WARRANTY
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.
=cut

419
C4/Labels/Layout.pm Normal file
View file

@ -0,0 +1,419 @@
package C4::Labels::Layout;
use strict;
use warnings;
use DBI qw(neat);
use C4::Context;
use C4::Debug;
use C4::Labels::PDF;
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
# FIXME: Consider this style parameter verification instead...
# my %param = @_;
# for (keys %param)
# { my $lc = lc($_);
# if (exists $default{$lc})
# { $default{$lc} = $param{$_};
# }
# else
# { print STDERR "Unknown parameter $_ , not used \n";
# }
# }
sub _check_params {
my $exit_code = 0;
my @valtmpl_id_params = (
'barcode_type',
'printing_type',
'layout_name',
'guidebox',
'font',
'font_size',
'callnum_split',
'text_justify',
'format_string',
);
if (scalar(@_) >1) {
my %given_params = @_;
foreach my $key (keys %given_params) {
if (!(grep m/$key/, @valtmpl_id_params)) {
warn sprintf('(Multiple parameters) Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valtmpl_id_params)) {
warn sprintf('(Single parameter) Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
return $exit_code;
}
sub new {
my $invocant = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my $type = ref($invocant) || $invocant;
my $self = {
barcode_type => 'CODE39',
printing_type => 'BAR',
layout_name => 'DEFAULT',
guidebox => 0,
font => 'TR',
font_size => 3,
callnum_split => 0,
text_justify => 'L',
format_string => 'title, author, isbn, issn, itemtype, barcode, callnumber',
@_,
};
bless ($self, $type);
return $self;
}
sub retrieve {
my $invocant = shift;
my %opts = @_;
my $type = ref($invocant) || $invocant;
my $query = "SELECT * FROM labels_layouts WHERE layout_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{'layout_id'});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $self = $sth->fetchrow_hashref;
bless ($self, $type);
return $self;
}
sub delete {
my $self = {};
my %opts = ();
my $call_type = '';
my $query_param = '';
if (ref($_[0])) {
$self = shift; # check to see if this is a method call
$call_type = 'C4::Labels::Layout->delete';
$query_param = $self->{'layout_id'};
}
else {
%opts = @_;
$call_type = 'C4::Labels::Layout::delete';
$query_param = $opts{'layout_id'};
}
if ($query_param eq '') { # If there is no layout id then we cannot delete it
warn sprintf('%s : Cannot delete layout as the layout id is invalid or non-existant.', $call_type);
return -1;
}
my $query = "DELETE FROM labels_layouts WHERE layout_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($query_param);
if ($sth->err) {
warn sprintf('%s : Database returned the following error: %s', $call_type, $sth->errstr);
return -1;
}
return 0;
}
sub save {
my $self = shift;
if ($self->{'layout_id'}) { # if we have an id, the record exists and needs UPDATE
my @params;
my $query = "UPDATE labels_layouts SET ";
foreach my $key (keys %{$self}) {
next if $key eq 'layout_id';
push (@params, $self->{$key});
$query .= "$key=?, ";
}
$query = substr($query, 0, (length($query)-2));
$query .= " WHERE layout_id=?;";
push (@params, $self->{'layout_id'});
my $sth = C4::Context->dbh->prepare($query);
#local $sth->{TraceLevel} = "3"; # enable DBI trace and set level; outputs to STDERR
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
return $self->{'layout_id'};
}
else { # otherwise create a new record
my @params;
my $query = "INSERT INTO labels_layouts (";
foreach my $key (keys %{$self}) {
push (@params, $self->{$key});
$query .= "$key, ";
}
$query = substr($query, 0, (length($query)-2));
$query .= ") VALUES (";
for (my $i=1; $i<=(scalar keys %$self); $i++) {
$query .= "?,";
}
$query = substr($query, 0, (length($query)-1));
$query .= ");";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(layout_id) FROM labels_layouts;");
$sth1->execute();
my $id = $sth1->fetchrow_array;
return $id;
}
}
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
else {
return -1;
}
return;
}
sub set_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my %attrs = @_;
foreach my $attrib (keys(%attrs)) {
$self->{$attrib} = $attrs{$attrib};
};
return 0;
}
sub get_text_wrap_cols {
my $self = shift;
my %params = @_;
my $string = '';
my $strwidth = 0;
my $col_count = 0;
my $textlimit = $params{'label_width'} - ( 3 * $params{'left_text_margin'});
while ($strwidth < $textlimit) {
$string .= '0';
$col_count++;
$strwidth = C4::Labels::PDF->StrWidth( $string, $self->{'font'}, $self->{'font_size'} );
}
return $col_count;
}
1;
__END__
=head1 NAME
C4::Labels::Layout -A class for creating and manipulating layout objects in Koha
=head1 ABSTRACT
This module provides methods for creating, retrieving, and otherwise manipulating label layout objects used by Koha to create and export labels.
=head1 METHODS
=head2 new()
Invoking the I<new> method constructs a new layout object containing the default values for a layout.
The following parameters are optionally accepted as key => value pairs:
C<barcode_type> Defines the barcode type to be used on labels. NOTE: At present only the following barcode types are supported in the label creator code:
=over 9
=item .
CODE39 = Code 3 of 9
=item .
CODE39MOD = Code 3 of 9 with modulo 43 checksum
=item .
CODE39MOD10 = Code 3 of 9 with modulo 10 checksum
=item .
COOP2OF5 = A varient of 2 of 5 barcode based on NEC's "Process 8000" code
=item .
INDUSTRIAL2OF5 = The standard 2 of 5 barcode (a binary level bar code developed by Identicon Corp. and Computer Identics Corp. in 1970)
=back
C<printing_type> Defines the general layout to be used on labels. NOTE: At present there are only five printing types supported in the label creator code:
=over 9
=item .
BIB = Only the bibliographic data is printed
=item .
BARBIB = Barcode proceeds bibliographic data
=item .
BIBBAR = Bibliographic data proceeds barcode
=item .
ALT = Barcode and bibliographic data are printed on alternating labels
=item .
BAR = Only the barcode is printed
=back
C<layout_name> The descriptive name for this layout.
C<guidebox> Setting this to '1' will result in a guide box being drawn around the labels marking the edge of each label
C<font> Defines the type of font to be used on labels. NOTE: The following fonts are available by default on most systems:
=over 9
=item .
TR = Times-Roman
=item .
TB = Times Bold
=item .
TI = Times Italic
=item .
TBI = Times Bold Italic
=item .
C = Courier
=item .
CB = Courier Bold
=item .
CO = Courier Oblique (Italic)
=item .
CBO = Courier Bold Oblique
=item .
H = Helvetica
=item .
HB = Helvetica Bold
=item .
HBO = Helvetical Bold Oblique
=back
C<font_size> Defines the size of the font in postscript points to be used on labels
C<callnum_split> Setting this to '1' will enable call number splitting on labels
C<text_justify> Defines the text justification to be used on labels. NOTE: The following justification styles are currently supported by label creator code:
=over 9
=item .
L = Left
=item .
C = Center
=item .
R = Right
=back
C<format_string> Defines what fields will be printed and in what order they will be printed on labels. These include any of the data fields that may be mapped
to your MARC frameworks. Specify MARC subfields as a 4-character tag-subfield string: ie. 254a Enclose a whitespace-separated list of fields
to concatenate on one line in double quotes. ie. "099a 099b" or "itemcallnumber barcode" Static text strings may be entered in single-quotes:
ie. 'Some static text here.'
example:
C<my $layout = Layout->new(); # Creates and returns a new layout object>
C<my $layout = C4::Labels::Layout->new(barcode_type => 'CODE39', printing_type => 'BIBBAR', font => 'C', font_size => 6); # Creates and returns a new layout object using
the supplied values to override the defaults>
B<NOTE:> This layout is I<not> written to the database until save() is invoked. You have been warned!
=head2 retrieve(layout_id => layout_id)
Invoking the I<retrieve> method constructs a new layout object containing the current values for layout_id. The method returns a new object upon success and 1 upon failure.
Errors are logged to the Apache log.
example:
C<my $layout = Layout->retrieve(layout_id => 1); # Retrieves layout record 1 and returns an object containing the record>
=head2 delete()
Invoking the delete method attempts to delete the layout from the database. The method returns 0 upon success and -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that template from the database. See the example below.
examples:
C<my $exitstat = $layout->delete(); # to delete the record behind the $layout object>
C<my $exitstat = Layout->delete(layout_id => 1); # to delete layout record 1>
=head2 save()
Invoking the I<save> method attempts to insert the layout into the database if the layout is new and update the existing layout record if the layout exists.
The method returns the new record id upon success and -1 upon failure (This avoids conflicting with a record id of 1). Errors are logged to the Apache log.
example:
C<my $exitstat = $layout->save(); # to save the record behind the $layout object>
=head2 get_attr($attribute)
Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $layout->get_attr($attribute);>
=head2 set_attr(attribute => value, attribute_2 => value)
Invoking the I<set_attr> method will set the value of the supplied attributes to the supplied values. The method accepts key/value pairs separated by
commas.
example:
C<$layout->set_attr(attribute => value);>
=head2 get_text_wrap_cols()
Invoking the I<get_text_wrap_cols> method will return the number of columns that can be printed on the label before wrapping to the next line.
examples:
C<my $text_wrap_cols = $layout->get_text_wrap_cols();>
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.
=cut

514
C4/Labels/Lib.pm Normal file
View file

@ -0,0 +1,514 @@
package C4::Labels::Lib;
# 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
# 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
use strict;
use warnings;
use Data::Dumper;
use C4::Context;
use C4::Debug;
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
use base qw(Exporter);
our @EXPORT_OK = qw(get_all_templates
get_all_layouts
get_all_profiles
get_batch_summary
get_label_summary
get_barcode_types
get_label_types
get_font_types
get_text_justification_types
get_label_output_formats
get_column_names
get_table_names
get_unit_values
html_table
);
}
#=head2 C4::Labels::Lib::_SELECT()
#
# This function returns a recordset upon success and 1 upon failure. Errors are logged to the Apache log.
#
# examples:
#
# my $field_value = _SELECT(field_name, table_name, condition);
#
#=cut
sub _SELECT {
my @params = @_;
my $query = "SELECT $params[0] FROM $params[1]";
$params[2] ? $query .= " WHERE $params[2];" : $query .= ';';
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return 1;
}
my $record_set = [];
while (my $row = $sth->fetchrow_hashref()) {
push(@$record_set, $row);
}
return $record_set;
}
my $barcode_types = [
{type => 'CODE39', name => 'Code 39', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern.', selected => 0},
{type => 'CODE39MOD', name => 'Code 39 + Modulo43', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern. Encodes Mod 43 checksum.', selected => 0},
{type => 'CODE39MOD10', name => 'Code 39 + Modulo10', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern. Encodes Mod 10 checksum.', selected => 0},
{type => 'COOP2OF5', name => 'COOP2of5', desc => 'Creates COOP2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
# {type => 'EAN13', name => 'EAN13', desc => 'Creates EAN13 barcodes from a string of 12 or 13 digits. The check number (the 13:th digit) is calculated if not supplied.', selected => 0},
# {type => 'EAN8', name => 'EAN8', desc => 'Translates a string of 7 or 8 digits to EAN8 barcodes. The check number (the 8:th digit) is calculated if not supplied.', selected => 0},
# {type => 'IATA2of5', name => 'IATA2of5', desc => 'Creates IATA2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
{type => 'INDUSTRIAL2OF5', name => 'Industrial2of5', desc => 'Creates Industrial2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
# {type => 'ITF', name => 'Interleaved2of5', desc => 'Translates the characters 0-9 to a barcodes. These barcodes could also be called 'Interleaved2of5'.', selected => 0},
# {type => 'MATRIX2OF5', name => 'Matrix2of5', desc => 'Creates Matrix2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
# {type => 'NW7', name => 'NW7', desc => 'Creates a NW7 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
# {type => 'UPCA', name => 'UPCA', desc => 'Translates a string of 11 or 12 digits to UPCA barcodes. The check number (the 12:th digit) is calculated if not supplied.', selected => 0},
# {type => 'UPCE', name => 'UPCE', desc => 'Translates a string of 6, 7 or 8 digits to UPCE barcodes. If the string is 6 digits long, '0' is added first in the string. The check number (the 8:th digit) is calculated if not supplied.', selected => 0},
];
my $label_types = [
{type => 'BIB', name => 'Biblio', desc => 'Only the bibliographic data is printed.', selected => 0},
{type => 'BARBIB', name => 'Barcode/Biblio', desc => 'Barcode proceeds bibliographic data.', selected => 0},
{type => 'BIBBAR', name => 'Biblio/Barcode', desc => 'Bibliographic data proceeds barcode.', selected => 0},
{type => 'ALT', name => 'Alternating', desc => 'Barcode and bibliographic data are printed on alternating labels.', selected => 0},
{type => 'BAR', name => 'Barcode', desc => 'Only the barcode is printed.', selected => 0},
];
my $font_types = [
{type => 'TR', name => 'Times-Roman', selected => 0},
{type => 'TB', name => 'Times-Bold', selected => 0},
{type => 'TI', name => 'Times-Italic', selected => 0},
{type => 'TBI', name => 'Times-Bold-Italic', selected => 0},
{type => 'C', name => 'Courier', selected => 0},
{type => 'CB', name => 'Courier-Bold', selected => 0},
{type => 'CO', name => 'Courier-Oblique', selected => 0},
{type => 'CBO', name => 'Courier-Bold-Oblique', selected => 0},
{type => 'H', name => 'Helvetica', selected => 0},
{type => 'HB', name => 'Helvetica-Bold', selected => 0},
{type => 'HBO', name => 'Helvetica-Bold-Oblique', selected => 0},
];
my $text_justification_types = [
{type => 'L', name => 'Left', selected => 0},
{type => 'C', name => 'Center', selected => 0},
{type => 'R', name => 'Right', selected => 0},
# {type => 'F', name => 'Full', selected => 0},
];
my $unit_values = [
{type => 'POINT', desc => 'PostScript Points', value => 1, selected => 0},
{type => 'AGATE', desc => 'Adobe Agates', value => 5.1428571, selected => 0},
{type => 'INCH', desc => 'US Inches', value => 72, selected => 0},
{type => 'MM', desc => 'SI Millimeters', value => 2.83464567, selected => 0},
{type => 'CM', desc => 'SI Centimeters', value => 28.3464567, selected => 0},
];
my $label_output_formats = [
{type => 'pdf', desc => 'PDF File'},
{type => 'csv', desc => 'CSV File'},
];
=head2 C4::Labels::Lib::get_all_templates()
This function returns a reference to a hash containing all templates upon success and 1 upon failure. Errors are logged to the Apache log.
examples:
my $templates = get_all_templates();
=cut
sub get_all_templates {
my %params = @_;
my @templates = ();
my $query = "SELECT " . ($params{'field_list'} ? $params{'field_list'} : '*') . " FROM labels_templates";
$query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
my $sth = C4::Context->dbh->prepare($query);
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
ADD_TEMPLATES:
while (my $template = $sth->fetchrow_hashref) {
push(@templates, $template);
}
return \@templates;
}
=head2 C4::Labels::Lib::get_all_layouts()
This function returns a reference to a hash containing all layouts upon success and 1 upon failure. Errors are logged to the Apache log.
examples:
my $layouts = get_all_layouts();
=cut
sub get_all_layouts {
my %params = @_;
my @layouts = ();
#my $query = "SELECT * FROM labels_layouts;";
my $query = "SELECT " . ($params{'field_list'} ? $params{'field_list'} : '*') . " FROM labels_layouts";
$query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
my $sth = C4::Context->dbh->prepare($query);
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
ADD_LAYOUTS:
while (my $layout = $sth->fetchrow_hashref) {
push(@layouts, $layout);
}
return \@layouts;
}
=head2 C4::Labels::Lib::get_all_profiles()
This function returns an arrayref whose elements are hashes containing all profiles upon success and 1 upon failure. Errors are logged
to the Apache log. Two parameters are accepted. The first limits the field(s) returned. This parameter should be string of comma separted
fields. ie. "field_1, field_2, ...field_n" The second limits the records returned based on a string containing a valud SQL 'WHERE' filter.
NOTE: Do not pass in the keyword 'WHERE.'
examples:
my $profiles = get_all_profiles();
my $profiles = get_all_profiles(field_list => field_list, filter => filter_string);
=cut
sub get_all_profiles {
my %params = @_;
my @profiles = ();
my $query = "SELECT " . ($params{'field_list'} ? $params{'field_list'} : '*') . " FROM printers_profile";
$query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3 if $debug;
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
ADD_PROFILES:
while (my $profile = $sth->fetchrow_hashref) {
push(@profiles, $profile);
}
return \@profiles;
}
=head2 C4::Labels::Lib::get_batch_summary()
This function returns an arrayref whose elements are hashes containing the batch_ids of current batches along with the item count
for each batch upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.
NOTE: Do not pass in the keyword 'WHERE.'
examples:
my $batches = get_batch_summary();
my $batches = get_batch_summary(filter => filter_string);
=cut
sub get_batch_summary {
my %params = @_;
my @batches = ();
my $query = "SELECT DISTINCT batch_id FROM labels_batches";
$query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
return -1;
}
ADD_BATCHES:
while (my $batch = $sth->fetchrow_hashref) {
my $query = "SELECT count(item_number) FROM labels_batches WHERE batch_id=?;";
my $sth1 = C4::Context->dbh->prepare($query);
$sth1->execute($batch->{'batch_id'});
if ($sth1->err) {
warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
return -1;
}
my $count = $sth1->fetchrow_arrayref;
$batch->{'_item_count'} = @$count[0];
push(@batches, $batch);
}
return \@batches;
}
=head2 C4::Labels::Lib::get_label_summary()
This function returns an arrayref whose elements are hashes containing the label_ids of current labels along with the item count
for each label upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.
NOTE: Do not pass in the keyword 'WHERE.'
examples:
my $labels = get_label_summary();
my $labels = get_label_summary(items => @item_list);
=cut
sub get_label_summary {
my %params = @_;
my $label_number = 0;
my @label_summaries = ();
my $query = "SELECT b.title, b.author, bi.itemtype, i.barcode, i.biblionumber FROM biblio AS b, biblioitems AS bi ,items AS i, labels_batches AS l WHERE itemnumber=? AND l.item_number=i.itemnumber AND i.biblioitemnumber=bi.biblioitemnumber AND bi.biblionumber=b.biblionumber AND l.batch_id=?;";
my $sth = C4::Context->dbh->prepare($query);
foreach my $item (@{$params{'items'}}) {
$label_number++;
$sth->execute($item->{'item_number'}, $params{'batch_id'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
return -1;
}
my $record = $sth->fetchrow_hashref;
my $label_summary->{'_label_number'} = $label_number;
$record->{'author'} =~ s/[^\.|\w]$// if $record->{'author'}; # strip off ugly trailing chars... but not periods or word chars
$record->{'title'} =~ s/\W*$//; # strip off ugly trailing chars
# FIXME contructing staff interface URLs should be done *much* higher up the stack - for the most part, C4 module code
# should not know that it's part of a web app
$record->{'title'} = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' . $record->{'biblionumber'} . '"> ' . $record->{'title'} . '</a>';
$label_summary->{'_summary'} = $record->{'title'} . " | " . ($record->{'author'} ? $record->{'author'} : 'N/A');
$label_summary->{'_item_type'} = $record->{'itemtype'};
$label_summary->{'_barcode'} = $record->{'barcode'};
$label_summary->{'_item_number'} = $item->{'item_number'};
$label_summary->{'_label_id'} = $item->{'label_id'};
push (@label_summaries, $label_summary);
}
return \@label_summaries;
}
=head2 C4::Labels::Lib::get_barcode_types()
This function returns a reference to an array of hashes containing all barcode types along with their name and description.
examples:
my $barcode_types = get_barcode_types();
=cut
sub get_barcode_types {
return $barcode_types;
}
=head2 C4::Labels::Lib::get_label_types()
This function returns a reference to an array of hashes containing all label types along with their name and description.
examples:
my $label_types = get_label_types();
=cut
sub get_label_types {
return $label_types;
}
=head2 C4::Labels::Lib::get_font_types()
This function returns a reference to an array of hashes containing all font types along with their name and description.
examples:
my $font_types = get_font_types();
=cut
sub get_font_types {
return $font_types;
}
=head2 C4::Labels::Lib::get_text_justification_types()
This function returns a reference to an array of hashes containing all text justification types along with their name and description.
examples:
my $text_justification_types = get_text_justification_types();
=cut
sub get_text_justification_types {
return $text_justification_types;
}
=head2 C4::Labels::Lib::get_unit_values()
This function returns a reference to an array of hashes containing all unit types along with their description and multiplier. NOTE: All units are relative to a PostScript Point.
There are 72 PS points to the inch.
examples:
my $unit_values = get_unit_values();
=cut
sub get_unit_values {
return $unit_values;
}
=head2 C4::Labels::Lib::get_label_output_formats()
This function returns a reference to an array of hashes containing all label output formats along with their description.
examples:
my $label_output_formats = get_label_output_formats();
=cut
sub get_label_output_formats {
return $label_output_formats;
}
=head2 C4::Labels::Lib::get_column_names($table_name)
Return an arrayref of an array containing the column names of the supplied table.
=cut
sub get_column_names {
my $table = shift;
my $dbh = C4::Context->dbh();
my $column_names = [];
my $sth = $dbh->column_info(undef,undef,$table,'%');
while (my $info = $sth->fetchrow_hashref()){
$$column_names[$info->{'ORDINAL_POSITION'}] = $info->{'COLUMN_NAME'};
}
return $column_names;
}
=head2 C4::Labels::Lib::get_table_names($search_term)
Return an arrayref of an array containing the table names which contain the supplied search term.
=cut
sub get_table_names {
my $search_term = shift;
my $dbh = C4::Context->dbh();
my $table_names = [];
my $sth = $dbh->table_info(undef,undef,"%$search_term%");
while (my $info = $sth->fetchrow_hashref()){
push (@$table_names, $info->{'TABLE_NAME'});
}
return $table_names;
}
=head2 C4::Labels::Lib::html_table()
This function returns an arrayref of an array of hashes contianing the supplied data formatted suitably to
be passed off as a T::P template parameter and used to build an html table.
examples:
my $table = html_table(header_fields, array_of_row_data);
=cut
sub html_table {
my $headers = shift;
my $data = shift;
return undef if scalar(@$data) == 0; # no need to generate a table if there is not data to display
my $table = [];
my $fields = [];
my @headers = ();
my @table_columns = ();
my ($row_index, $col_index) = (0,0);
my $cols = 0; # number of columns to wrap on
my $field_count = 0;
my $select_value = undef;
my $link_field = undef;
POPULATE_HEADER:
foreach my $header (@$headers) {
my @key = keys %$header;
if ($key[0] eq 'select' ) {
push (@table_columns, $key[0]);
$$fields[$col_index] = {hidden => 0, select_field => 0, field_name => ($key[0]), field_label => $header->{$key[0]}{'label'}};
# do special formatting stuff....
$select_value = $header->{$key[0]}{'value'};
}
else {
# do special formatting stuff....
$link_field->{$key[0]} = ($header->{$key[0]}{'link_field'} == 1 ? 1 : 0);
push (@table_columns, $key[0]);
$$fields[$col_index] = {hidden => 0, select_field => 0, field_name => ($key[0]), field_label => $header->{$key[0]}{'label'}};
}
$field_count++;
$col_index++;
}
$$table[$row_index] = {header_fields => $fields};
$cols = $col_index;
$field_count *= scalar(@$data); # total fields to be displayed in the table
$col_index = 0;
$row_index++;
$fields = [];
POPULATE_TABLE:
foreach my $db_row (@$data) {
POPULATE_ROW:
foreach my $table_column (@table_columns) {
if (grep {$table_column eq $_} keys %$db_row) {
$$fields[$col_index] = {hidden => 0, link_field => $link_field->{$table_column}, select_field => 0, field_name => ($table_column . "_tbl"), field_value => $db_row->{$table_column}};
$col_index++;
next POPULATE_ROW;
}
elsif ($table_column =~ m/^_((.*)_(.*$))/) { # this a special case
my $table_name = get_table_names($2);
my $record_set = _SELECT($1, @$table_name[0], $2 . "_id = " . $db_row->{$2 . "_id"});
$$fields[$col_index] = {hidden => 0, link_field => $link_field->{$table_column}, select_field => 0, field_name => ($table_column . "_tbl"), field_value => $$record_set[0]{$1}};
$col_index++;
next POPULATE_ROW;
}
elsif ($table_column eq 'select' ) {
$$fields[$col_index] = {hidden => 0, select_field => 1, field_name => 'select', field_value => $db_row->{$select_value}};
}
}
$$table[$row_index] = {text_fields => $fields};
$col_index = 0;
$row_index++;
$fields = [];
}
return $table;
}
1;
__END__
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=cut

291
C4/Labels/PDF.pm Normal file
View file

@ -0,0 +1,291 @@
package C4::Labels::PDF;
# 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
# 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
use strict;
use warnings;
use PDF::Reuse;
use PDF::Reuse::Barcode;
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
sub _InitVars {
my $self = shift;
my $param = shift;
prInitVars($param);
}
sub new {
my $invocant = shift;
my $type = ref($invocant) || $invocant;
my %opts = @_;
my $self = {};
_InitVars() if ($opts{InitVars} == 0);
_InitVars($opts{InitVars}) if ($opts{InitVars} > 0);
delete($opts{InitVars});
prDocDir($opts{'DocDir'}) if $opts{'DocDir'};
delete($opts{'DocDir'});
prFile(%opts);
bless ($self, $type);
return $self;
}
sub End {
my $self = shift;
prEnd();
}
sub Add {
my $self = shift;
my $string = shift;
prAdd($string);
}
sub Bookmark {
my $self = shift;
my $reference = shift;
prBookmark($reference);
}
sub Compress {
my $self = shift;
my $directive = shift;
prCompress($directive);
}
sub Doc {
my $self = shift;
my %params = @_;
prDoc(%params);
}
sub DocForm {
my $self = shift;
my %params = @_;
return prDocForm(%params);
}
sub Extract {
my $self = shift;
my ($pdfFile, $pageNo, $oldInternalName) = @_;
return prExtract($pdfFile, $pageNo, $oldInternalName);
}
sub Field {
my $self = shift;
my ($fieldName, $value) = @_;
prField($fieldName, $value);
}
sub Font {
my $self = shift;
my $fontName = shift;
return prFont($fontName);
}
sub FontSize {
my $self = shift;
my $size = shift;
return prFontSize($size);
}
sub Form {
my $self = shift;
my %params = @_;
return prForm(%params);
}
sub GetLogBuffer {
my $self = shift;
return prGetLogBuffer();
}
sub GraphState {
my $self = shift;
my $string = shift;
prGraphState($string);
}
sub Image {
my $self = shift;
my %params = @_;
return prImage(%params);
}
sub Init {
my $self = shift;
my ($string, $duplicateCode) = @_;
prInit($string, $duplicateCode);
}
sub Jpeg {
my $self = shift;
my ($imageFile, $width, $height) = @_;
return prJpeg($imageFile, $width, $height);
}
sub Js {
my $self = shift;
my $string_or_fileName = shift;
prJs($string_or_fileName);
}
sub Link {
my $self = shift;
my %params = @_;
prLink(%params);
}
sub Log {
my $self = shift;
my $string = shift;
prLog($string);
}
sub LogDir {
my $self = shift;
my $directory = shift;
prLogDir($directory);
}
sub Mbox {
my $self = shift;
my ($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY) = @_;
prMbox($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
}
sub Page {
my $self = shift;
my $noLog = shift;
prPage($noLog);
}
sub SinglePage {
my $self = shift;
my ($file, $pageNumber) = @_;
return prSinglePage($file, $pageNumber);
}
sub StrWidth {
my $self = shift;
my ($string, $font, $fontSize) = @_;
return prStrWidth($string, $font, $fontSize);
}
sub Text {
my $self = shift;
my ($x, $y, $string, $align, $rotation) = @_;
return prText($x, $y, $string, $align, $rotation);
}
sub TTFont {
my $self = shift;
my $path = shift;
return prTTFont($path);
}
sub Code128 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::Code128(%opts);
}
sub Code39 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::Code39(%opts);
}
sub COOP2of5 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::COOP2of5(%opts);
}
sub EAN13 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::EAN13(%opts);
}
sub EAN8 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::EAN8(%opts);
}
sub IATA2of5 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::IATA2of5(%opts);
}
sub Industrial2of5 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::Industrial2of5(%opts);
}
sub ITF {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::ITF(%opts);
}
sub Matrix2of5 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::Matrix2of5(%opts);
}
sub NW7 {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::NW7(%opts);
}
sub UPCA {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::UPCA(%opts);
}
sub UPCE {
my $self = shift;
my %opts = @_;
PDF::Reuse::Barcode::UPCE(%opts);
}
1;
__END__
=head1 NAME
C4::Labels::PDF - A class wrapper for PDF::Reuse and PDF::Reuse::Barcode to allow usage as a psuedo-object. For usage see
PDF::Reuse documentation and C4::Labels::PDF code.
=cut
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=cut

355
C4/Labels/Profile.pm Normal file
View file

@ -0,0 +1,355 @@
package C4::Labels::Profile;
use strict;
use warnings;
use C4::Context;
use C4::Debug;
use C4::Labels::Lib 1.000000 qw(get_unit_values);
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
sub _check_params {
my $given_params = {};
my $exit_code = 0;
my @valid_profile_params = (
'printer_name',
'template_id',
'paper_bin',
'offset_horz',
'offset_vert',
'creep_horz',
'creep_vert',
'units',
);
if (scalar(@_) >1) {
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_profile_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_profile_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
return $exit_code;
}
sub _conv_points {
my $self = shift;
my @unit_value = grep {$_->{'type'} eq $self->{units}} @{get_unit_values()};
$self->{offset_horz} = $self->{offset_horz} * $unit_value[0]->{'value'};
$self->{offset_vert} = $self->{offset_vert} * $unit_value[0]->{'value'};
$self->{creep_horz} = $self->{creep_horz} * $unit_value[0]->{'value'};
$self->{creep_vert} = $self->{creep_vert} * $unit_value[0]->{'value'};
return $self;
}
sub new {
my $invocant = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my $type = ref($invocant) || $invocant;
my $self = {
printer_name => 'Default Printer',
template_id => '',
paper_bin => 'Tray 1',
offset_horz => 0,
offset_vert => 0,
creep_horz => 0,
creep_vert => 0,
units => 'POINT',
@_,
};
bless ($self, $type);
return $self;
}
sub retrieve {
my $invocant = shift;
my %opts = @_;
my $type = ref($invocant) || $invocant;
my $query = "SELECT * FROM printers_profile WHERE profile_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{profile_id});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $self = $sth->fetchrow_hashref;
$self = _conv_points($self) if ($opts{convert} && $opts{convert} == 1);
bless ($self, $type);
return $self;
}
sub delete {
my $self = {};
my %opts = ();
my $call_type = '';
my $query_param = '';
if (ref($_[0])) {
$self = shift; # check to see if this is a method call
$call_type = 'C4::Labels::Profile->delete';
$query_param = $self->{'profile_id'};
}
else {
%opts = @_;
$call_type = 'C4::Labels::Profile::delete';
$query_param = $opts{'profile_id'};
}
if ($query_param eq '') { # If there is no profile id then we cannot delete it
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 $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute($query_param);
}
sub save {
my $self = shift;
if ($self->{'profile_id'}) { # if we have an profile_id, the record exists and needs UPDATE
my @params;
my $query = "UPDATE printers_profile SET ";
foreach my $key (keys %{$self}) {
next if $key eq 'profile_id';
push (@params, $self->{$key});
$query .= "$key=?, ";
}
$query = substr($query, 0, (length($query)-2));
push (@params, $self->{'profile_id'});
$query .= " WHERE profile_id=?;";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error on attempted UPDATE: %s', $sth->errstr);
return -1;
}
return $self->{'profile_id'};
}
else { # otherwise create a new record
my @params;
my $query = "INSERT INTO printers_profile (";
foreach my $key (keys %{$self}) {
push (@params, $self->{$key});
$query .= "$key, ";
}
$query = substr($query, 0, (length($query)-2));
$query .= ") VALUES (";
for (my $i=1; $i<=(scalar keys %$self); $i++) {
$query .= "?,";
}
$query = substr($query, 0, (length($query)-1));
$query .= ");";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(profile_id) FROM printers_profile;");
$sth1->execute();
my $tmpl_id = $sth1->fetchrow_array;
return $tmpl_id;
}
}
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
else {
warn sprintf('%s is currently undefined.', $attr);
return -1;
}
}
sub set_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my %attrs = @_;
foreach my $attrib (keys(%attrs)) {
$self->{$attrib} = $attrs{$attrib};
};
return 0;
}
1;
__END__
=head1 NAME
C4::Labels::Profile - A class for creating and manipulating profile objects in Koha
=head1 ABSTRACT
This module provides methods for creating, retrieving, and otherwise manipulating label profile objects used by Koha to create and export labels.
=head1 METHODS
=head2 new()
Invoking the I<new> method constructs a new profile object containing the default values for a template.
The following parameters are optionally accepted as key => value pairs:
C<printer_name> The name of the printer to which this profile applies.
C<template_id> The template to which this profile may be applied. NOTE: There may be multiple profiles which may be applied to the same template.
C<paper_bin> The paper bin of the above printer to which this profile applies. NOTE: printer name, template id, and paper bin must form a unique combination.
C<offset_horz> Amount of compensation for horizontal offset (position of text on a single label). This amount is measured in the units supplied by the units parameter in this profile.
C<offset_vert> Amount of compensation for vertical offset.
C<creep_horz> Amount of compensation for horizontal creep (tendency of text to 'creep' off of the labels over the span of the entire page).
C<creep_vert> Amount of compensation for vertical creep.
C<units> The units of measure used for this template. These B<must> match the measures you supply above or
bad things will happen to your document. NOTE: The only supported units at present are:
=over 9
=item .
POINT = Postscript Points (This is the base unit in the Koha label creator.)
=item .
AGATE = Adobe Agates (5.1428571 points per)
=item .
INCH = US Inches (72 points per)
=item .
MM = SI Millimeters (2.83464567 points per)
=item .
CM = SI Centimeters (28.3464567 points per)
=back
example:
C<my $profile = C4::Labels::Profile->new(); # Creates and returns a new profile object>
C<my $profile = C4::Labels::Profile->new(template_id => 1, paper_bin => 'Bypass Tray', offset_horz => 0.02, units => 'POINT'); # Creates and returns a new profile object using
the supplied values to override the defaults>
B<NOTE:> This profile is I<not> written to the database until save() is invoked. You have been warned!
=head2 retrieve(profile_id => $profile_id, convert => 1)
Invoking the I<retrieve> method constructs a new profile object containing the current values for profile_id. The method returns a new object upon success and 1 upon failure.
Errors are logged to the Apache log. One further option maybe accessed. See the examples below for further description.
examples:
C<my $profile = C4::Labels::Profile->retrieve(profile_id => 1); # Retrieves profile record 1 and returns an object containing the record>
C<my $profile = C4::Labels::Profile->retrieve(profile_id => 1, convert => 1); # Retrieves profile record 1, converts the units to points and returns an object containing the record>
=head2 delete()
Invoking the delete method attempts to delete the profile from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that profile from the database. See the example below.
examples:
C<my $exitstat = $profile->delete(); # to delete the record behind the $profile object>
C<my $exitstat = C4::Labels::Profile::delete(profile_id => 1); # to delete profile record 1>
=head2 save()
Invoking the I<save> method attempts to insert the profile into the database if the profile is new and update the existing profile record if the profile exists. The method returns
the new record profile_id upon success and -1 upon failure (This avoids conflicting with a record profile_id of 1). Errors are logged to the Apache log.
example:
C<my $exitstat = $profile->save(); # to save the record behind the $profile object>
=head2 get_attr($attribute)
Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $profile->get_attr($attribute);>
=head2 set_attr(attribute => value, attribute_2 => value)
Invoking the I<set_attr> method will set the value of the supplied attributes to the supplied values. The method accepts key/value pairs separated by commas.
example:
$profile->set_attr(attribute => value);
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.
=cut
#=head1
#drawbox( ($left_margin), ($top_margin), ($page_width-(2*$left_margin)), ($page_height-(2*$top_margin)) ); # FIXME: Breakout code to print alignment page for printer profile setup
#
#=head2 draw_boundaries
#
# sub draw_boundaries ($llx_spine, $llx_circ1, $llx_circ2,
# $lly, $spine_width, $label_height, $circ_width)
#
#This sub draws boundary lines where the label outlines are, to aid in printer testing, and debugging.
#
#=cut
#
## FIXME: Template use for profile adjustment...
##sub draw_boundaries {
##
## my (
## $llx_spine, $llx_circ1, $llx_circ2, $lly,
## $spine_width, $label_height, $circ_width
## ) = @_;
##
## my $lly_initial = ( ( 792 - 36 ) - 90 );
## $lly = $lly_initial; # FIXME - why are we ignoring the y_pos parameter by redefining it?
## my $i = 1;
##
## for ( $i = 1 ; $i <= 8 ; $i++ ) {
##
## _draw_box( $llx_spine, $lly, ($spine_width), ($label_height) );
##
## #warn "OLD BOXES x=$llx_spine, y=$lly, w=$spine_width, h=$label_height";
## _draw_box( $llx_circ1, $lly, ($circ_width), ($label_height) );
## _draw_box( $llx_circ2, $lly, ($circ_width), ($label_height) );
##
## $lly = ( $lly - $label_height );
##
## }
##}
#
#
#
#=cut

396
C4/Labels/Template.pm Normal file
View file

@ -0,0 +1,396 @@
package C4::Labels::Template;
use strict;
use warnings;
use PDF::Reuse;
use POSIX qw(ceil);
use C4::Context;
use C4::Debug;
use C4::Labels::Profile 1.000000;
use C4::Labels::PDF 1.000000;
use C4::Labels::Lib 1.000000 qw(get_unit_values);
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
sub _check_params {
my $given_params = {};
my $exit_code = 0;
my @valid_template_params = (
'profile_id',
'template_code',
'template_desc',
'page_width',
'page_height',
'label_width',
'label_height',
'top_text_margin',
'left_text_margin',
'top_margin',
'left_margin',
'cols',
'rows',
'col_gap',
'row_gap',
'units',
);
if (scalar(@_) >1) {
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_template_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_template_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
return $exit_code;
}
sub _conv_points {
my $self = shift;
my @unit_value = grep {$_->{'type'} eq $self->{'units'}} @{get_unit_values()};
$self->{'page_width'} = $self->{'page_width'} * $unit_value[0]->{'value'};
$self->{'page_height'} = $self->{'page_height'} * $unit_value[0]->{'value'};
$self->{'label_width'} = $self->{'label_width'} * $unit_value[0]->{'value'};
$self->{'label_height'} = $self->{'label_height'} * $unit_value[0]->{'value'};
$self->{'top_text_margin'} = $self->{'top_text_margin'} * $unit_value[0]->{'value'};
$self->{'left_text_margin'} = $self->{'left_text_margin'} * $unit_value[0]->{'value'};
$self->{'top_margin'} = $self->{'top_margin'} * $unit_value[0]->{'value'};
$self->{'left_margin'} = $self->{'left_margin'} * $unit_value[0]->{'value'};
$self->{'col_gap'} = $self->{'col_gap'} * $unit_value[0]->{'value'};
$self->{'row_gap'} = $self->{'row_gap'} * $unit_value[0]->{'value'};
return $self;
}
sub _apply_profile {
my $self = shift;
my $profile = C4::Labels::Profile->retrieve(profile_id => $self->{'profile_id'}, convert => 1);
$self->{'top_margin'} = $self->{'top_margin'} + $profile->get_attr('offset_vert'); # controls vertical offset
$self->{'left_margin'} = $self->{'left_margin'} + $profile->get_attr('offset_horz'); # controls horizontal offset
$self->{'label_height'} = $self->{'label_height'} + $profile->get_attr('creep_vert'); # controls vertical creep
$self->{'label_width'} = $self->{'label_width'} + $profile->get_attr('creep_horz'); # controls horizontal creep
return $self;
}
sub new {
my $invocant = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my $type = ref($invocant) || $invocant;
my $self = {
profile_id => '0',
template_code => 'DEFAULT TEMPLATE',
template_desc => 'Default description',
page_width => 0,
page_height => 0,
label_width => 0,
label_height => 0,
top_text_margin => 0,
left_text_margin => 0,
top_margin => 0,
left_margin => 0,
cols => 0,
rows => 0,
col_gap => 0,
row_gap => 0,
units => 'POINT',
template_stat => 0, # false if any data has changed and the db has not been updated
@_,
};
bless ($self, $type);
return $self;
}
sub retrieve {
my $invocant = shift;
my %opts = @_;
my $type = ref($invocant) || $invocant;
my $query = "SELECT * FROM labels_templates WHERE template_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{template_id});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $self = $sth->fetchrow_hashref;
$self = _conv_points($self) if (($opts{convert} && $opts{convert} == 1) || $opts{profile_id});
$self = _apply_profile($self) if $opts{profile_id} && $self->{'profile_id'}; # don't bother if there is no profile_id
$self->{'template_stat'} = 1;
bless ($self, $type);
return $self;
}
sub delete {
my $self = {};
my %opts = ();
my $call_type = '';
my $query_param = '';
if (ref($_[0])) {
$self = shift; # check to see if this is a method call
$call_type = 'C4::Labels::Template->delete';
$query_param = $self->{'template_id'};
}
else {
%opts = @_;
$call_type = 'C4::Labels::Template::delete';
$query_param = $opts{'template_id'};
}
if ($query_param eq '') { # If there is no template id then we cannot delete it
warn sprintf('%s : Cannot delete layout as the template id is invalid or non-existant.', $call_type);
return -1;
}
my $query = "DELETE FROM labels_templates WHERE template_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($query_param);
$self->{'template_stat'} = 0;
}
sub save {
my $self = shift;
if ($self->{'template_id'}) { # if we have an template_id, the record exists and needs UPDATE
my @params;
my $query = "UPDATE labels_templates SET ";
foreach my $key (keys %{$self}) {
next if ($key eq 'template_id') || ($key eq 'template_stat');
push (@params, $self->{$key});
$query .= "$key=?, ";
}
$query = substr($query, 0, (length($query)-2));
push (@params, $self->{'template_id'});
$query .= " WHERE template_id=?;";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
$self->{'template_stat'} = 1;
return $self->{'template_id'};
}
else { # otherwise create a new record
my @params;
my $query = "INSERT INTO labels_templates (";
foreach my $key (keys %{$self}) {
next if $key eq 'template_stat';
push (@params, $self->{$key});
$query .= "$key, ";
}
$query = substr($query, 0, (length($query)-2));
$query .= ") VALUES (";
for (my $i=1; $i<=((scalar keys %$self) - 1); $i++) { # key count less keys not db related...
$query .= "?,";
}
$query = substr($query, 0, (length($query)-1));
$query .= ");";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(template_id) FROM labels_templates;");
$sth1->execute();
my $template_id = $sth1->fetchrow_array;
$self->{'template_id'} = $template_id;
$self->{'template_stat'} = 1;
return $template_id;
}
}
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
else {
return -1;
}
}
sub set_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
return -1;
}
my %attrs = @_;
foreach my $attrib (keys(%attrs)) {
$self->{$attrib} = $attrs{$attrib};
};
}
sub get_label_position {
my ($self, $start_label) = @_;
my ($row_count, $col_count, $llx, $lly) = 0,0,0,0;
if ($start_label eq 1) {
$row_count = 1;
$col_count = 1;
$llx = $self->{'left_margin'};
$lly = ($self->{'page_height'} - $self->{'top_margin'} - $self->{'label_height'});
return ($row_count, $col_count, $llx, $lly);
}
else {
$row_count = ceil($start_label / $self->{'cols'});
$col_count = ($start_label - (($row_count - 1) * $self->{'cols'}));
$llx = $self->{'left_margin'} + ($self->{'label_width'} * ($col_count - 1)) + ($self->{'col_gap'} * ($col_count - 1));
$lly = $self->{'page_height'} - $self->{'top_margin'} - ($self->{'label_height'} * $row_count) - ($self->{'row_gap'} * ($row_count - 1));
return ($row_count, $col_count, $llx, $lly);
}
}
1;
__END__
=head1 NAME
C4::Labels::Template - A class for creating and manipulating template objects in Koha
=head1 ABSTRACT
This module provides methods for creating, retrieving, and otherwise manipulating label template objects used by Koha to create and export labels.
=head1 METHODS
=head2 new()
Invoking the I<new> method constructs a new template object containing the default values for a template.
The following parameters are optionally accepted as key => value pairs:
C<profile_id> A valid profile id to be assciated with this template. NOTE: The profile must exist in the database and B<not> be assigned to another template.
C<template_code> A template code. ie. 'Avery 5160 | 1 x 2-5/8'
C<template_desc> A readable description of the template. ie. '3 columns, 10 rows of labels'
C<page_width> The width of the page measured in the units supplied by the units parameter in this template.
C<page_height> The height of the page measured in the same units.
C<label_width> The width of a single label on the page this template applies to.
C<label_height> The height of a single label on the page.
C<top_text_margin> The measure of the top margin on a single label on the page.
C<left_text_margin> The measure of the left margin on a single label on the page.
C<top_margin> The measure of the top margin of the page.
C<left_margin> The measure of the left margin of the page.
C<cols> The number of columns of labels on the page.
C<rows> The number of rows of labels on the page.
C<col_gap> The measure of the gap between the columns of labels on the page.
C<row_gap> The measure of the gap between the rows of labels on the page.
C<units> The units of measure used for this template. These B<must> match the measures you supply above or
bad things will happen to your document. NOTE: The only supported units at present are:
=over 9
=item .
POINT = Postscript Points (This is the base unit in the Koha label creator.)
=item .
AGATE = Adobe Agates (5.1428571 points per)
=item .
INCH = US Inches (72 points per)
=item .
MM = SI Millimeters (2.83464567 points per)
=item .
CM = SI Centimeters (28.3464567 points per)
=back
example:
my $template = Template->new(); # Creates and returns a new template object with the defaults
my $template = C4::Labels::Template->new(profile_id => 1, page_width => 8.5, page_height => 11.0, units => 'INCH'); # Creates and returns a new template object using
the supplied values to override the defaults
B<NOTE:> This template is I<not> written to the database untill save() is invoked. You have been warned!
=head2 retrieve(template_id => $template_id)
Invoking the I<retrieve> method constructs a new template object containing the current values for template_id. The method returns
a new object upon success and -1 upon failure. Errors are logged to the Apache log. Two further options may be accessed. See the example
below for further description.
examples:
C<my $template = C4::Labels::Template->retrieve(template_id => 1); # Retrieves template record 1 and returns an object containing the record>
C<my $template = C4::Labels::Template->retrieve(template_id => 1, convert => 1); # Retrieves template record 1, converts the units to points,
and returns an object containing the record>
C<my $template = C4::Labels::Template->retrieve(template_id => 1, profile_id => 1); # Retrieves template record 1, converts the units
to points, applies the currently associated profile id, and returns an object containing the record.>
=head2 delete()
Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that template from the database. See the example below.
examples:
C<my $exitstat = $template->delete(); # to delete the record behind the $template object>
C<my $exitstat = C4::Labels::Template::delete(template_id => 1); # to delete template record 1>
=head2 save()
Invoking the I<save> method attempts to insert the template into the database if the template is new and update the existing template record if
the template exists. The method returns the new record template_id upon success and -1 upon failure (This avoids template_ids conflicting with a
record template_id of 1). Errors are logged to the Apache log.
example:
C<my $template_id = $template->save(); # to save the record behind the $template object>
=head2 get_attr($attribute)
Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $template->get_attr($attribute);>
=head2 set_attr(attribute => value, attribute_2 => value)
Invoking the I<set_attr> method will set the value of the supplied attributes to the supplied values. The method accepts key/value pairs separated by
commas.
example:
C<$template->set_attr(attribute => value);>
=head2 get_label_position($start_label)
Invoking the I<get_label_position> method will return the row, column coordinates on the starting page and the lower left x,y coordinates on the starting
label for the template object.
examples:
C<my ($row_count, $col_count, $llx, $lly) = $template->get_label_position($start_label);>
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.
=cut

View file

@ -0,0 +1,292 @@
package C4::Labels::Patroncard;
# 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
# 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
use strict;
use warnings;
use C4::Context;
use C4::Debug;
use C4::Biblio;
use C4::Labels::Layout 1.000000; # use version 1.0.0 or better
use C4::Labels::Template 1.000000;
use Data::Dumper;
BEGIN {
use version; our $VERSION = qv('1.0.0_1');
}
sub _check_params {
my $given_params = {};
my $exit_code = 0;
my @valid_template_params = (
'layout_id',
'tmpl_id',
'prof_id',
);
if (scalar(@_) >1) {
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_template_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_template_params)) {
warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
return $exit_code;
}
=head1 NAME
C4::Labels::Batch - A class for creating and manipulating batch objects in Koha
=cut
=head1 METHODS
=head2 C4::Labels::Batch->new(layout_id => layout_id, tmpl_id => template_id, prof_id => prof_id)
Invoking the I<new> method constructs a new batch object with no items.
example:
my $batch = C4::Labels::Batch->new(layout_id => layout_id, tmpl_id => template_id, prof_id => prof_id);
# Creates and returns a new batch object
B<NOTE:> This batch is I<not> written to the database untill $batch->save() is invoked. You have been warned!
=cut
sub new {
my ($invocant, %params) = @_;
my $type = ref($invocant) || $invocant;
my $self = {
batch_id => 0,
layout_id => $params{layout_id},
tmpl_id => $params{tmpl_id},
prof_id => $params{prof_id},
items => [],
batch_stat => 0, # False if any data has changed and the db has not been updated
};
bless ($self, $type);
return $self;
}
=head2 $batch->add_item($item_number)
Invoking the I<add_item> method will add the supplied item to the batch object.
example:
$batch->add_item($item_number);
=cut
sub add_item {
my $self = shift;
my $item_num = shift;
push (@{$self->{items}}, $item_num);
$self->{batch_stat} = 0;
}
=head2 $batch->get_attr()
Invoking the I<get_attr> method will return the requested attribute.
example:
my @items = $batch->get_attr($attr);
=cut
sub get_attr {
my $self = shift;
return $self->{$_[0]};
}
=head2 $batch->delete_item()
Invoking the I<delete_item> method will delete the supplied item from the batch object.
example:
$batch->delete_item();
=cut
sub delete_item {
my $self = shift;
my $item_num = shift;
my $index = 0;
++$index until $$self->{items}[$index] == $item_num or $item_num > $#$self->{items};
delete ($$self->{items}[$index]);
$self->{batch_stat} = 0;
}
=head2 $batch->save()
Invoking the I<save> method attempts to insert the batch into the database if the batch is new and
update the existing batch record if the batch exists. The method returns the new record batch_id upon
success and -1 upon failure (This avoids conflicting with a record batch_id of 1). Errors are
logged to the Apache log.
example:
my $exitstat = $batch->save(); # to save the record behind the $batch object
=cut
sub save {
my $self = shift;
if ($self->{batch_id} > 0) {
foreach my $item_number (@$self->{items}) {
my $query = "UPDATE labels_batches SET item_number=?, layout_id=?, tmpl_id=?, prof_id=? WHERE batch_id=?;";
warn "DEBUG: Updating: $query\n" if $debug;
my $sth->C4::Context->dbh->prepare($query);
$sth->execute($item_number, $self->{layout_id}, $self->{tmpl_id}, $self->{prof_id}, $self->{batch_id});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
}
}
else {
foreach my $item_number (@$self->{items}) {
my $query = "INSERT INTO labels_batches (item_number, layout_id, tmpl_id, prof_id) VALUES (?,?,?,?);";
warn "DEBUG: Inserting: $query\n" if $debug;
my $sth->C4::Context->dbh->prepare($query);
$sth->execute($item_number, $self->{layout_id}, $self->{tmpl_id}, $self->{prof_id});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM labels_batches;");
$sth1->execute();
my $batch_id = $sth1->fetchrow_array;
$self->{batch_id} = $batch_id;
return $batch_id;
}
}
$self->{batch_stat} = 1;
}
=head2 C4::Labels::Template->retrieve(template_id)
Invoking the I<retrieve> method constructs a new template object containing the current values for template_id. The method returns
a new object upon success and 1 upon failure. Errors are logged to the Apache log. Two further options may be accessed. See the example
below for further description.
examples:
my $template = C4::Labels::Template->retrieve(template_id => 1); # Retrieves template record 1 and returns an object containing the record
my $template = C4::Labels::Template->retrieve(template_id => 1, convert => 1); # Retrieves template record 1, converts the units to points,
and returns an object containing the record
my $template = C4::Labels::Template->retrieve(template_id => 1, prof_id => prof_id); # Retrieves template record 1, converts the units
to points, applies the given profile id, and returns an object containing the record
=cut
sub retrieve {
my $invocant = shift;
my %opts = @_;
my $type = ref($invocant) || $invocant;
my $query = "SELECT * FROM labels_batches WHERE batch_id = ? ORDER BY label_id";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{batch_id});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
return 1;
}
my $self = {
items => [],
};
while (my $record = $sth->fetchrow_hashref) {
$self->{batch_id} = $record->{batch_id}; # FIXME: seems a bit wasteful to re-initialize these every trip: is there a better way?
$self->{layout_id} = $record->{layout_id};
$self->{tmpl_id} = $record->{tmpl_id};
$self->{prof_id} = $record->{prof_id};
push (@{$self->{items}}, $record->{item_number});
}
$self->{batch_stat} = 1;
bless ($self, $type);
return $self;
}
=head2 C4::Labels::Batch->delete(batch_id => batch_id) | $batch->delete()
Invoking the delete method attempts to delete the batch from the database. The method returns 0 upon success
and 1 upon failure. Errors are logged to the Apache log.
examples:
my $exitstat = $batch->delete(); # to delete the record behind the $batch object
my $exitstat = C4::Labels::Batch->delete(batch_id => 1); # to delete batch record 1
=cut
sub delete {
my $self = shift;
my %opts = @_;
if ((ref $self) && !$self->{'batch_id'}) { # If there is no batch batch_id then we cannot delete it from the db
warn 'Cannot delete batch: Batch has not been saved.';
return 1;
}
elsif (!$opts{batch_id}) {
warn 'Cannot delete batch: Missing batch_id.';
return 1;
}
my $query = "DELETE FROM labels_batches WHERE batch_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($self->{'batch_id'});
return 0;
}
1;
__END__
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=cut
#
# elsif ( $label_type eq 'PATCRD' ) {
# my $patron_data = $item;
#
# #FIXME: This needs to be paramatized and passed in from the user...
# #Each element of this hash is a separate line on the patron card. Keys are the text to print and the associated data is the point size.
# my $text = {
# $patron_data->{'description'} => $template->get_attr('font_size'),
# $patron_data->{'branchname'} => ($template->get_attr('font_size') + 3),
# };
#
# $debug and warn "Generating patron card for cardnumber $patron_data->{'cardnumber'}";
#
# my $barcode_height = $label_height / 2.75; #FIXME: Scaling barcode height; this needs to be a user parameter.
# $label->barcode( $llx, $lly, $barcode_height, $label_width, $patron_data->{'cardnumber'},
# $barcodetype );
# DrawPatronCardText( $llx, $lly, $label_height, $label_width, $template->get_attr('font'), $template->get_attr('font_size'),
# $left_text_margin, $text_wrap_cols, $text, $label_type );
# _calc_next_label_pos();
# }

View file

@ -1,25 +1,21 @@
-- Label Templates
LOCK TABLES `labels_templates` WRITE;
INSERT INTO `labels_templates`
(tmpl_id,tmpl_code,tmpl_desc,page_width,page_height,label_width,label_height,topmargin,leftmargin,cols,`rows`,colgap,rowgap,
active,units,fontsize,font)
VALUES
(1,'Avery 5160 | 1 x 2-5/8','3 columns, 10 rows of labels',8.5,11,2.625,1,0.5,0.1875,3,10,0.125,0,1,'INCH',7,'TR'),
(2,'Gaylord 8511 Spine Label','Prints only the left-hand column of a Gaylord 8511.',8.5,11,1,1.25,0.6,0.5,1,8,0,0,NULL,'INCH',10,'TR'),
(3,'Avery 5460 vertical','',3.625,5.625,1.5,0.75,0.38,0.35,2,7,0.25,0,NULL,'INCH',8,'TR'),
(4,'Avery 5460 spine labels','',5.625,3.625,0.75,1.5,0.35,0.31,7,2,0,0.25,NULL,'INCH',8,'TR'),
(5,'Avery 8163','2rows x 5 rows',8.5,11,4,2,0.5,0.17,2,5,0.2,0.01,NULL,'INCH',11,'TR'),
(6,'cards','Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000',8.5,11,2.75,1.05,0.25,0,3,10,0.2,0.01,NULL,'INCH',8,'TR'),
(7,'HB-PC0001','A template for home brewed patron card forms',8.5,11,3.125,1.875,0.375,0.5625,2,5,1.125,0.1875,NULL,'INCH',16,'TR');
UNLOCK TABLES;
LOCK TABLES `labels_conf` WRITE;
/*!40000 ALTER TABLE `labels_conf` DISABLE KEYS */;
INSERT INTO `labels_conf`
(id,barcodetype,title,subtitle,itemtype,barcode,dewey,classification,subclass,itemcallnumber,author,issn,isbn,startlabel,
printingtype,formatstring,layoutname,guidebox,active,fonttype,ccode,callnum_split)
VALUES
(5,'CODE39',2,0,3,0,0,0,0,4,1,0,0,1,'BIBBAR','biblio and barcode',1,1,NULL,NULL,NULL,NULL),
(6,'CODE39',2,0,0,0,0,3,4,0,1,0,3,1,'BAR','alternating',1,1,NULL,NULL,NULL,NULL),
(7,'CODE39',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,2,NULL,NULL,1,'PATCRD','Patron ID Cards',1,NULL,NULL,NULL,NULL,NULL);
/*!40000 ALTER TABLE `labels_conf` ENABLE KEYS */;
/*!40000 ALTER TABLE `labels_templates` DISABLE KEYS */;
INSERT INTO `labels_templates` VALUES
(1,0,'Avery 5160 | 1 x 2-5/8', '3 columns, 10 rows of labels', 8.5, 11, 2.63, 1, 0.139, 0, 0.35, 0.23, 3, 10, 0.13, 0, 'INCH'),
(2,0,'Gaylord 8511 Spine Label','Prints only the left-hand column of a Gaylord 8511.', 8.5, 11, 1, 1.25, 0.6, 0.5, 0, 0, 1, 8, 0, 0, 'INCH'),
(3,0,'Avery 5460 vertical', '', 3.625, 5.625, 1.5, 0.75, 0.38, 0.35, 2, 7, 2, 1, 0.25, 0, 'INCH'),
(4,0,'Avery 5460 spine labels', '', 5.625, 3.625, 0.75, 1.5, 0.35, 0.31, 7, 2, 1, 0, 0.25, 0, 'INCH'),
(5,0,'Avery 8163', '2rows x 5 rows', 8.5, 11, 4, 2, 0, 0, 0.5, 0.17, 2, 5, 0.2, 0.01, 'INCH'),
(6,0,'cards', 'Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000', 8.5, 11, 2.75, 1.05, 0, 0, 0.25, 0, 3, 10, 0.2, 0.01, 'INCH'),
(7,0,'Demco WS14942260', '1\" X 1.5\" Spine Label', 8.5, 11, 1.5, 1, 0.236, 0, 0.4, 0.25, 5, 10, 0.0625, 0, 'INCH');
/*!40000 ALTER TABLE `labels_templates` ENABLE KEYS */;
UNLOCK TABLES;
LOCK TABLES `labels_layouts` WRITE;
/*!40000 ALTER TABLE `labels_layouts` DISABLE KEYS */;
INSERT INTO `labels_layouts` VALUES
(1,'CODE39','BIBBAR', 'biblio and barcode', 0, 'TR',7,0,'L','title, author, itemcallnumber'),
(2,'CODE39','BIB', 'spine', 0, 'TR',3,1,'L','itemcallnumber'),
(3,'CODE39','BARBIB', 'barcode and biblio', 0, 'TR',3,1,'L','title, author, itemcallnumber');
/*!40000 ALTER TABLE `labels_layouts` ENABLE KEYS */;
UNLOCK TABLES;

View file

@ -5,4 +5,5 @@ Gaylord 8511 Spine Label
Avery 5460 - vertical
Avery 5460 - spine labels
Avery 8163 - 2rows x 5 rows
cards Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000
cards Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8" [3x10] : equivalent: Gaylord JD-ML3000
Demco WS14942260 | 1" X 1.5" Spine Label

View file

@ -1,24 +1,20 @@
-- Label Templates
set NAMES 'utf8';
LOCK TABLES `labels_templates` WRITE;
INSERT INTO `labels_templates`
(tmpl_id,tmpl_code,tmpl_desc,page_width,page_height,label_width,label_height,topmargin,leftmargin,cols,`rows`,colgap,rowgap,
active,units,fontsize,font)
VALUES
(1,'Avery 5160 | 1 x 2-5/8','3 colonnes, 10 lignes d''étiquette',8.5,11,2.625,1,0.5,0.1875,3,10,0.125,0,1,'INCH',7,'TR'),
(2,'Gaylord 8511 Spine Label','Imprime uniquement dans la colnne de gauche d''une planche Gaylord 8511.',8.5,11,1,1.25,0.6,0.5,1,8,0,0,NULL,'INCH',10,'TR'),
(3,'Avery 5460 vertical','',3.625,5.625,1.5,0.75,0.38,0.35,2,7,0.25,0,NULL,'INCH',8,'TR'),
(4,'Avery 5460 Etiquettes de cote','',5.625,3.625,0.75,1.5,0.35,0.31,7,2,0,0.25,NULL,'INCH',8,'TR'),
(5,'Avery 8163','2colonnes x 5 colonnes',8.5,11,4,2,0.5,0.17,2,5,0.2,0.01,NULL,'INCH',11,'TR'),
(6,'cards','Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000',8.5,11,2.75,1.05,0.25,0,3,10,0.2,0.01,NULL,'INCH',8,'TR');
INSERT INTO `labels_templates` VALUES
(1,0,'Avery 5160 | 1 x 2-5/8', '3 colonnes, 10 lignes d''étiquette', 8.5, 11, 2.63, 1, 0.139, 0, 0.35, 0.23, 3, 10, 0.13, 0, 'INCH'),
(2,0,'Gaylord 8511 Spine Label','Imprime uniquement dans la colnne de gauche d''une planche Gaylord 8511.', 8.5, 11, 1, 1.25, 0.6, 0.5, 0, 0, 1, 8, 0, 0, 'INCH'),
(3,0,'Avery 5460 vertical', '', 3.625, 5.625, 1.5, 0.75, 0.38, 0.35, 2, 7, 2, 1, 0.25, 0, 'INCH'),
(4,0,'Avery 5460 spine labels', '', 5.625, 3.625, 0.75, 1.5, 0.35, 0.31, 7, 2, 1, 0, 0.25, 0, 'INCH'),
(5,0,'Avery 8163', '2colonnes x 5 colonnes', 8.5, 11, 4, 2, 0, 0, 0.5, 0.17, 2, 5, 0.2, 0.01, 'INCH'),
(6,0,'cards', 'Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000', 8.5, 11, 2.75, 1.05, 0, 0, 0.25, 0, 3, 10, 0.2, 0.01, 'INCH'),
(7,0,'Demco WS14942260', '1\" X 1.5\" Etiquettes de cotes', 8.5, 11, 1.5, 1, 0.236, 0, 0.4, 0.25, 5, 10, 0.0625, 0, 'INCH');
UNLOCK TABLES;
LOCK TABLES `labels_conf` WRITE;
/*!40000 ALTER TABLE `labels_conf` DISABLE KEYS */;
INSERT INTO `labels_conf`
(id,barcodetype,title,subtitle,itemtype,barcode,dewey,classification,subclass,itemcallnumber,author,issn,isbn,startlabel,
printingtype,formatstring,layoutname,guidebox,active,fonttype,ccode,callnum_split)
VALUES
(5,'CODE39',2,0,3,0,0,0,0,4,1,0,0,1,'BIBBAR','biblio and barcode',1,1,NULL,NULL,NULL,NULL),
(6,'CODE39',2,0,0,0,0,3,4,0,1,0,3,1,'BAR','alternating',1,1,NULL,NULL,NULL,NULL);
/*!40000 ALTER TABLE `labels_conf` ENABLE KEYS */;
LOCK TABLES `labels_layouts` WRITE;
/*!40000 ALTER TABLE `labels_layouts` DISABLE KEYS */;
INSERT INTO `labels_layouts` VALUES
(1,'CODE39','BIBBAR','biblio and barcode',0,'TR',7,0,'L','title, author, itemcallnumber'),
(2,'CODE39','BIB','spine',0,'TR',3,1,'L','itemcallnumber'),
(3,'CODE39','BARBIB','barcode and biblio',0,'TR',3,1,'L','title, author, itemcallnumber');
/*!40000 ALTER TABLE `labels_layouts` ENABLE KEYS */;
UNLOCK TABLES;

View file

@ -4,4 +4,5 @@ Gaylord 8511 Spine Label
Avery 5460 - vertical
Avery 5460 - spine labels
Avery 8163 - 2rows x 5 rows
cards Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000
cards Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8" [3x10] : equivalent: Gaylord JD-ML3000
Demco WS14942260 | 1" X 1.5" Etiquettes de cotes

View file

@ -1228,60 +1228,40 @@ CREATE TABLE `itemtypes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `labels`
-- Table structure for table `labels_batches`
--
DROP TABLE IF EXISTS `labels`;
CREATE TABLE `labels` (
`labelid` int(11) NOT NULL auto_increment,
`batch_id` int(10) NOT NULL default 1,
`itemnumber` varchar(100) NOT NULL default '',
DROP TABLE IF EXISTS `labels_batches`;
CREATE TABLE `labels_batches` (
`label_id` int(11) NOT NULL auto_increment,
`batch_id` int(10) NOT NULL default '1',
`item_number` int(11) NOT NULL default '0',
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`labelid`)
`branch_code` varchar(10) NOT NULL default 'NB',
PRIMARY KEY USING BTREE (`label_id`),
KEY `branch_fk` (`branch_code`),
KEY `item_fk` (`item_number`),
CONSTRAINT `item_fk_constraint` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE,
CONSTRAINT `branch_fk_constraint` FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `labels_conf`
-- Table structure for table `labels_layouts`
--
DROP TABLE IF EXISTS `labels_conf`;
CREATE TABLE `labels_conf` (
`id` int(4) NOT NULL auto_increment,
`barcodetype` char(100) default '',
`title` int(1) default '0',
`subtitle` int(1) default '0',
`itemtype` int(1) default '0',
`barcode` int(1) default '0',
`dewey` int(1) default '0',
`classification` int(1) default NULL,
`subclass` int(1) default '0',
`itemcallnumber` int(1) default '0',
`author` int(1) default '0',
`issn` int(1) default '0',
`isbn` int(1) default '0',
`startlabel` int(2) NOT NULL default '1',
`printingtype` char(32) default 'BAR',
`formatstring` mediumtext default NULL,
`layoutname` char(20) NOT NULL default 'TEST',
DROP TABLE IF EXISTS `labels_layouts`;
CREATE TABLE `labels_layouts` (
`layout_id` int(4) NOT NULL auto_increment,
`barcode_type` char(100) NOT NULL default 'CODE39',
`printing_type` char(32) NOT NULL default 'BAR',
`layout_name` char(20) NOT NULL default 'DEFAULT',
`guidebox` int(1) default '0',
`active` tinyint(1) default '1',
`fonttype` char(10) collate utf8_unicode_ci default NULL,
`ccode` char(4) collate utf8_unicode_ci default NULL,
`callnum_split` int(1) default NULL,
`text_justify` char(1) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `labels_profile`
--
DROP TABLE IF EXISTS `labels_profile`;
CREATE TABLE `labels_profile` (
`tmpl_id` int(4) NOT NULL,
`prof_id` int(4) NOT NULL,
UNIQUE KEY `tmpl_id` (`tmpl_id`),
UNIQUE KEY `prof_id` (`prof_id`)
`font` char(10) character set utf8 collate utf8_unicode_ci NOT NULL default 'TR',
`font_size` int(4) NOT NULL default '10',
`callnum_split` int(1) default '0',
`text_justify` char(1) character set utf8 collate utf8_unicode_ci NOT NULL default 'L',
`format_string` varchar(210) NOT NULL default 'barcode',
PRIMARY KEY USING BTREE (`layout_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@ -1290,24 +1270,25 @@ CREATE TABLE `labels_profile` (
DROP TABLE IF EXISTS `labels_templates`;
CREATE TABLE `labels_templates` (
`tmpl_id` int(4) NOT NULL auto_increment,
`tmpl_code` char(100) default '',
`tmpl_desc` char(100) default '',
`page_width` float default '0',
`page_height` float default '0',
`label_width` float default '0',
`label_height` float default '0',
`topmargin` float default '0',
`leftmargin` float default '0',
`cols` int(2) default '0',
`rows` int(2) default '0',
`colgap` float default '0',
`rowgap` float default '0',
`active` int(1) default NULL,
`units` char(20) default 'PX',
`fontsize` int(4) NOT NULL default '3',
`font` char(10) NOT NULL default 'TR',
PRIMARY KEY (`tmpl_id`)
`template_id` int(4) NOT NULL auto_increment,
`profile_id` int(4) default NULL,
`template_code` char(100) NOT NULL default 'DEFAULT TEMPLATE',
`template_desc` char(100) NOT NULL default 'Default description',
`page_width` float NOT NULL default '0',
`page_height` float NOT NULL default '0',
`label_width` float NOT NULL default '0',
`label_height` float NOT NULL default '0',
`top_text_margin` float NOT NULL default '0',
`left_text_margin` float NOT NULL default '0',
`top_margin` float NOT NULL default '0',
`left_margin` float NOT NULL default '0',
`cols` int(2) NOT NULL default '0',
`rows` int(2) NOT NULL default '0',
`col_gap` float NOT NULL default '0',
`row_gap` float NOT NULL default '0',
`units` char(20) NOT NULL default 'POINT',
PRIMARY KEY (`template_id`),
KEY `template_profile_fk_constraint` (`profile_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@ -1630,18 +1611,17 @@ CREATE TABLE `printers` (
DROP TABLE IF EXISTS `printers_profile`;
CREATE TABLE `printers_profile` (
`prof_id` int(4) NOT NULL auto_increment,
`printername` varchar(40) NOT NULL,
`tmpl_id` int(4) NOT NULL,
`paper_bin` varchar(20) NOT NULL,
`offset_horz` float default NULL,
`offset_vert` float default NULL,
`creep_horz` float default NULL,
`creep_vert` float default NULL,
`unit` char(20) NOT NULL default 'POINT',
PRIMARY KEY (`prof_id`),
UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
`profile_id` int(4) NOT NULL auto_increment,
`printer_name` varchar(40) NOT NULL default 'Default Printer',
`template_id` int(4) NOT NULL default '0',
`paper_bin` varchar(20) NOT NULL default 'Bypass',
`offset_horz` float NOT NULL default '0',
`offset_vert` float NOT NULL default '0',
`creep_horz` float NOT NULL default '0',
`creep_vert` float NOT NULL default '0',
`units` char(20) NOT NULL default 'POINT',
PRIMARY KEY (`profile_id`),
UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--

View file

@ -0,0 +1,184 @@
#!/usr/bin/perl
#
# 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
# 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
use C4::Context;
my $sth = C4::Context->dbh;
# NOTE: As long as we die on error *before* the DROP TABLE instructions are executed, the script may simply be rerun after addressing whatever errors occur; If we get past the data conversion without error, the DROPs and ALTERs could be executed manually if need be.
# Turn off key checks for duration of script...
$sth->do("
SET UNIQUE_CHECKS = 0;
") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("
SET FOREIGN_KEY_CHECKS = 0;
") or die "DB ERROR: " . $sth->errstr . "\n";
# Create new tables with temporary names...
$sth->do("
DROP TABLE IF EXISTS labels_batches_tmp;");
$sth->do("
CREATE TABLE `labels_batches_tmp` (
`label_id` int(11) NOT NULL auto_increment,
`batch_id` int(10) NOT NULL default '1',
`item_number` int(11) NOT NULL default '0',
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`branch_code` varchar(10) NOT NULL default 'NB',
PRIMARY KEY USING BTREE (`label_id`),
KEY `branch_fk_constraint` (`branch_code`),
KEY `item_fk_constraint` (`item_number`),
FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("
DROP TABLE IF EXISTS labels_layouts_tmp;");
$sth->do("
CREATE TABLE `labels_layouts_tmp` (
`layout_id` int(4) NOT NULL auto_increment,
`barcode_type` char(100) NOT NULL default 'CODE39',
`printing_type` char(32) NOT NULL default 'BAR',
`layout_name` char(20) NOT NULL default 'DEFAULT',
`guidebox` int(1) default '0',
`font` char(10) character set utf8 collate utf8_unicode_ci NOT NULL default 'TR',
`font_size` int(4) NOT NULL default '10',
`callnum_split` int(1) default '0',
`text_justify` char(1) character set utf8 collate utf8_unicode_ci NOT NULL default 'L',
`format_string` varchar(210) NOT NULL default 'barcode',
PRIMARY KEY USING BTREE (`layout_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("
DROP TABLE IF EXISTS labels_templates_tmp;");
$sth->do("
CREATE TABLE `labels_templates_tmp` (
`template_id` int(4) NOT NULL auto_increment,
`profile_id` int(4) default NULL,
`template_code` char(100) NOT NULL default 'DEFAULT TEMPLATE',
`template_desc` char(100) NOT NULL default 'Default description',
`page_width` float NOT NULL default '0',
`page_height` float NOT NULL default '0',
`label_width` float NOT NULL default '0',
`label_height` float NOT NULL default '0',
`top_text_margin` float NOT NULL default '0',
`left_text_margin` float NOT NULL default '0',
`top_margin` float NOT NULL default '0',
`left_margin` float NOT NULL default '0',
`cols` int(2) NOT NULL default '0',
`rows` int(2) NOT NULL default '0',
`col_gap` float NOT NULL default '0',
`row_gap` float NOT NULL default '0',
`units` char(20) NOT NULL default 'POINT',
PRIMARY KEY (`template_id`),
KEY `template_profile_fk_constraint` (`profile_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("
DROP TABLE IF EXISTS printers_profile_tmp;");
$sth->do("
CREATE TABLE `printers_profile_tmp` (
`profile_id` int(4) NOT NULL auto_increment,
`printer_name` varchar(40) NOT NULL default 'Default Printer',
`template_id` int(4) NOT NULL default '0',
`paper_bin` varchar(20) NOT NULL default 'Bypass',
`offset_horz` float NOT NULL default '0',
`offset_vert` float NOT NULL default '0',
`creep_horz` float NOT NULL default '0',
`creep_vert` float NOT NULL default '0',
`units` char(20) NOT NULL default 'POINT',
PRIMARY KEY (`profile_id`),
UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
") or die "DB ERROR: " . $sth->errstr . "\n";
# Migrate data from existing tables to new tables...
$sth->do("INSERT INTO `labels_batches_tmp` (label_id, batch_id, item_number) SELECT labelid, batch_id, itemnumber FROM labels;") or die "DB ERROR: " . $sth->errstr . "\n";
# Since the new label creator keys batches on branch code we must add a branch code during the conversion; the simplest solution appears to be to grab the top branch code from the branches table...
$sth->do("UPDATE `labels_batches_tmp` SET branch_code=(SELECT branchcode FROM branches LIMIT 0,1);") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("INSERT INTO `labels_layouts_tmp` (layout_id, barcode_type, printing_type, layout_name, guidebox, callnum_split, text_justify, format_string) SELECT lc.id, lc.barcodetype, lc.printingtype, lc.layoutname, lc.guidebox, lc.callnum_split, lc.text_justify, lc.formatstring FROM labels_conf AS lc;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("INSERT INTO `labels_templates_tmp` (template_id, template_code, template_desc, page_width, page_height, label_width, label_height, top_margin, left_margin, cols, rows, col_gap, row_gap, units) SELECT lt.tmpl_id, lt.tmpl_code, lt.tmpl_desc, lt.page_width, lt.page_height, lt.label_width, lt.label_height, lt.topmargin, lt.leftmargin, lt.cols, lt.rows, lt.colgap, lt.rowgap, lt.units FROM labels_templates AS lt;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("INSERT INTO `printers_profile_tmp` (profile_id, printer_name, template_id, paper_bin, offset_horz, offset_vert, creep_horz, creep_vert, units) SELECT prof_id, printername, tmpl_id, paper_bin, offset_horz, offset_vert, creep_horz, creep_vert, unit FROM printers_profile;") or die "DB ERROR: " . $sth->errstr . "\n";
my $sth1 = C4::Context->dbh->prepare("SELECT layout_id, format_string FROM labels_layouts_tmp;");
#$sth1->{'TraceLevel'} = 3;
$sth1->execute or die "DB ERROR: " . $sth1->errstr . "\n";
while (my $layout = $sth1->fetchrow_hashref()) {
if (!$layout->{'format_string'}) {
my $sth2 = C4::Context->dbh->prepare("SELECT id, title, subtitle, itemtype, barcode, dewey, classification, subclass, itemcallnumber, author, issn, isbn, ccode FROM labels_conf WHERE id = " . $layout->{'layout_id'});
$sth2->execute or die "DB ERROR: " . $sth2->errstr . "\n";
my $record = $sth2->fetchrow_hashref();
my @label_fields = ();
RECORD:
foreach (keys(%$record)) {
next RECORD if $record->{$_} eq '' or $_ eq 'id';
$label_fields[$record->{$_}] = $_;
}
shift @label_fields;
my $format_string = join (",", @label_fields);
# my $format_string = s/^,//i;
$sth->do("UPDATE `labels_layouts_tmp` SET format_string=\'$format_string\' WHERE layout_id = " . $record->{'id'}) or die "DB ERROR: " . $sth->errstr . "\n";
}
}
my $sth3 = C4::Context->dbh->prepare("SELECT template_id FROM labels_templates_tmp;");
$sth3->execute or die "DB ERROR: " . $sth3->errstr . "\n";
RECORD:
while (my $template = $sth3->fetchrow_hashref()) {
my $sth4 = C4::Context->dbh->prepare("SELECT profile_id FROM printers_profile_tmp WHERE template_id = " . $template->{'template_id'});
$sth4->execute or die "DB ERROR: " . $sth4->errstr . "\n";
my $profile_id = $sth4->fetchrow_hashref();
next RECORD if $profile_id->{'profile_id'} eq '';
$sth->do("UPDATE `labels_templates_tmp` SET profile_id=\'" . $profile_id->{'profile_id'} . "\' WHERE template_id = " . $template->{'template_id'}) or die "DB ERROR: " . $sth->errstr . "\n";
}
# Drop old tables....
$sth->do("DROP TABLE IF EXISTS labels;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("DROP TABLE IF EXISTS labels_conf;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("DROP TABLE IF EXISTS labels_profile;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("DROP TABLE IF EXISTS labels_templates;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("DROP TABLE IF EXISTS printers_profile;") or die "DB ERROR: " . $sth->errstr . "\n";
# Rename temporary tables to permenant names...
$sth->do("ALTER TABLE labels_batches_tmp RENAME TO labels_batches;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("ALTER TABLE labels_layouts_tmp RENAME TO labels_layouts;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("ALTER TABLE labels_templates_tmp RENAME TO labels_templates;") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("ALTER TABLE printers_profile_tmp RENAME TO printers_profile;") or die "DB ERROR: " . $sth->errstr . "\n";
# Re-enable key checks...
$sth->do("
SET UNIQUE_CHECKS = 1;
") or die "DB ERROR: " . $sth->errstr . "\n";
$sth->do("
SET FOREIGN_KEY_CHECKS = 1;
") or die "DB ERROR: " . $sth->errstr . "\n";

View file

@ -2596,6 +2596,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
print "Upgrade to $DBversion done (bug 3481: add permanent_location column to deleteditems)\n";
}
$DBversion = '3.01.00.053';
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/labels_upgrade.pl";
system("perl $upgrade_script");
print "Upgrade to $DBversion done (Migrated labels tables and data to new schema.) NOTE: All existing label batches have been assigned to the first branch in the list of branches. This is ONLY true of migrated label batches.\n";
SetVersion ($DBversion);
}
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table

View file

@ -0,0 +1,37 @@
div.homeimage {
background-attachment: scroll;
background-color: transparent;
background-image: url(../../img/label-creator-image.png);
background-position: top right;
background-repeat: no-repeat;
min-width: 800px;
}
div.lci_01 {
float: right;
clear: right;
height: 90px;
width: 280px;
margin: 2px;
padding: 2px;
}
div.lci_02 {
float: right;
clear: right;
height: 165px;
width: 582px;
margin: 2px;
padding: 2px;
}
div.lci_03 {
float: right;
clear: right;
height: 55px;
width: 305px;
margin: 2px;
padding: 2px;
}

View file

@ -5,10 +5,14 @@ a, a:link, a:visited, a:active {
color : #0000CC;
}
.yui-button a,.yui-button a:link,.yui-button a:visited {
.yui-button,.yui-button a:link,.yui-button a:visited {
color : #000;
}
a.yuimenuitemlabel {
color: #000000;
}
a:hover {
color : #669ACC;
}
@ -227,6 +231,15 @@ table {
border-right : 1px solid #BCBCBC;
}
table.borderless {
border-collapse : separate;
border: 0 none;
}
#label-search-results {
width: 700px;
}
td, th {
border-bottom : 1px solid #BCBCBC;
border-left : 1px solid #BCBCBC;
@ -237,6 +250,11 @@ td {
background-color : White;
}
td.borderless {
border-collapse : separate;
border : 0 none;
}
th {
background-color : #E8E8E8;
font-weight : bold;
@ -323,6 +341,9 @@ legend {
display : inline;
}
div.justify {
text-align: justify;
}
div#header_search {
background-position : .5em .5em;
@ -474,7 +495,7 @@ fieldset.brief ol, fieldset.brief li {
list-style-type : none;
}
fieldset.brief div.hint, fieldset.rows div.hint {
fieldset.brief div.hint, fieldset.rows div.hint, div.yui-u div.hint {
color : #999999;
font-size : 95%;
margin-bottom : .4em;
@ -534,7 +555,7 @@ fieldset.rows fieldset {
}
.yui-u fieldset.rows label, .yui-u fieldset.rows span.label {
width: 6em;
width: 10em;
}
.yui-u fieldset.rows div.hint {
@ -777,7 +798,7 @@ fieldset.rows .inputnote {
visibility:visible; /* you propably don't need to change this one */
display:block;
}
#newbiblio a, #addchild a, #newentry a, #newshelf a, #newmenuc .first-child, #newsupplier .first-child, #newlabel a, #newtemplate a, #newlabelbatch a, #newpatroncardbatch a, #newprofile a, #newsubscription a, #newdictionary a, #neworder a {
#newbiblio a, #addchild a, #newentry a, #newshelf a, #newmenuc .first-child, #newsupplier .first-child, #newlabel a, #newtemplate a, #newbatch a, #newprofile a, #newsubscription a, #newdictionary a, #neworder a {
padding-left : 34px;
background-image: url("../../img/toolbar-new.gif");
background-position : center left;
@ -806,7 +827,7 @@ fieldset.rows .inputnote {
background-repeat : no-repeat;
}
#editpatron a, #editmenuc .first-child, #editshelf a, #edit a, #editsupplier a {
#editpatron a, #editmenuc .first-child, #editshelf a, #edit a, #editsupplier a, #managelabel a, #managetemplate a, #managelabelbatch a, #manageprofile a {
padding-left : 34px;
background-image: url("../../img/toolbar-edit.gif");
background-position : center left;
@ -1103,6 +1124,11 @@ div.alert strong {
color : #900;
}
div.dialog {
background : #FFC url(../../img/dialog-bg.gif) repeat-x left 0;
text-align : center;
}
div.message {
background : white url("../../img/message-bg.gif") repeat-x left 0;
border : 1px solid #bcbcbc;
@ -1694,3 +1720,72 @@ span.permissiondesc {
color: black;
}
.hintsClass {
font-family: tahoma, verdana, arial;
font-size: 12px;
background-color: #f0f0f0;
color: #000000;
border: 1px solid #808080;
padding: 5px;
}
.hintSource {
color: green;
text-decoration: underline;
cursor: pointer;
}
h1#pdf {
background:transparent url(../../img/pdficon_large.gif) no-repeat scroll 0%;
border: 0;
margin:0.75em .3em 0.75em .7em;
padding:0;
}
h1#pdf a {
border:0;
cursor:pointer;
display:block;
height:0px !important;
margin:0;
overflow:hidden;
padding:44px 0 0;
text-decoration:none;
width:35px;
}
h1#csv {
background:transparent url(../../img/csv_icon.gif) no-repeat scroll 0%;
border: 0;
margin:0.75em .3em 0.75em .7em;
padding:0;
}
h1#csv a {
border:0;
cursor:pointer;
display:block;
height:0px !important;
margin:0;
overflow:hidden;
padding:44px 0 0;
text-decoration:none;
width:35px;
}
h1#xml {
background:transparent url(../../img/icon_xml.gif) no-repeat scroll 0%;
border: 0;
margin:0.75em .3em 0.75em .7em;
padding:0;
}
h1#xml a {
border:0;
cursor:pointer;
display:block;
height:0px !important;
margin:0;
overflow:hidden;
padding:44px 0 0;
text-decoration:none;
width:35px;

View file

@ -1,38 +1,66 @@
<div id="header" class="clearfix">
<div id="toplevelnav">
<ul id="toplevelmenu">
<!-- TMPL_IF NAME="CAN_user_circulate" --><li><a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a></li><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_borrowers" --><li><a href="/cgi-bin/koha/members/members-home.pl">Patrons</a></li><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_catalogue" --><li><a href="/cgi-bin/koha/catalogue/search.pl">Search</a></li><!-- /TMPL_IF -->
<!-- TMPL_VAR name="IntranetNav" -->
<li class="more"><a id="showmore" href="/cgi-bin/koha/mainpage.pl">More</a><div id="moremenu"><div class="bd"><ul>
<li><a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a></li>
<!-- TMPL_IF NAME="CAN_user_editcatalogue" --><li><a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a></li>
<!-- TMPL_IF NAME="CAN_user_acquisition" -->
<li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a></li>
<!-- /TMPL_IF -->
<li><a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a></li>
<!-- TMPL_IF NAME="CAN_user_serials" -->
<li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li><!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_reports" --><li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_tools" --><li><a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a></li><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_parameters" --><li><a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a></li><!-- /TMPL_IF -->
<li><a href="/cgi-bin/koha/about.pl">About Koha</a></li></ul></div></div></li>
</ul>
</div>
<div id="login">
<!-- TMPL_IF NAME="AutoLocation" --><strong><!-- TMPL_VAR NAME="LoginBranchname" --></strong>
<!-- TMPL_ELSE -->
<strong><!-- TMPL_VAR NAME="LoginBranchname" --></strong>
<!-- TMPL_IF NAME="IndependantBranches" -->
<!-- TMPL_IF NAME="CAN_user_management" --> (<a href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set</a>)<!-- /TMPL_IF -->
<!-- TMPL_ELSE -->
(<a href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set</a>)
<!-- /TMPL_IF -->
| <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="loggedinusername" --><span class="loggedinusername"><!-- TMPL_VAR NAME="loggedinusername" --></span> (<a href="/cgi-bin/koha/mainpage.pl?logout.x=1">Log Out</a>) |
<!-- TMPL_ELSE -->You are not logged in |
<!-- /TMPL_IF -->
<a href="/cgi-bin/koha/help.pl" id="helper" onclick="window.open('/cgi-bin/koha/help.pl','Koha_Help','width=600,height=600,toolbar=false,scrollbars=yes'); return false;">[ ? ]</a></div></div>
<div id="header" class="clearfix">
<div id="toplevelnav">
<ul id="toplevelmenu">
<!-- TMPL_IF NAME="CAN_user_circulate" --><li><a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a></li><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_borrowers" --><li><a href="/cgi-bin/koha/members/members-home.pl">Patrons</a></li><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_catalogue" --><li><a href="/cgi-bin/koha/catalogue/search.pl">Search</a></li><!-- /TMPL_IF -->
<!-- TMPL_VAR name="IntranetNav" -->
<li class="more">
<a id="showmore" href="/cgi-bin/koha/mainpage.pl">More</a>
<div id="moremenu">
<div class="bd">
<ul>
<li><a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a></li>
<!-- TMPL_IF NAME="CAN_user_editcatalogue" -->
<li><a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a></li>
<!-- TMPL_IF NAME="CAN_user_acquisition" -->
<li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a></li>
<!-- /TMPL_IF -->
<li><a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a></li>
<!-- TMPL_IF NAME="CAN_user_serials" -->
<li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_reports" -->
<li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_tools" -->
<li><a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a></li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_parameters" -->
<li><a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a></li>
<!-- /TMPL_IF -->
<li><a href="/cgi-bin/koha/about.pl">About Koha</a></li>
</ul>
</div>
</div>
</li>
</ul>
</div>
<div id="login">
<!-- TMPL_IF NAME="AutoLocation" -->
<strong>
<!-- TMPL_VAR NAME="LoginBranchname" -->
</strong>
<!-- TMPL_ELSE -->
<strong><!-- TMPL_VAR NAME="LoginBranchname" --></strong>
<!-- TMPL_IF NAME="IndependantBranches" -->
<!-- TMPL_IF NAME="CAN_user_management" -->
(<a href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set</a>)
<!-- /TMPL_IF -->
<!-- TMPL_ELSE -->
(<a href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set</a>)
<!-- /TMPL_IF -->
|
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="loggedinusername" -->
<span class="loggedinusername">
<!-- TMPL_VAR NAME="loggedinusername" -->
</span>
(<a href="/cgi-bin/koha/mainpage.pl?logout.x=1">Log Out</a>) |
<!-- TMPL_ELSE -->
You are not logged in |
<!-- /TMPL_IF -->
<a href="/cgi-bin/koha/help.pl" id="helper" onclick="window.open('/cgi-bin/koha/help.pl','Koha_Help','width=600,height=600,toolbar=false,scrollbars=yes'); return false;">[ ? ]</a>
</div>
</div>

View file

@ -0,0 +1,179 @@
<div id="toolbar">
<script type="text/JavaScript">
//<![CDATA[
function DeleteConfirm() {
var msg = "Are you sure you want to delete batch <!-- TMPL_VAR NAME="batch_id" -->?"
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=<!-- TMPL_VAR NAME="batch_id" -->";
}
else {
return; // abort delete
}
};
function Remove() {
items = new Array;
item_num = new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
items.push("label_id=" + document.items.action[i].value);
item_num.push(i+1);
}
}
if (items.length < 1) {
alert("Please select at least one item to delete.");
return; // no item selected
}
getstr = items.join("&");
item_msg = item_num.join(", ");
var msg = "Are you sure you want to remove label number(s): " + item_msg + " from this batch?"
}
// else if (document.items.action.checked) {
// getstr = "label_id="+document.items.action.value;
// var msg = "Are you sure you want to remove selected item from this batch?"
// }
else {
alert("Please select at least label to delete.");
return; // no item selected
}
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;" + getstr;
}
else {
return; // abort delete
}
};
function Add() {
window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
};
function DeDuplicate() {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->";
};
function Xport(mode) {
if (mode == 'label') {
labels= new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
labels.push("label_id=" + document.items.action[i].value);
}
}
if (labels.length < 1) {
alert("Please select at least one label to export.");
return; // no batch selected
}
getstr = labels.join("&");
}
else if (document.items.action.checked) {
getstr = document.items.action.value;
}
else {
alert("Please select at least one label to export.");
return; // no batch selected
}
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&" + getstr, 700, 800);
}
else if (mode == 'batch') {
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->", 700, 800);
}
else {
// some pass-thru error trapping just in case...
}
};
function selected_layout() {
if (document.items.action.length) {
for (i=0;i<document.items.action.length;i++){
if (document.items.action[i].checked==true){
return(document.items.action[i].value);
}
};
}
else {
if (document.items.action.checked){
return(document.items.action.value);
}
};
alert("Please select at least one item.");
return (-1);
};
// prepare DOM for YUI Toolbar
$(document).ready(function() {
$("#additemsc").empty();
$("#removeitemsc").empty();
$("#deletebatchc").empty();
$("#deduplicatec").empty();
$("#exportitemsc").empty();
$("#exportbatchc").empty();
yuiToolbar();
});
// YUI Toolbar Functions
function yuiToolbar() {
new YAHOO.widget.Button({
id: "additems",
type: "link",
href: "#",
label: _("Add Item(s)"),
container: "additemsc",
onclick: {fn:function(){Add()}}
});
new YAHOO.widget.Button({
id: "removeitems",
type: "link",
href: "#",
label: _("Remove Item(s)"),
container: "removeitemsc",
onclick: {fn:function(){Remove()}}
});
new YAHOO.widget.Button({
id: "deletebatch",
type: "link",
href: "#",
label: _("Delete Batch"),
container: "deletebatchc",
onclick: {fn:function(){DeleteConfirm()}}
});
new YAHOO.widget.Button({
id: "deduplicate",
type: "link",
href: "#",
label: _("Remove Duplicates"),
container: "deduplicatec",
onclick: {fn:function(){DeDuplicate()}}
});
new YAHOO.widget.Button({
id: "exportitems",
type: "link",
href: "#",
label: _("Export Item(s)"),
container: "exportitemsc",
onclick: {fn:function(){Xport('label')}}
});
new YAHOO.widget.Button({
id: "exportbatch",
type: "link",
href: "#",
label: _("Export Batch"),
container: "exportbatchc",
onclick: {fn:function(){Xport('batch')}}
});
new YAHOO.widget.Button("deletebatch");
}
//]]>
</script>
<ul class="toolbar">
<li id="additemsc"><a id="additems" href="#">Add Item(s)</a></li>
<li id="removeitemsc"><a id="removeitems" href="#">Remove Item(s)</a></li>
<li id="deletebatchc"><a id="deletebatch" href="#">Delete Batch</a></li>
<li id="deduplicatec"><a id="deduplicate" href="#">Remove Duplicates</a></li>
<li id="exportitemsc"><a id="exportitems" href="#">Export Item(s)</a></li>
<li id="exportbatchc"><a id="exportbatch" href="#">Export Batch</a></li>
</ul>
</div>

View file

@ -1,8 +1,8 @@
<div id="navmenu"><ul id="navmenulist">
<li><a href="/cgi-bin/koha/labels/label-home.pl">Layouts</a></li>
<li><a href="/cgi-bin/koha/labels/label-templates.pl">Templates</a></li>
<li><a href="/cgi-bin/koha/labels/label-profiles.pl">Printer Profiles</a></li>
<li><a href="/cgi-bin/koha/labels/label-manager.pl?type=labels">Manage Label Batches</a></li>
<li><a href="/cgi-bin/koha/labels/label-manager.pl?type=patroncards">Manage Patron Card Batches</a></li>
<li><a href="/cgi-bin/koha/labels/label-home.pl">Labels Home</a></li>
<li><a href="/cgi-bin/koha/labels/label-manage.pl?label_element=layout">Manage Layouts</a></li>
<li><a href="/cgi-bin/koha/labels/label-manage.pl?label_element=template">Manage Templates</a></li>
<li><a href="/cgi-bin/koha/labels/label-manage.pl?label_element=profile">Manage Profiles</a></li>
<li><a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Manage Batches</a></li>
</ul>
</div>

View file

@ -0,0 +1,23 @@
<script type="text/javascript">
//<![CDATA[
// prepare DOM for YUI Toolbar
$(document).ready(function() {
yuiToolbar();
});
// YUI Toolbar Functions
function yuiToolbar() {
new YAHOO.widget.Button("newlabel");
new YAHOO.widget.Button("newtemplate");
new YAHOO.widget.Button("newprofile");
new YAHOO.widget.Button("newbatch");
}
//]]>
</script>
<div id="toolbar">
<ul class="toolbar">
<li><a id="newlabel" href="/cgi-bin/koha/labels/label-edit-layout.pl?op=new">New Layout</a></li>
<li><a id="newtemplate" href="/cgi-bin/koha/labels/label-edit-template.pl?op=new">New Template</a></li>
<li><a id="newprofile" href="/cgi-bin/koha/labels/label-edit-profile.pl?op=new">New Profile</a></li>
<li><a id="newbatch" href="/cgi-bin/koha/labels/label-edit-batch.pl?op=new">New Batch</a></li>
</ul>
</div>

View file

@ -0,0 +1,75 @@
<script type="text/javascript">
//<![CDATA[
// prepare DOM for YUI Toolbar
$(document).ready(function() {
$("#layoutsc").empty();
$("#templatesc").empty();
$("#profilesc").empty();
$("#batches").empty();
yuiToolbar();
});
// YUI Toolbar Functions
function yuiToolbar() {
var layouts = [
{text: _("Manage Layouts"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=layout" },
{text: _("New Layout"), url: "/cgi-bin/koha/labels/label-edit-layout.pl?op=new" }
];
var templates = [
{text: _("Manage Templates"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=template" },
{text: _("New Template"), url: "/cgi-bin/koha/labels/label-edit-template.pl?op=new" }
];
var profiles = [
{text: _("Manage Profiles"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=profile" },
{text: _("New Profile"), url: "/cgi-bin/koha/labels/label-edit-profile.pl?op=new" }
];
var batches = [
{text: _("Manage Batches"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=batch" },
{text: _("New Batch"), url: "/cgi-bin/koha/labels/label-edit-batch.pl?op=new" }
];
new YAHOO.widget.Button({
type: "menu",
label: _("Layouts"),
name: "layouts",
menu: layouts,
container: "layoutsc"
});
new YAHOO.widget.Button({
type: "menu",
label: _("Templates"),
name: "templates",
menu: templates,
container: "templatesc"
});
new YAHOO.widget.Button({
type: "menu",
label: _("Profiles"),
name: "profiles",
menu: profiles,
container: "profilesc"
});
new YAHOO.widget.Button({
type: "menu",
label: _("Batches"),
name: "batches",
menu: batches,
container: "batchesc"
});
}
//]]>
</script>
<div id="toolbar">
<ul class="toolbar">
<li id="layoutsc"><a id="layouts" href="#">Layouts</a></li>
<li id="templatesc"><a id="templates" href="#">Templates</a></li>
<li id="profilesc"><a id="profiles" href="#">Profiles</a></li>
<li id="batchesc"><a id="batches" href="#">Batches</a></li>
</ul>
</div>

View file

@ -1,85 +0,0 @@
<!-- TMPL_IF NAME="batch_is_labels" -->
<div id="toolbar">
<script type="text/javascript">
//<![CDATA[
function Plugin(batch_id, batch_type) {
window.open("label-item-search.pl?batch_id="+batch_id+"&amp;type="+batch_type+"",'FindABibIndex','width=640,height=400,toolbar=no,scrollbars=yes');
return false;
}
// prepare DOM for YUI Toolbar
$(document).ready(function() {
$("#additemsc").empty();
yuiToolbar();
});
// YUI Toolbar Functions
function yuiToolbar() {
new YAHOO.widget.Button({
id: "additems",
type: "link",
href: "#",
label: _("Add item(s) to batch"),
container: "additemsc",
onclick: {fn:function(){Plugin(<!-- TMPL_VAR NAME="batch_id" -->,"<!-- TMPL_VAR NAME="batch_type" -->")}}
});
new YAHOO.widget.Button("deletebatch");
new YAHOO.widget.Button("dedup");
new YAHOO.widget.Button("generate");
}
//]]>
</script>
<ul class="toolbar">
<li id="additemsc"><a id="additems" href="#">Add item(s) to batch</a></li>
<li><a id="deletebatch" href="/cgi-bin/koha/labels/label-manager.pl?op=delete_batch&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Delete current batch</a></li>
<!-- FIXME: should use POST to change server state, not GET -->
<li><a id="dedup" href="/cgi-bin/koha/labels/label-manager.pl?op=deduplicate&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Remove duplicates</a></li>
<li><a id="generate" href="/cgi-bin/koha/labels/label-print-<!-- TMPL_VAR NAME="outputformat" -->.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Generate labels for Batch</a></li>
</ul></div>
<!-- TMPL_ELSIF NAME="batch_is_patroncards" -->
<div id="toolbar">
<script type="text/javascript">
//<![CDATA[
function Plugin(batch_id, batch_type) {
// window.open("label-item-search.pl?batch_id="+batch_id+"",'FindABibIndex','width=640,height=400,toolbar=no,scrollbars=yes');
window.open("pcard-member-search.pl?batch_id="+batch_id+"&amp;type="+batch_type+"",'FindAPatronIndex','width=640,height=400,toolbar=no,scrollbars=yes');
}
// prepare DOM for YUI Toolbar
$(document).ready(function() {
$("#addpatronsc").empty();
yuiToolbar();
});
// YUI Toolbar Functions
function yuiToolbar() {
new YAHOO.widget.Button({
id: "addpatrons",
type: "link",
href: "#",
label: _("Add patron(s) to batch"),
container: "addpatronsc",
onclick: {fn:function(){Plugin(<!-- TMPL_VAR NAME="batch_id" -->,"<!-- TMPL_VAR NAME="batch_type" -->"); }}
});
new YAHOO.widget.Button("deletebatch");
new YAHOO.widget.Button("dedup");
new YAHOO.widget.Button("generate");
}
//]]>
</script>
<ul class="toolbar">
<li id="addpatronsc"><a id="addpatrons" href="#">Add patron(s) to batch</a></li>
<li><a id="deletebatch" href="/cgi-bin/koha/labels/label-manager.pl?op=delete_batch&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Delete current batch</a></li>
<!-- FIXME: should use POST to change server state, not GET -->
<li><a id="dedup" href="/cgi-bin/koha/labels/label-manager.pl?op=deduplicate&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Remove duplicates</a></li>
<li><a id="generate" href="/cgi-bin/koha/labels/label-print-<!-- TMPL_VAR NAME="outputformat" -->.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Generate labels for Batch</a></li>
</ul></div>
<!-- /TMPL_IF -->

View file

@ -1,29 +0,0 @@
<div id="toolbar">
<script type="text/javascript">
//<![CDATA[
// prepare DOM for YUI Toolbar
$(document).ready(function() {
yuiToolbar();
});
// YUI Toolbar Functions
function yuiToolbar() {
new YAHOO.widget.Button("newlabel");
new YAHOO.widget.Button("newtemplate");
new YAHOO.widget.Button("newprofile");
new YAHOO.widget.Button("newlabelbatch");
new YAHOO.widget.Button("newpatroncardbatch");
}
//]]>
</script>
<ul class="toolbar">
<li><a id="newlabel" href="/cgi-bin/koha/labels/label-edit-layout.pl">New Layout</a></li>
<li><a id="newtemplate" href="/cgi-bin/koha/labels/label-create-template.pl?op=blank">New Label Template</a></li>
<li><a id="newprofile" href="/cgi-bin/koha/labels/label-create-profile.pl?op=blank">New Printer Profile</a></li>
<li><a id="newlabelbatch" href="/cgi-bin/koha/labels/label-manager.pl?op=add_batch&amp;type=labels">New Label Batch</a></li>
<li><a id="newpatroncardbatch" href="/cgi-bin/koha/labels/label-manager.pl?op=add_batch&amp;type=patroncards">New Patron Card Batch</a></li>
</ul></div>

View file

@ -60,7 +60,16 @@
.GB_header table {
margin: 0;
width: 100%;
border-collapse: collapse;
border-collapse: separate;
border-right: 0px;
border-top: 0px;
}
.GB_header td {
background-color: #333333;
border-bottom: 0px;
border-left: 0px;
padding: 0em 0em;
}
.GB_header .caption {
@ -68,6 +77,7 @@
color: #eee;
white-space: nowrap;
font-size: 20px;
border-collapse: separate;
}
.GB_header .close {
@ -146,3 +156,15 @@
.GB_Window .on { border-bottom: 1px solid #333; }
.GB_Window .click { border-bottom: 1px solid red; }
table {
border-collapse: separate;
border-spacing: 0;
border: hidden none;
}
.header {
cursor: auto;
background-position: center center;
background-repeat: repeat;
}

View file

@ -116,8 +116,9 @@ $(document).ready(function(){
<td><!-- TMPL_VAR NAME="edition" --></td>
<td><!-- TMPL_VAR NAME="isbn" --></td>
<td><!-- TMPL_VAR NAME="lccn" --></td>
<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=<!-- TMPL_VAR NAME="breedingid" -->" title="MARC" rel="gb_page_center[600,500]">MARC</a></td><td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=<!-- TMPL_VAR NAME="breedingid" -->" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
<td><a href="javascript:Import(<!-- TMPL_VAR NAME="breedingid" -->,<!-- TMPL_VAR NAME="biblionumber" -->)">Import</a></td>
<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=<!-- TMPL_VAR NAME="breedingid" -->" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&importid=<!-- TMPL_VAR NAME="breedingid" -->" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
<td><a href="javascript:Import(<!-- TMPL_VAR NAME="breedingid" -->,<!-- TMPL_VAR NAME="biblionumber" -->)">Import</a></td>
</tr>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP --></tbody>

View file

@ -1,255 +0,0 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Create Layout</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; Create Layout</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="label-status.inc" -->
<form name="input" action="/cgi-bin/koha/labels/label-manager.pl" method="get">
<fieldset class="rows">
<legend>Create Layout</legend>
<ol><li><label for="layoutname">Layout Name</label>
<input type="text" name="layoutname" id="layoutname" size="20" value="<!-- TMPL_VAR NAME="layoutname" -->" /></li>
<li><fieldset>
<legend>Choose Order Of Fields to Print</legend>
<table summary="fields to print">
<tr>
<td>
<select name="tx_title" id="tx_title">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_title">Title</label>
</td>
<td>
<select name="tx_subtitle" id="tx_subtitle">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_subtitle">Subtitle</label>
</td>
<td>
<select name="tx_author" id="tx_author">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_author">Author</label>
</td>
</tr>
<tr>
<td>
<select name="tx_isbn" id="tx_isbn">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_isbn">ISBN</label>
</td>
<td>
<select name="tx_issn" id="tx_issn">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_issn">ISSN</label>
</td>
<td>
<select name="tx_itemtype" id="tx_itemtype">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_itemtype">Itemtype</label>
</td>
</tr>
<tr>
<td>
<select name="tx_dewey" id="tx_dewey">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_dewey">Dewey</label>
</td>
<td>
<select name="tx_barcode" id="tx_barcode">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_barcode">Barcode</label>
</td>
<td>
<select name="tx_classif" id="tx_classif">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_classif">Classification</label>
</td>
</tr>
<tr>
<td>
<select name="tx_subclass" id="tx_subclass">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_subclass">Sub-Class</label>
</td>
<td colspan="2">
<select name="tx_itemcallnumber" id="tx_itemcallnumber">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="tx_itemcallnumber">Call Number</label>
</td>
</tr>
</table></fieldset></li>
<li><label for="barcodetype">Choose Barcode Type: </label>
<select name="barcodetype" id="barcodetype">
<!-- TMPL_LOOP NAME="barcode_types" -->
<!-- TMPL_IF NAME="active" --><option value="<!-- TMPL_VAR NAME="code" -->" selected="selected"><!-- TMPL_VAR NAME="desc" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="code" -->"><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select></li>
<li><label for="printingtype">Choose Layout Type: </label>
<select name="printingtype" id="printingtype">
<!-- TMPL_LOOP NAME="printingtypes" -->
<!-- TMPL_IF NAME="active" -->
<option value="<!-- TMPL_VAR NAME="code" -->" selected="selected"><!-- TMPL_VAR NAME="desc" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="code" -->"><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select></li>
<li>
<label for="startlabel">Start printing from Label number: </label> <input type="text" name="startlabel" id="startlabel" size="2" value="1" /></li>
<li><label for="guidebox">Draw Guide Boxes: </label><input type="checkbox" id="guidebox" name="guidebox" value="1" /></li></ol></fieldset>
<fieldset class="action"><input type="hidden" name="op" value="add_layout" />
<input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/labels/label-home.pl">Cancel</a></fieldset>
</form>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,95 +0,0 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript">
//<![CDATA[
function confirm_deletion(biblionumber,itemnumber) {
var original = $("#row"+itemnumber).attr("class");
$("#row"+itemnumber).attr("class","confirm");
var is_confirmed = confirm(_('Are you sure you want to delete this profile?'));
if (is_confirmed) {
window.location = "additem.pl?op=delitem&biblionumber="+biblionumber+"&itemnumber="+itemnumber;
} else {
$("#row"+itemnumber).attr("class","");
}
}
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-profiles.pl">Printer Profiles</a> &rsaquo; Create Printer Profile</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<h3>Create Printer Profile</h3>
<!-- TMPL_IF NAME="dberror" -->
<div class="yui-g">
<div class="dialog alert"><h3>Error Creating Profile</h3>
<p>
<!-- TMPL_VAR NAME="errmsg" -->
</p>
</div>
</div>
<!-- /TMPL_IF -->
<div class="yui-g">
<form name="input" action="/cgi-bin/koha/labels/label-create-profile.pl" method="get">
<fieldset class="rows"><legend>Profile Settings</legend>
<ol>
<li>
<label for="printername">Printer Name:</label> <input type="text" size="40" name="printername" id="printername" />
</li>
<li>
<label for="paper_bin">Paper Bin:</label><input type="text" size="20" name="paper_bin" id="paper_bin" />
</li>
<li>
<label for="tmpl_id">Template Code: </label><select id="tmpl_id" name="tmpl_id">
<!-- TMPL_LOOP NAME="tmpllist" -->
<option value="<!-- TMPL_VAR NAME="tmpl_id" -->"><!-- TMPL_VAR NAME="tmpl_code" --></option>
<!-- /TMPL_LOOP --></select>
</li>
<li>
<fieldset><legend>Offset:</legend>
<ol><li><label for="offset_horz">Horizontal:</label><input type="text" size="2" name="offset_horz" id="offset_horz" /></li>
<li><label for="offset_vert">Vertical:</label><input type="text" size="2" name="offset_vert" id="offset_vert" /></li></ol></fieldset>
</li>
<li>
<fieldset><legend>Creep:</legend>
<ol><li>
<label for="creep_horz">Horizontal:</label><input type="text" size="2" name="creep_horz" id="creep_horz" />
</li>
<li>
<label for="creep_vert">Vertical:</label><input type="text" size="2" name="creep_vert" id="creep_vert" />
</li></ol>
</fieldset>
</li>
<li><label for="unit">Units: </label><select id="unit" name="unit">
<!-- TMPL_LOOP NAME="unit" -->
<option value="<!-- TMPL_VAR NAME="unit" -->"><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_LOOP -->
</select>
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" name="op" value="Save" /> <a class="cancel" href="/cgi-bin/koha/labels/label-profiles.pl">Cancel</a>
</fieldset></form></div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,86 +0,0 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; Create Label Template</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<form name="input" action="/cgi-bin/koha/labels/label-create-template.pl" method="get">
<fieldset class="rows">
<legend>Create Label Template</legend>
<ol>
<li><label for="tmpl_code">Template Code:</label> <input type="text" size="40" name="tmpl_code" id="tmpl_code" /></li>
<li><label for="tmpl_desc">Template Description:</label> <textarea cols="40" rows="3" name="tmpl_desc" id="tmpl_desc"></textarea></li>
<li><label for="units">Units: </label><select id="units" name="units">
<!-- TMPL_LOOP NAME="units" -->
<option value="<!-- TMPL_VAR NAME="unit" -->"><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_LOOP -->
</select></li>
<li>
<label for="page_width">Page Width:</label><input type="text" size="2" name="page_width" id="page_width" />
</li>
<li>
<label for="page_height">Page Height:</label><input type="text" size="2" name="page_height" id="page_height" />
</li>
<li>
<label for="label_width">Label Width:</label><input type="text" size="2" name="label_width" id="label_width" />
</li>
<li>
<label for="label_height">Label Height:</label><input type="text" size="2" name="label_height" id="label_height" />
</li>
<li>
<label for="topmargin">Top Page Margin:</label><input type="text" size="2" name="topmargin" id="topmargin" />
</li>
<li>
<label for="leftmargin">Left Page Margin:</label><input type="text" size="2" name="leftmargin" id="leftmargin" />
</li>
<li>
<label for="cols">Number of Columns:</label><input type="text" size="2" name="cols" id="cols" />
</li>
<li>
<label for="rows">Number of Rows:</label><input type="text" size="2" name="rows" id="rows" />
</li>
<li>
<label for="colgap">Gap between Columns:</label><input type="text" size="2" name="colgap" id="colgap" />
</li>
<li>
<label for="rowgap">Gap between Rows:</label><input type="text" size="2" name="rowgap" id="rowgap" />
</li>
<li><label for="fonts">Font: </label><select id="fonts" name="fonts">
<!-- TMPL_LOOP NAME="fonts" -->
<option value="<!-- TMPL_VAR NAME="font" -->"><!-- TMPL_VAR NAME="name" --></option>
<!-- /TMPL_LOOP -->
</select></li>
<li><label for="fontsize">Font Size:</label> <input type="text" id="fontsize" name="fontsize" size="1" value="" /></li>
<li><label for="active">Active: </label><input type="checkbox" id="active" name="active" /></li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" name="op" value="Create" />
<input type="submit" name="op" value="Cancel" />
</fieldset>
</form>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -0,0 +1,75 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Manage Label Batches</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="greybox.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/labels/labels-home.pl">Labels Home</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Mange Label Batches</a> &rsaquo;
Manage Batch Number <!-- TMPL_VAR NAME="batch_id" -->
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-batches-toolbar.inc" -->
<div class="yui-g">
<div class="yui-u first" id="manage-label-batches">
<div class="hint">Current Branch: <!-- TMPL_VAR NAME="LoginBranchname" --></div>
<!-- TMPL_IF NAME="table_loop" -->
<form name="items" class="checkboxed">
<h2>Items in batch number <!-- TMPL_VAR NAME="batch_id" --></h2>
<table>
<!-- TMPL_LOOP NAME="table_loop" -->
<!-- TMPL_IF NAME="header_fields" -->
<tr>
<!-- TMPL_LOOP NAME="header_fields" -->
<th><!-- TMPL_VAR NAME="field_label" --></th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_ELSE -->
<tr>
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="select_field" -->
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
<!-- TMPL_ELSE -->
<td><!-- TMPL_VAR NAME="field_value" --></td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</table>
</form>
<!-- TMPL_ELSE -->
<h2>There are no items in this batch yet</h2>
<div class="hint"><h3>Use the toolbar above to add items.</h3></div>
<!-- /TMPL_IF -->
</div>
<!-- TMPL_IF NAME="err" -->
<div class="yui-u">
<div class="alert">
<strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="errstr" --> Please have your system administrator check the error log for details.</strong>
</div>
</div>
<!-- TMPL_ELSIF NAME="duplicate_message" -->
<div class="yui-u">
<div class="dialog">
<strong><!-- TMPL_VAR NAME="duplicate_count" --> duplicate item(s) found and removed from batch <!-- TMPL_VAR NAME="batch_id" -->.</strong>
</div>
</div>
<!-- /TMPL_IF -->
</div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,264 +1,182 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript">
$(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>
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/JavaScript" language="JavaScript">
//<![CDATA[
$(document).ready(function() {
$("input[name='layout_choice']").change( function() { layout_method() } );
layout_method();
});
function layout_method() {
if( $("input[name='layout_choice']:checked").val() == 'layout_string' ) {
$('#layout_table').hide();
$('#layout_string').show();
} else {
$('#layout_table').show();
$('#layout_string').hide();
}
}
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; <!-- TMPL_IF NAME="layout_id" -->Edit<!-- TMPL_ELSE -->Create<!-- /TMPL_IF --> Label Layout</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<form name="input" action="/cgi-bin/koha/labels/label-manager.pl" method="get">
<fieldset class="rows">
<legend><!-- TMPL_IF NAME="layout_id" -->Edit<!-- TMPL_ELSE -->Create<!-- /TMPL_IF --> Label Layout</legend>
<ol>
<li><label for="layoutname">Layout Name</label>
<input type="text" name="layoutname" id="layoutname" size="20" value="<!-- TMPL_VAR NAME="layoutname" -->" /></li>
<li><label for="barcodetype">Choose Barcode Type (encoding)</label>
<select name="barcodetype" id="barcodetype">
<!-- TMPL_LOOP NAME="barcode_types" -->
<!-- TMPL_IF NAME="active" -->
<option value="<!-- TMPL_VAR NAME="code" -->" selected="selected"><!-- TMPL_VAR NAME="desc" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="code" -->"><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select></li>
<li><label for="printingtype">Choose Layout Type</label>
<select name="printingtype" id="printingtype">
<!-- TMPL_LOOP NAME="printingtypes" -->
<!-- TMPL_IF NAME="active" -->
<option value="<!-- TMPL_VAR NAME="code" -->" selected="selected"><!-- TMPL_VAR NAME="desc" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="code" -->"><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select></li>
<li>
<fieldset class="rows">
<legend>
Bibliographic Data to Print
</legend>
<!-- TMPL_IF NAME="layout_string" -->
<input type="radio" name="layoutchoice" value="layout_tx" />Choose Order Of Text Fields to Print
<!-- TMPL_ELSE -->
<input type="radio" name="layoutchoice" value="layout_tx" checked="checked" />Choose Order Of Text Fields to Print
<!-- /TMPL_IF -->
<br />
<fieldset id="layout_tx">
<table summary="fields to print">
<tr>
<td>
<select name="tx_title" id="tx_title">
<!-- TMPL_LOOP Name="tx_title" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_title">Title</label>
</td>
<td>
<select name="tx_author" id="tx_author">
<!-- TMPL_LOOP Name="tx_author" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_author">Author</label>
</td>
<td>
<select name="tx_isbn" id="tx_isbn">
<!-- TMPL_LOOP Name="tx_isbn" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_isbn">ISBN</label>
</td>
</tr>
<tr>
<td>
<select name="tx_issn" id="tx_issn">
<!-- TMPL_LOOP Name="tx_issn" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_issn">ISSN</label>
</td>
<td>
<select name="tx_itemtype" id="tx_itemtype">
<!-- TMPL_LOOP Name="tx_itemtype" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_itemtype">Itemtype</label>
</td>
<td>
<select id="tx_barcode" name="tx_barcode">
<!-- TMPL_LOOP Name="tx_barcode" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_barcode">Barcode (as text)</label>
</td>
</tr>
<tr>
<td>
<select name="tx_itemcallnumber" id="tx_itemcallnumber">
<!-- TMPL_LOOP Name="tx_itemcallnumber" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->">
<!-- TMPL_VAR Name="num" -->
</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="tx_itemcallnumber">Call Number</label>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<br />
</fieldset>
<br />
<!-- TMPL_IF NAME="formatstring" -->
<input type="radio" name="layoutchoice" value="layout_string" checked="checked"/> List Fields
<!-- TMPL_ELSE -->
<input type="radio" name="layoutchoice" value="layout_string" /> List Fields
<!-- /TMPL_IF -->
<fieldset id="layout_string" class="brief">
<label for="layoutname">Data Fields</label>
<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>
<p>See online help for advanced options</p>
<p>ex: barcode, itemcallnumber, title, "050a 050b", 300a </p>
</div>
</fieldset>
</fieldset>
</li>
<li><label for="startlabel">Start printing from Label number: </label><input type="text" name="startlabel" id="startlabel" size="1" value="<!-- TMPL_IF NAME="startlabel" --><!-- TMPL_VAR NAME="startlabel" --><!-- TMPL_ELSE -->1<!-- /TMPL_IF -->" /></li>
<li><label for="guidebox">Draw Guide Boxes</label>
<!-- TMPL_IF NAME="guidebox"-->
<input type="checkbox" name="guidebox" id="guidebox" value="1" checked="checked" />
<!-- TMPL_ELSE -->
<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 id="text_justify" 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">
<input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/labels/label-home.pl">Cancel</a>
<input type="hidden" name="op" value="<!-- TMPL_IF NAME="layout_id" -->save<!-- TMPL_ELSE -->add<!-- /TMPL_IF -->_layout" />
<input type="hidden" name="layout_id" value="<!-- TMPL_VAR NAME="layout_id" -->" />
</fieldset>
</form>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels Home</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=layout">Mange Label Layouts</a> &rsaquo;
<!-- TMPL_IF NAME="layout_id" -->Edit<!-- TMPL_ELSE -->Create<!-- /TMPL_IF --> Label Layout
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="input" action="/cgi-bin/koha/labels/label-edit-layout.pl" method="get">
<fieldset class="rows">
<legend><!-- TMPL_IF NAME="layout_id" -->Edit<!-- TMPL_ELSE -->Create<!-- /TMPL_IF --> Label Layout</legend>
<ol>
<li>
<label for="layout_name">Layout Name</label>
<input type="text" name="layout_name" id="layout_name" size="20" value="<!-- TMPL_VAR NAME="layout_name" -->" />
</li>
<li>
<label for="barcode_type">Choose Barcode Type (encoding)</label>
<select name="barcode_type" id="barcode_type">
<!-- TMPL_LOOP NAME="barcode_types" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="type" -->" selected="selected"><!-- TMPL_VAR NAME="name" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="type" -->"><!-- TMPL_VAR NAME="name" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<label for="printing_type">Choose Layout Type</label>
<select name="printing_type" id="printing_type">
<!-- TMPL_LOOP NAME="label_types" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="type" -->" selected="selected"><!-- TMPL_VAR NAME="name" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="type" -->"><!-- TMPL_VAR NAME="name" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<fieldset class="rows">
<legend>Bibliographic Data to Print</legend>
<!-- TMPL_IF NAME="layout_string" -->
<input type="radio" name="layout_choice" value="layout_table" checked="checked">Choose Order Of Text Fields to Print</input>
<!-- TMPL_ELSE -->
<input type="radio" name="layout_choice" value="layout_table">Choose Order Of Text Fields to Print</input>
<!-- /TMPL_IF -->
<br />
<fieldset id="layout_table">
<table summary="fields to print">
<!-- TMPL_LOOP NAME="field_table" -->
<tr>
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="field_empty" -->
<td>
&nbsp;
</td>
<!-- TMPL_ELSE -->
<td>
<select name="<!-- TMPL_VAR NAME="field_name" -->" id="<!-- TMPL_VAR NAME="field_name" -->">
<!-- TMPL_LOOP NAME="order" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="num" -->" selected="selected"><!-- TMPL_VAR Name="num" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="num" -->"><!-- TMPL_VAR Name="num" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<label for="<!-- TMPL_VAR NAME="field_name" -->"><!-- TMPL_VAR NAME="field_label" --></label>
</td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
</table>
<br />
</fieldset>
<br />
<!-- TMPL_IF NAME="layout_string" -->
<input type="radio" name="layout_choice" value="layout_string" checked="checked"> List Fields </input>
<!-- TMPL_ELSE -->
<input type="radio" name="layout_choice" value="layout_string"> List Fields </input>
<!-- /TMPL_IF -->
<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" -->" />
<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>
<p>See online help for advanced options</p>
<p>ex: barcode, itemcallnumber, title, "050a 050b", 300a </p>
</div>
</fieldset>
</fieldset>
</li>
<li>
<label for="guidebox">Draw Guide Boxes</label>
<!-- TMPL_IF NAME="guidebox"-->
<input type="checkbox" name="guidebox" id="guidebox" value="1" checked="checked" />
<!-- TMPL_ELSE -->
<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" id="text_justify">
<!-- TMPL_LOOP Name="text_justification_types" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="type" -->" selected="selected"><!-- TMPL_VAR Name="name" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="type" -->"><!-- TMPL_VAR Name="name" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<label for="font">Font</label>
<select name="font" id="font">
<!-- TMPL_LOOP Name="font_types" -->
<!-- TMPL_IF Name="selected" -->
<option value="<!-- TMPL_VAR Name="type" -->" selected="selected"><!-- TMPL_VAR Name="name" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR Name="type" -->"><!-- TMPL_VAR Name="name" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<label for="font_size">Font Size</label>
<input type="text" name="font_size" id="font_size" size="2" value="<!-- TMPL_VAR ESCAPE='HTML' NAME="font_size" -->" />
</li>
</ol>
</fieldset>
<fieldset class="action">
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Save" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/labels/label-manage.pl?label_element=layout';" /></span></span>
<input type="hidden" name="op" value="save" />
<input type="hidden" name="layout_id" value="<!-- TMPL_VAR NAME="layout_id" -->" />
</fieldset>
</form>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,74 +1,99 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->i
<title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>&rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-profiles.pl">Printer Profiles</a> &rsaquo; Edit Printer Profile</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="input" action="/cgi-bin/koha/labels/label-edit-profile.pl" method="get">
<div class="yui-g">
<h3>Edit Printer Profile</h3>
<div class="yui-g first">
<fieldset class="rows"><legend>Profile Settings</legend>
<ol>
<li>
<label>Printer Name:</label> <!-- TMPL_VAR NAME="printername" -->
</li>
<li>
<label>Paper Bin:</label> <!-- TMPL_VAR NAME="paper_bin" -->
</li>
<li>
<label>Template Name:</label> <!-- TMPL_VAR NAME="tmpl_code" -->
</li>
<li>
<label><h4>Offset:</h4></label>
</li>
<li>
<label for="offset_horz">Horizontal: </label><input type="text" size="4" name="offset_horz" id="offset_horz" value="<!-- TMPL_VAR NAME="offset_horz" -->" />
</li>
<li>
<label for="offset_vert">Vertical: </label><input type="text" size="4" name="offset_vert" id="offset_vert" value="<!-- TMPL_VAR NAME="offset_vert" -->" />
</li>
<li>
<label><h4>Creep:</h4></label>
</li>
<li>
<label for="creep_horz">Horizontal: </label><input type="text" size="4" name="creep_horz" id="creep_horz" value="<!-- TMPL_VAR NAME="creep_horz" -->" />
</li>
<li>
<label for="creep_vert">Vertical: </label><input type="text" size="4" name="creep_vert" id="creep_vert" value="<!-- TMPL_VAR NAME="creep_vert" -->" />
</li>
<li><label for="unit">Units: </label><select id="unit" name="unit">
<!-- TMPL_LOOP NAME="units" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="unit" -->" selected="selected">
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="unit" -->">
<!-- /TMPL_IF --><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_LOOP -->
</select>
</li>
<input type="hidden" name="prof_id" value="<!-- TMPL_VAR NAME="prof_id" -->" />
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" name ="op" value="Save" /> <input type="submit" name="op" value="Cancel" />
</fieldset></div>
</div>
</div></form>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a>&rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>&rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels</a>&rsaquo;
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=profile">Printer Profiles</a>&rsaquo;
Edit Printer Profile
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="input" action="/cgi-bin/koha/labels/label-edit-profile.pl" method="get">
<div class="yui-g">
<h3>Edit Printer Profile</h3>
<div class="yui-g first">
<fieldset class="rows"><legend>Profile Settings</legend>
<ol>
<li>
<label for="printer_name">Printer Name:</label>
<!-- TMPL_IF NAME="profile_id" -->
<!-- TMPL_VAR NAME="printer_name" -->
<!-- TMPL_ELSE -->
<input type="text" size="20" name="printer_name" id="printer_name" />
<!-- /TMPL_IF -->
</li>
<li>
<label for="paper_bin">Paper Bin:</label>
<!-- TMPL_IF NAME="profile_id" -->
<!-- TMPL_VAR NAME="paper_bin" -->
<!-- TMPL_ELSE -->
<input type="text" size="20" name="paper_bin" id="paper_bin" />
<!-- /TMPL_IF -->
</li>
<li>
<label for="template_name">Template Name:</label>
<!-- TMPL_IF NAME="label_template" -->
<!-- TMPL_VAR NAME="label_template" -->
<!-- TMPL_ELSE -->
Profile Unassigned
<!-- /TMPL_IF -->
</li>
</li>
<li>
<label><h4>Offset:</h4></label>
</li>
<li>
<label for="offset_horz">Horizontal: </label><input type="text" size="4" name="offset_horz" id="offset_horz" value="<!-- TMPL_VAR NAME="offset_horz" -->" />
</li>
<li>
<label for="offset_vert">Vertical: </label><input type="text" size="4" name="offset_vert" id="offset_vert" value="<!-- TMPL_VAR NAME="offset_vert" -->" />
</li>
<li>
<label><h4>Creep:</h4></label>
</li>
<li>
<label for="creep_horz">Horizontal: </label><input type="text" size="4" name="creep_horz" id="creep_horz" value="<!-- TMPL_VAR NAME="creep_horz" -->" />
</li>
<li>
<label for="creep_vert">Vertical: </label><input type="text" size="4" name="creep_vert" id="creep_vert" value="<!-- TMPL_VAR NAME="creep_vert" -->" />
</li>
<li>
<label for="units">Units: </label>
<select id="units" name="units">
<!-- TMPL_LOOP NAME="units" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="type" -->" selected="selected">
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="type" -->">
<!-- /TMPL_IF -->
<!-- TMPL_VAR NAME="desc" -->
</option>
<!-- /TMPL_LOOP -->
</select>
</li>
</ol>
</fieldset>
<fieldset class="action">
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Save" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/labels/label-manage.pl?label_element=profile';" /></span></span>
<input type="hidden" name="op" value="save" />
<input type="hidden" name="profile_id" value="<!-- TMPL_VAR NAME="profile_id" -->" />
</fieldset>
</div>
</div>
</div>
</form>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,126 +1,135 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Templates</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>&rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-templates.pl">Label Templates</a> &rsaquo; Edit Label Template</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="input" action="/cgi-bin/koha/labels/label-save-template.pl" method="get">
<div class="yui-g">
<h3>Edit Label Template</h3>
<div class="yui-u first">
<fieldset class="rows"><legend>Template Settings</legend>
<ol>
<li><span class="label">Template ID: <!-- TMPL_VAR NAME="tmpl_id" --> </span></li>
<li><label for="tmpl_code">Template Code:</label> <input type="text" size="40" name="tmpl_code" id="tmpl_code" value="<!-- TMPL_VAR NAME="tmpl_code" -->" /></li>
<li><label for="tmpl_desc">Template Description:</label> <textarea cols="40" rows="3" id="tmpl_desc" name="tmpl_desc"><!-- TMPL_VAR NAME="tmpl_desc" --></textarea></li>
<li>
<label for="page_width">Page Width: </label><input type="text" size="4" name="page_width" id="page_width" value="<!-- TMPL_VAR NAME="page_width" -->" />
</li>
<li>
<label for="page_height">Page Height: </label><input type="text" size="4" name="page_height" id="page_height" value="<!-- TMPL_VAR NAME="page_height" -->" />
</li>
<li>
<label for="label_width">Label Width: </label><input type="text" size="4" name="label_width" id="label_width" value="<!-- TMPL_VAR NAME="label_width" -->" />
</li>
<li>
<label for="label_height">Label Height: </label><input type="text" size="4" name="label_height" id="label_height" value="<!-- TMPL_VAR NAME="label_height" -->" />
</li>
<li>
<label for="topmargin">Top Page Margin: </label><input type="text" size="4" name="topmargin" id="topmargin" value="<!-- TMPL_VAR NAME="topmargin" -->" />
</li>
<li>
<label for="leftmargin">Left Page Margin: </label><input type="text" size="4" name="leftmargin" id="leftmargin" value="<!-- TMPL_VAR NAME="leftmargin" -->" />
</li>
</ol>
</fieldset>
</div>
<div class="yui-u">
<fieldset class="rows">
<ol>
<li>
<label for="cols">Number of Columns: </label><input type="text" size="4" name="cols" id="cols" value="<!-- TMPL_VAR NAME="cols" -->" />
</li>
<li>
<label for="rows">Number of Rows: </label><input type="text" size="4" name="rows" id="rows" value="<!-- TMPL_VAR NAME="rows" -->" />
</li>
<li>
<label for="colgap">Gap between Columns: </label><input type="text" size="4" name="colgap" id="colgap" value="<!-- TMPL_VAR NAME="colgap" -->" />
</li>
<li>
<label for="rowgap">Gap between Rows: </label><input type="text" size="4" name="rowgap" id="rowgap" value="<!-- TMPL_VAR NAME="rowgap" -->" />
</li>
<li><label for="units">Units: </label><select id="units" name="units">
<!-- TMPL_LOOP NAME="units" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="unit" -->" selected="selected">
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="unit" -->">
<!-- /TMPL_IF --><!-- TMPL_VAR NAME="desc" --></option>
<!-- /TMPL_LOOP -->
</select></li>
<li><label for="prof_id">Profile: </label>
<!-- TMPL_IF NAME="proflist" -->
<select id="prof_id" name="prof_id">
<!-- TMPL_LOOP NAME="proflist" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="prof_id" -->" selected="selected">
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="prof_id" -->">
<!-- /TMPL_IF --><!-- TMPL_VAR NAME="printername" -->/<!-- TMPL_VAR NAME="paper_bin" --></option>
<!-- /TMPL_LOOP -->
</select>
<!-- TMPL_ELSE -->
None Defined
<!-- /TMPL_IF -->
</li>
<li><label for="fonts">Font: </label><select id="fonts" name="fonts">
<!-- TMPL_LOOP NAME="fonts" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="font" -->" selected="selected">
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="font" -->">
<!-- /TMPL_IF --><!-- TMPL_VAR NAME="name" --></option>
<!-- /TMPL_LOOP -->
</select></li>
<li><label for="fontsize">Font Size:</label> <input type="text" id="fontsize" name="fontsize" size="1" value="<!-- TMPL_VAR NAME="fontsize" -->" /></li>
<li><label for="active">Active: </label>
<!-- TMPL_IF NAME="active" -->
<input type="checkbox" name="active" id="active" checked="checked" />
<!-- TMPL_ELSE -->
<input type="checkbox" name="active" id="active" />
<!-- /TMPL_IF -->
<input type="hidden" name="tmpl_id" value="<!-- TMPL_VAR NAME="tmpl_id" -->" /></li>
</ol></fieldset>
</div>
</div><div class="yui-g">
<fieldset class="action">
<input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/labels/label-save-template.pl">Cancel</a>
</fieldset></div>
</form>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a>&rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>&rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels</a>&rsaquo;
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=template">Label Templates</a>&rsaquo;
Edit Label Template
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="input" action="/cgi-bin/koha/labels/label-edit-template.pl" method="get">
<div class="yui-g">
<h3>Edit Label Template</h3>
<div class="yui-u first">
<fieldset class="rows">
<ol>
<li>
<span class="label">Template ID:</span><!-- TMPL_IF NAME="template_id" --><!-- TMPL_VAR NAME="template_id" --><!-- TMPL_ELSE -->N/A<!-- /TMPL_IF -->
</li>
<li>
<label for="template_code">Template Code:</label>
<input type="text" size="43" name="template_code" id="template_code" value="<!-- TMPL_VAR NAME="template_code" -->" />
</li>
<li>
<label for="template_desc">Template Description:</label>
<textarea cols="40" rows="3" id="template_desc" name="template_desc"><!-- TMPL_VAR NAME="template_desc" --></textarea>
</li>
<li>
<label for="page_height">Page Height:</label>
<input type="text" size="4" name="page_height" id="page_height" value="<!-- TMPL_VAR NAME="page_height" -->" />
</li>
<li>
<label for="page_width">Page Width:</label>
<input type="text" size="4" name="page_width" id="page_width" value="<!-- TMPL_VAR NAME="page_width" -->" />
</li>
<li>
<label for="label_width">Label Width:</label>
<input type="text" size="4" name="label_width" id="label_width" value="<!-- TMPL_VAR NAME="label_width" -->" />
</li>
<li>
<label for="label_height">Label Height:</label>
<input type="text" size="4" name="label_height" id="label_height" value="<!-- TMPL_VAR NAME="label_height" -->" />
</li>
<li>
<label for="top_margin">Top Page Margin:</label>
<input type="text" size="4" name="top_margin" id="top_margin" value="<!-- TMPL_VAR NAME="top_margin" -->" />
</li>
<li>
<label for="left_margin">Left Page Margin:</label>
<input type="text" size="4" name="left_margin" id="left_margin" value="<!-- TMPL_VAR NAME="left_margin" -->" />
</li>
</ol>
</fieldset>
</div>
<div class="yui-u">
<fieldset class="rows">
<ol>
<li>
<label for="top_text_margin">Top Text Margin:</label>
<input type="text" size="4" name="top_text_margin" id="top_text_margin" value="<!-- TMPL_VAR NAME="top_text_margin" -->" />
</li>
<li>
<label for="left_text_margin">Left Text Margin:</label>
<input type="text" size="4" name="left_text_margin" id="left_text_margin" value="<!-- TMPL_VAR NAME="left_text_margin" -->" />
</li>
<li>
<label for="cols">Number of Columns:</label>
<input type="text" size="4" name="cols" id="cols" value="<!-- TMPL_VAR NAME="cols" -->" />
</li>
<li>
<label for="rows">Number of Rows:</label>
<input type="text" size="4" name="rows" id="rows" value="<!-- TMPL_VAR NAME="rows" -->" />
</li>
<li>
<label for="col_gap">Gap between Columns:</label>
<input type="text" size="4" name="col_gap" id="col_gap" value="<!-- TMPL_VAR NAME="col_gap" -->" />
</li>
<li>
<label for="row_gap">Gap between Rows:</label>
<input type="text" size="4" name="row_gap" id="row_gap" value="<!-- TMPL_VAR NAME="row_gap" -->" />
</li>
<li>
<label for="units">Units:</label>
<select id="units" name="units">
<!-- TMPL_LOOP NAME="units" -->
<option value="<!-- TMPL_VAR NAME="type" -->"<!-- TMPL_IF NAME="selected" --> selected="selected"<!-- /TMPL_IF -->>
<!-- TMPL_VAR NAME="desc" -->
</option>
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<label for="profile_id">Profile:</label>
<!-- TMPL_IF NAME="profile_list" -->
<select id="profile_id" name="profile_id">
<!-- TMPL_LOOP NAME="profile_list" -->
<option value="<!-- TMPL_VAR NAME="profile_id" -->"<!-- TMPL_IF NAME="selected" --> selected="selected"<!-- /TMPL_IF -->>
<!-- TMPL_VAR NAME="printer_name" -->/<!-- TMPL_VAR NAME="paper_bin" -->
</option>
<!-- /TMPL_LOOP -->
</select>
<!-- TMPL_ELSE -->
<a href="/cgi-bin/koha/tools/tools-edit-profile.pl?op=new">Click here to define a printer profile.</a>
<!-- /TMPL_IF -->
</li>
</ol>
</fieldset>
</div>
</div>
<div class="yui-g">
<fieldset class="action">
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Save" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/labels/label-manage.pl?label_element=template';" /></span></span>
<input type="hidden" name="op" value="save" />
<!-- TMPL_IF NAME="template_id" -->
<input type="hidden" name="template_id" value="<!-- TMPL_VAR NAME="template_id" -->" />
<!-- /TMPL_IF -->
</fieldset>
</div>
</form>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,78 +1,51 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels Home</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR NAME="themelang" -->/css/label.css" />
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Labels</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<!-- TMPL_IF NAME="layout_loop" -->
<div class="yui-gc">
<div class="yui-u first">
<form name="input" action="/cgi-bin/koha/labels/label-manager.pl" method="get">
<h2>Set Active Layout</h2>
<table>
<tr>
<th>Layout</th>
<th>Barcode Type</th>
<th>Print Type</th>
<th>Fields to Print</th>
<th>Edit</th>
<th>Delete</th>
<th>Active</th>
</tr>
<!-- TMPL_LOOP NAME="layout_loop" -->
<tr>
<td><!-- TMPL_VAR NAME="layoutname" --> </td>
<td> <!-- TMPL_VAR NAME="barcodetype" --> </td>
<td> <!-- TMPL_VAR NAME="printingtype" --> </td>
<td>
<!-- TMPL_VAR NAME="fieldlist" -->
</td>
<td>
<a href="/cgi-bin/koha/labels/label-edit-layout.pl?layout_id=<!-- TMPL_VAR NAME="id" -->">Edit</a>
</td>
<td>
<a href="/cgi-bin/koha/labels/label-home.pl?op=delete_layout&amp;layout_id=<!-- TMPL_VAR NAME="id"-->">Delete</a>
</td>
<td> <!-- TMPL_IF NAME="active" -->
<input type="radio" name="layout_id" value="<!-- TMPL_VAR NAME="id" -->" checked="checked" />
<!-- TMPL_ELSE -->
<input type="radio" name="layout_id" value="<!-- TMPL_VAR NAME="id" -->" />
<!-- /TMPL_IF -->
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<fieldset class="action">
<input type="submit" value="Save" />
<input type="hidden" name="op" value="set_active_layout" /></fieldset>
</form></div>
<div class="yui-u">
<!-- TMPL_INCLUDE NAME="label-status.inc" -->
</div>
</div>
<!-- TMPL_ELSE -->
<!-- TMPL_INCLUDE NAME="label-status.inc" -->
<!-- /TMPL_IF -->
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a>&rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>&rsaquo;
Labels Home
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div class="yui-g">
<!-- TMPL_INCLUDE NAME="labels-toolbar.inc" -->
<div class="yui-u first">
<div class="justify homeimage">
<div class="lci_01"></div>
<div class="lci_02"></div>
<div class="lci_03"></div>
<h2>Welcome to Koha's Label Creator Module</h2>
<p>The Label Creator allow you to use layouts and templates which you design to print a nearly unlimited variety of labels including barcodes. Here are some of the features of the Label Creator module:</p>
<ul>
<li>Customize label layouts</li>
<li>Design custom label templates for printed labels</li>
<li>Build and manage batches of labels</li>
<li>Export single or multiple batches</li>
<li>Export single or multiple labels from within a batch</li>
<li>Export label data in one of three formats:</li>
<ul>
<li>PDF - Readable by any standard PDF reader, making labels printable directly on a printer</li>
<li>CSV - Export label data after your chosen layout is applied allowing labels to be imported in to a variety of applications</li>
<li>XML - Included as an alternate export format</li>
</ul>
</ul>
<p>At the top of each screen within the Label Creator, you will see a toolbar allowing quick access to relevant functions. The menu to the left of each screen also allows easy access to the different sections of the Label Creator. The breadcrumb trail near the top of each screen will give specific indication as to where you are within the Label Creator module and allow quick navigation to previously traversed sections. And finally, you can find more detailed information on each section of the Label Creator by clicking the online help link at the upper left-hand corner of every page.</p>
<p>The developers of the Label Creator module hope you will find this an extremely useful tool in the course of your cataloging work. You are encouraged to submit any enhancement requests as well as any bugs via <a href="http://bugs.koha.org/">Koha Project Bugzilla</a>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -0,0 +1,152 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Manage Label Elements</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="greybox.inc" -->
<!-- Uncomment the following script line to enable firebug lite for use on IE -->
<!-- <script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> -->
<script type="text/JavaScript" language="JavaScript">
//<![CDATA[
function DeleteConfirm() {
var element_id = selected_layout("delete");
if (element_id>-1) {
var msg = "Are you sure you want to delete <!-- TMPL_VAR NAME="label_element" --> " + element_id + "?"
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=<!-- TMPL_VAR NAME="label_element" -->&amp;element_id=" + element_id;
}
else {
return; // abort delete
}
}
else {
return; // no layout selected
};
};
function Edit() {
var element_id = selected_layout("edit");
if (element_id>-1) {
window.location = "/cgi-bin/koha/labels/label-edit-<!-- TMPL_VAR NAME="label_element" -->.pl?op=edit&amp;element_id=" + element_id;
}
else {
return; // no layout selected
};
};
function Xport() {
batches= new Array;
if(document.layouts.action.length > 0) {
for (var i=0; i < document.layouts.action.length; i++) {
if (document.layouts.action[i].checked) {
batches.push("batch_id=" + document.layouts.action[i].value);
}
}
if (batches.length < 1) {
alert("Please select at least one batch to export.");
return; // no batch selected
}
getstr = batches.join("&");
}
else if (document.layouts.action.checked) {
getstr = "batch_id="+document.layouts.action.value;
}
else {
alert("Please select at least one batch to export.");
return; // no batch selected
}
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?" + getstr, 700, 800);
};
function selected_layout(op) {
var selected = new Array;
if (document.layouts.action.length) {
for (i=0;i<document.layouts.action.length;i++){
if (document.layouts.action[i].checked){
selected.push(i);
}
};
if (selected.length == 1) {
return(document.layouts.action[selected[0]].value);
}
else {
alert("Please select only one <!-- TMPL_VAR NAME="label_element" --> to " + op + ".");
return (-1);
}
}
else {
if (document.layouts.action.checked){
return(document.layouts.action.value);
}
};
alert("Please select a <!-- TMPL_VAR NAME="label_element" -->.");
return (-1);
};
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels Home</a> &rsaquo;
Manage Label <!-- TMPL_VAR NAME="label_element_title" -->
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-toolbar.inc" -->
<div class="yui-gc">
<div class="yui-u first" id="manage-label-layouts">
<div class="hint">Current Branch: <!-- TMPL_VAR NAME="LoginBranchname" --></div>
<!-- TMPL_IF NAME="table_loop" -->
<form name="layouts">
<h2>Currently Available <!-- TMPL_VAR NAME="label_element_title" --></h2>
<table>
<!-- TMPL_LOOP NAME="table_loop" -->
<!-- TMPL_IF NAME="header_fields" -->
<tr>
<!-- TMPL_LOOP NAME="header_fields" -->
<th><!-- TMPL_VAR NAME="field_label" --></th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_ELSE -->
<tr>
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="select_field" -->
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
<!-- TMPL_ELSIF NAME="field_value" -->
<td><!-- TMPL_VAR NAME="field_value" --></td>
<!-- TMPL_ELSE -->
<td>&nbsp;</td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</table>
<div style="margin: 10px 10px 10px 0px;">
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="edit" onclick="Edit()" value="Edit"></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="delete" onclick="DeleteConfirm()" value="Delete"></span></span>
<!-- TMPL_IF NAME="print" --><span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="print" onclick="Xport()" value="Export"></span></span><!-- /TMPL_IF -->
</div>
</form>
<!-- TMPL_ELSE -->
<h2>There Are No <!-- TMPL_VAR NAME="label_element_title" --> Currently Available.</h2>
<div class="hint"><h3>Use the toolbar above to create a new <!-- TMPL_VAR NAME="label_element" -->.</h3></div>
<!-- /TMPL_IF -->
</div>
<!-- TMPL_IF NAME="error" -->
<div class="yui-u">
<div class="alert">
<strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="label_element" --> <!-- TMPL_VAR NAME="element_id" --> was not deleted. Please have your system administrator check the error log for details.</strong>
</div>
</div>
<!-- /TMPL_IF -->
</div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -18,7 +18,7 @@
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="batch_id" -->
<!-- TMPL_INCLUDE NAME="tools-labels-batches-toolbar.inc" -->
<!-- TMPL_INCLUDE NAME="labels-batches-toolbar.inc" -->
<div class="yui-g">
<div class="yui-u first">
<!-- TMPL_IF NAME="batch_is_labels" -->
@ -72,7 +72,7 @@
</div>
</div>
<!-- TMPL_ELSE -->
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<!-- TMPL_INCLUDE NAME="labels-toolbar.inc" -->
<!-- TMPL_IF NAME="batch_is_labels" -->
<div class="yui-g">
<div class="yui-u first">

View file

@ -1,181 +1,164 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Print Preview</title>
<style type="text/css" media="screen">
/* need to set print margins for sheet */
body {
margin:48px; /* 1/2" at 96dpi */
/* margin:36px */ /* 1/2" at 72dpi */
}
/*
8 1/2" x 11" sheet size
spine data
1 1/4"H x 1"W
at 96dpi -> 120px H x 96px W
at 72dpi -> 90px H x 72px W
space between cells - 1/2"
at 96dpi -> 48px
at 72dpi -> 36px
circ data
1 1/4"H x 2 7/8"W
at 96dpi -> 120px H x 276px W
at 72dpi -> 90px H x 207px W
*/
table.print-preview {
border-collapse:collapse;
border-spacing:0;
empty-cells: show;
}
.print-preview td {
font-family:arial,helvetica,sans-serif;
font-size:10px;
padding:0 4px 0 4px
}
/* 96dpi */
.spine-label-8511 {
border:dashed 1px #999999;
width: 88px;
height: 112px;
text-align: center
}
.space-8511 {
width:40px
}
.circ-label-8511 {
border:dashed 1px #999999;
width:268px;
text-align: center
}
/* 72dpi
.spine-label-8511 {
border:dashed 1px #999999;
width: 64px;
height: 82px;
text-align: center
}
.space-8511 {
width:28px
}
.circ-label-8511 {
border:dashed 1px #999999;
width:199px;
text-align: center
}
*/
</style>
<style type="text/css" media="print">
/* need to set print margins for sheet */
body {
margin:48px; /* 1/2" at 96dpi */
/* margin:36px */ /* 1/2" at 72dpi */
}
.noprint {
display:none
}
table.print-preview {
border-collapse:collapse;
border-spacing:0;
}
/* need to set printer font size */
.print-preview td {
font-family:arial,helvetica,sans-serif;
font-size:10px;
padding:0 4px 0 4px
}
/* 96dpi */
.spine-label-8511 {
border:dashed 1px #999999;
width: 88px;
height: 112px;
}
.space-8511 {
width:40px;
}
.circ-label-8511 {
border:dashed 1px #999999;
width:268px;
height:112px;
}
/* 72dpi
.spine-label-8511 {
border:none;
width: 64px;
height: 82px;
text-align: center
}
.space-8511 {
width:28px
}
.circ-label-8511 {
border:none;
width:199px;
text-align: left
}
*/
</style>
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Label Printing/Exporting</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/JavaScript" language="JavaScript">
//<![CDATA[
function Done() {
window.location = "<!-- TMPL_VAR NAME="referer" -->";
};
//]]>
</script>
<style type="text/css">#custom-doc {width:47.23em; *width:46.04em; min-width:610px; margin:auto; margin-top:0.4em;}</style>
</head>
<body>
<div class="noprint">
<h3 class="bull">Print Preview<br />
Barcodetype:<!-- TMPL_VAR NAME="barcodetype_opt" --><br />
Papertype:<!-- TMPL_VAR NAME="papertype_opt" --><br />
Field Options: <!-- TMPL_IF NAME="author_opt" -->Author <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="itemtype_opt" -->Itemtype <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="title_opt" -->Title <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="isbn_opt" -->ISBN <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="dewey_opt" -->Dewey <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="class_opt" -->Class<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="subclass_opt" -->Subclass<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="itemcallnumber_opt" -->Itemcallnumber<!-- /TMPL_IF -->
</h3>
</div>
<table summary="print preview" class="print-preview">
<!-- TMPL_LOOP NAME="resultsloop" -->
<tr>
<td class="spine-label-8511">
<!-- TMPL_IF NAME="itemtype_opt" --><!-- TMPL_VAR NAME="itemtype" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="papertype_opt" --><!-- TMPL_VAR NAME="papertype" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="author_opt" --><!-- TMPL_VAR NAME="author" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="title_opt" --><!-- TMPL_VAR NAME="title" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="isbn_opt" --><!-- TMPL_VAR NAME="isbn" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="dewey_opt" --><!-- TMPL_VAR NAME="dewey" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="class_opt" --><!-- TMPL_VAR NAME="class" --><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="subclass_opt" --><!-- TMPL_VAR NAME="subclass" --><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="itemcallnumber_opt" --><!-- TMPL_VAR NAME="itemcallnumber" --><!-- /TMPL_IF -->
</td>
<td class="space-8511">&nbsp;</td>
<td class="circ-label-8511">
<img src="/intranet-tmpl/barcodes/<!-- TMPL_VAR NAME="barcodetype_opt" -->-<!-- TMPL_VAR NAME="barcode" -->.png">
<!-- TMPL_IF NAME="barcodeerror" -->
<div class="noprint">'<!-- TMPL_VAR NAME="barcode" -->'<br />
not '<!-- TMPL_VAR NAME="barcodetype_opt" -->' format.</div>
<!-- /TMPL_IF -->
</td>
<td class="space-8511">&nbsp;</td>
<td class="circ-label-8511">
<img src="/intranet-tmpl/barcodes/<!-- TMPL_VAR NAME="barcodetype_opt" -->-<!-- TMPL_VAR NAME="barcode" -->.png">
<!-- TMPL_IF NAME="barcodeerror" -->
<div class="noprint">'<!-- TMPL_VAR NAME="barcode" -->'<br />
not '<!-- TMPL_VAR NAME="barcodetype_opt" -->' format.</div>
<!-- /TMPL_IF -->
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<div class="noprint"><br />
<a href="/cgi-bin/koha/barcodes/label-manager.pl"
class="button">Back</a> &nbsp;
<a href="/cgi-bin/koha/barcodes/label-print-pdf.pl" class="button">Print</a> &nbsp;
</div>
</body>
</html>
<div id="custom-doc" class="yui-t2">
<div id="bd">
<!-- TMPL_IF NAME="batches" -->
<form>
<div align="center">
<div class="message">
<b>Click on the following link(s) to download the exported batch(es).</b>
</div>
</div>
<fieldset class="rows">
<table class="borderless">
<!-- TMPL_LOOP NAME="batches" -->
<tr>
<!-- TMPL_IF NAME="label_ids" -->
<td class="borderless">
<!-- TMPL_VAR NAME="label_count" --> Single Labels
</td>
<td class="borderless">
<h1 id="pdf">
<a href="/cgi-bin/koha/labels/<!-- TMPL_VAR NAME="create_script" -->?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" -->&amp;start_label=<!-- TMPL_VAR NAME="start_label" --><!-- TMPL_VAR NAME="label_ids" -->">label_single_<!-- TMPL_VAR NAME="label_count" -->.pdf</a>
</h1>
</td>
<td class="borderless">
<h1 id="csv">
<a href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" --><!-- TMPL_VAR NAME="label_ids" -->">label_single_<!-- TMPL_VAR NAME="label_count" -->.csv</a>
</h1>
</td>
<td class="borderless">
<h1 id="xml">
<a href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" --><!-- TMPL_VAR NAME="label_ids" -->">label_single_<!-- TMPL_VAR NAME="label_count" -->.xml</a>
</h1>
</td>
<!-- TMPL_ELSIF NAME="item_numbers" -->
<td class="borderless">
<!-- TMPL_VAR NAME="label_count" --> Single Labels
</td>
<td class="borderless">
<h1 id="pdf">
<a href="/cgi-bin/koha/labels/<!-- TMPL_VAR NAME="create_script" -->?template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" -->&amp;start_label=<!-- TMPL_VAR NAME="start_label" --><!-- TMPL_VAR NAME="item_numbers" -->">label_single_<!-- TMPL_VAR NAME="label_count" -->.pdf</a>
</h1>
</td>
<td class="borderless">
<h1 id="csv">
<a href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" --><!-- TMPL_VAR NAME="item_numbers" -->">label_single_<!-- TMPL_VAR NAME="label_count" -->.csv</a>
</h1>
</td>
<td class="borderless">
<h1 id="xml">
<a href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" --><!-- TMPL_VAR NAME="item_numbers" -->">label_single_<!-- TMPL_VAR NAME="label_count" -->.xml</a>
</h1>
</td>
<!-- TMPL_ELSE -->
<td class="borderless">
Label Batch Number <!-- TMPL_VAR NAME="batch_id" -->
</td>
<td class="borderless">
<h1 id="pdf">
<a href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" -->&amp;start_label=<!-- TMPL_VAR NAME="start_label" -->">label_batch_<!-- TMPL_VAR NAME="batch_id" -->.pdf</a>
</h1>
</td>
<td class="borderless">
<h1 id="csv">
<a href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" -->">label_batch_<!-- TMPL_VAR NAME="batch_id" -->.csv</a>
</h1>
</td>
<td class="borderless">
<h1 id="xml">
<a href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;template_id=<!-- TMPL_VAR NAME="template_id" -->&amp;layout_id=<!-- TMPL_VAR NAME="layout_id" -->">label_batch_<!-- TMPL_VAR NAME="batch_id" -->.xml</a>
</h1>
</td>
<!-- /TMPL_IF -->
</tr>
<!-- /TMPL_LOOP -->
</table>
</fieldset>
<fieldset class="action">
<div style="margin: 10px 10px 10px 0px;">
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="done" onclick="parent.parent.GB_hide();" value="Done"></span></span>
</div>
</fieldset>
</form>
<!-- TMPL_ELSE -->
<div align="center">
<div class="message">
<!-- TMPL_IF NAME="label_ids" -->
<b>Exporting <!-- TMPL_VAR NAME="label_count" --> label(s).</b>
<!-- TMPL_ELSIF NAME="item_numbers"-->
<b>Exporting <!-- TMPL_VAR NAME="item_count" --> label(s).</b>
<!-- TMPL_ELSE -->
<b><!-- TMPL_VAR NAME="multi_batch_count" --> batch(es) to export.</b>
<!-- /TMPL_IF -->
</div>
</div>
<form name="exporting" method="post" action="/cgi-bin/koha/labels/label-print.pl">
<input type="hidden" name="op" value="export" />
<input type="hidden" name="referer" value="<!-- TMPL_VAR NAME="referer" -->" />
<!-- TMPL_LOOP NAME="batch_ids" -->
<input type="hidden" name="batch_id" value="<!-- TMPL_VAR NAME="batch_id" -->" />
<!-- /TMPL_LOOP -->
<!-- TMPL_LOOP NAME="label_ids" -->
<input type="hidden" name="label_id" value="<!-- TMPL_VAR NAME="label_id" -->" />
<!-- /TMPL_LOOP -->
<!-- TMPL_LOOP NAME="item_numbers" -->
<input type="hidden" name="item_number" value="<!-- TMPL_VAR NAME="item_number" -->" />
<!-- /TMPL_LOOP -->
<fieldset class="rows">
<table class="borderless">
<tr>
<td class="borderless">
<label for="template">Select a template to be applied: </label>
</td>
<td class="borderless">
<select name="template_id">
<!-- TMPL_LOOP NAME="templates" -->
<option value="<!-- TMPL_VAR NAME="template_id" -->"><!-- TMPL_VAR NAME="template_code" --></option>
<!-- /TMPL_LOOP -->
</select>
</td>
</tr>
<tr>
<td class="borderless">
<label for="layout">Select a layout to be applied: </label>
</td>
<td class="borderless">
<select name="layout_id">
<!-- TMPL_LOOP NAME="layouts" -->
<option value="<!-- TMPL_VAR NAME="layout_id" -->"><!-- TMPL_VAR NAME="layout_name" --></option>
<!-- /TMPL_LOOP -->
</select>
</td>
</tr>
<tr>
<td class="borderless">
<label for="start_label">Enter starting label number: </label>
</td>
<td class="borderless">
<input type="text" size="5" id="start_label" name="start_label" class="focus" title="Starting label number" value="1"/>
</td>
</tr>
</table>
</fieldset>
<fieldset class="action">
<div style="margin: 10px 10px 10px 0px;">
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Export" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="done" onclick="parent.parent.GB_hide();" value="Cancel"></span></span>
</div>
</fieldset>
</form>
<!-- /TMPL_IF -->
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,98 +0,0 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript">
//<![CDATA[
function confirm_deletion(prof_id) {
var original = $("#row"+prof_id).attr("class");
$("#row"+prof_id).attr("class","confirm");
var is_confirmed = confirm(_('Are you sure you want to delete this item?'));
if (is_confirmed) {
window.location = "label-profiles.pl?op=delete&amp;prof_id="+prof_id;
} else {
$("#row"+prof_id).attr("class","");
}
}
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>&rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; Printer Profiles</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<div class="yui-g">
<div class="yui-u first">
<h2>Printer Profiles</h2>
<form name="input" action="/cgi-bin/koha/labels/label-profiles.pl" method="get">
<!-- TMPL_IF NAME="resultsloop" -->
<table>
<tr>
<th>Printer Name</th>
<th>Paper Bin</th>
<th>Template Name</th>
<th>Offset-Horizontal</th>
<th>Offset-Vertical</th>
<th>Creep-Horizontal</th>
<th>Creep-Vertical</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<!-- TMPL_LOOP NAME="resultsloop" -->
<tr>
<td>
<!-- TMPL_VAR NAME="printername" -->
</td>
<td>
<!-- TMPL_VAR NAME="paper_bin" -->
</td>
<td>
<!-- TMPL_VAR NAME="tmpl_code" -->
</td>
<td>
<!-- TMPL_VAR NAME="offset_horz" -->
</td>
<td>
<!-- TMPL_VAR NAME="offset_vert" -->
</td>
<td>
<!-- TMPL_VAR NAME="creep_horz" -->
</td>
<td>
<!-- TMPL_VAR NAME="creep_vert" -->
</td>
<td>
<a href="/cgi-bin/koha/labels/label-edit-profile.pl?prof_id=<!-- TMPL_VAR NAME="prof_id" -->">Edit</a>
</td>
<td>
<a href="/cgi-bin/koha/labels/label-profiles.pl?" onclick="confirm_deletion(<!-- TMPL_VAR NAME="prof_id" -->); return false;">Delete</a>
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
</form>
<!-- TMPL_ELSE -->
No Printer Profiles currently defined.
</form>
<!-- /TMPL_IF -->
</div>
<div class="yui-u">
<!-- TMPL_INCLUDE NAME="label-status.inc" -->
</div>
</div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,72 +0,0 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo; Label Templates </div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-labels-toolbar.inc" -->
<div class="yui-g">
<div class="yui-u first">
<!-- TMPL_IF NAME="resultsloop" -->
<h2>Templates</h2>
<form name="input" action="/cgi-bin/koha/labels/label-templates.pl" method="get">
<table>
<tr>
<th>Template Code</th>
<th>Description</th>
<th>Edit</th>
<th>Delete</th>
<th>Active</th>
</tr>
<!-- TMPL_LOOP NAME="resultsloop" -->
<tr>
<td>
<!-- TMPL_VAR NAME="tmpl_code" -->
</td>
<td>
<!-- TMPL_VAR NAME="tmpl_desc" -->
</td>
<td>
<a href="/cgi-bin/koha/labels/label-edit-template.pl?tmpl_id=<!-- TMPL_VAR NAME="tmpl_id" -->">Edit</a>
</td>
<td>
<a href="/cgi-bin/koha/labels/label-templates.pl?op=delete&amp;tmpl_id=<!-- TMPL_VAR NAME="tmpl_id" -->">Delete</a>
</td>
<td>
<!-- TMPL_IF NAME="active" -->
<input type="radio" name="tmpl_id" value="<!-- TMPL_VAR NAME="tmpl_id" -->" checked="checked" />
<!-- TMPL_ELSE -->
<input type="radio" name="tmpl_id" value="<!-- TMPL_VAR NAME="tmpl_id" -->" />
<!-- /TMPL_IF -->
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<fieldset class="action">
<input class="button" type="submit" value="Set Active Template" />
<input type="hidden" name="op" value="set_active_template" /></fieldset>
</form>
<!-- /TMPL_IF -->
</div>
<div class="yui-u">
<!-- TMPL_INCLUDE NAME="label-status.inc" -->
</div>
</div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -1,143 +1,141 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Barcodes and Labels &rsaquo; Search Results</title><!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<style type="text/css">#custom-doc { width:46.23em;*width:45.04em;min-width:610px; margin:auto;margin-top: .4em; text-align:left; }</style>
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("#CheckAll").click(function(){
$(".checkboxed").checkCheckboxes();
return false;
});
$("#CheckNone").click(function(){
$(".checkboxed").unCheckCheckboxes();
return false;
});
});
function add_item(itemnum,batch_id,type_id){
var getstr='';
if (itemnum == 'checked') {
itms= new Array;
if(document.resultform.i_itemnumber.length > 0) {
for (var i=0; i < document.resultform.i_itemnumber.length; i++) {
if (document.resultform.i_itemnumber[i].checked) {
itms.push("itemnumber=" + document.resultform.i_itemnumber[i].value);
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Barcodes and Labels &rsaquo; Search Results</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<style type="text/css">#custom-doc { width:46.23em;*width:45.04em;min-width:700px; margin:auto;margin-top: .4em; text-align:left; }</style>
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("#CheckAll").click(function(){
$(".checkboxed").checkCheckboxes();
return false;
});
$("#CheckNone").click(function(){
$(".checkboxed").unCheckCheckboxes();
return false;
});
});
function add_item(item_number,batch_id,type_id){
var getstr='';
if (item_number == 'checked') {
items= new Array;
if(document.resultform.action.length > 0) {
for (var i=0; i < document.resultform.action.length; i++) {
if (document.resultform.action[i].checked) {
items.push("item_number=" + document.resultform.action[i].value);
}
}
getstr = items.join("&");
} else {
getstr = "item_number="+document.resultform.action.value;
}
}
else {
getstr = "item_number="+item_number;
}
var myurl = "label-edit-batch.pl?op=add&batch_id="+batch_id+
"&"+getstr;
window.opener.location.href = myurl;
//top.location.href=myurl;
}
}
getstr = itms.join("&");
} else {
getstr = "itemnumber="+document.resultform.i_itemnumber.value;
}
} else {
getstr = "itemnumber="+itemnum;
}
var myurl = "label-manager.pl?op=add&batch_id="+batch_id+
// "&type="+type_id+ // The template variable NAME="TYPE" is RESERVED ('opac' or 'intranet').
"&"+getstr;
window.opener.location.href = myurl;
}
function add_item3(i_itemnumber){
var myurl = "label-manager.pl?op=add&itemnumber="+i_itemnumber+"";
window.opener.location.href = myurl;
}
//]]>
</script>
//]]>
</script>
</head>
<body>
<div id="custom-doc" class="yui-t7">
<div id="bd">
<h1>Search results</h1>
<div class="results">
<!-- TMPL_IF EXPR="displayprev || displaynext" --><p>
<!-- TMPL_IF NAME="displayprev" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&lt;&lt;</a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME="numbers" -->
<!-- TMPL_IF NAME="highlight" -->
<span class="current"><!-- TMPL_VAR NAME="number" --></span>
<!-- TMPL_ELSE -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME="displaynext" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&gt;&gt;</a>
<!-- /TMPL_IF -->
</p><!-- /TMPL_IF -->
<!-- TMPL_IF name="result" -->
<strong>Results <!-- TMPL_VAR name="from" --> through <!-- TMPL_VAR name="to" --> <!-- TMPL_IF NAME="total" --> of <!-- TMPL_VAR name="total" --><!-- /TMPL_IF --></strong>
<!-- TMPL_ELSE -->
No results found
<!-- /TMPL_IF -->
</div>
<div id="breadcrumbs"><a href="/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->">Search for Items for Batch <!-- TMPL_VAR NAME="batch_id" --></a> &rsaquo; Search results</div>
<form name="resultform" class="checkboxed" action=""><div style="float: right; margin-top: .5em;"><input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',<!-- TMPL_VAR NAME="batch_id" -->,'<!-- TMPL_VAR NAME="type" -->'); return false" /> <input type="button" class="close" value="Done" /></div><div style="line-height: 2em; margin-left: .7em;"><a id="CheckAll" href="/cgi-bin/koha/labels/label-item-search.pl">Select All</a><span class="clearall"><a id="CheckNone" href="/cgi-bin/koha/labels/label-item-search.pl">Clear All</a></span></div>
<input type="hidden" name="ccl_query" value="<!-- TMPL_VAR name="ccl_query" -->" />
<!-- TMPL_LOOP name="result" -->
<table frame="border" border="2" style="float: left; margin: .5em 0;">
<!-- TMPL_IF name="highlight" -->
<tr class="highlight">
<!-- TMPL_ELSE -->
<tr>
<!-- /TMPL_IF -->
<td colspan="5">
<label style="font-weight:bold;"><!-- TMPL_VAR NAME="title" escape="html" --></label> by <!-- TMPL_VAR NAME="author" --><br />
[<!-- TMPL_VAR NAME="itemtype" -->], <!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --><!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="copyrightdate" --><!-- TMPL_VAR name="copyrightdate" -->, <!-- /TMPL_IF --><!-- TMPL_IF name="pages" --><!-- TMPL_VAR name="pages" --><!-- /TMPL_IF --><!-- TMPL_IF name="isbn" -->, <b>ISBN: </b><!-- TMPL_VAR name="isbn" --><!-- /TMPL_IF --><!-- TMPL_IF name="notes" -->,<br /><!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
<div id="custom-doc" class="yui-t7">
<div id="bd">
<h1>Search results</h1>
<div class="results">
<!-- TMPL_IF EXPR="displayprev || displaynext" -->
<p>
<!-- TMPL_IF NAME="displayprev" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&lt;&lt;</a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME="numbers" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME="displaynext" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&gt;&gt;</a>
<!-- /TMPL_IF -->
</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="results" -->
<strong>Results <!-- TMPL_VAR name="from" --> through <!-- TMPL_VAR name="to" --> <!-- TMPL_IF NAME="total" --> of <!-- TMPL_VAR name="total" --><!-- /TMPL_IF --></strong>
<!-- TMPL_ELSE -->
No results found
<!-- /TMPL_IF -->
</div>
<div id="breadcrumbs">
<a href="/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->">Search for Items for Batch <!-- TMPL_VAR NAME="batch_id" --></a> &rsaquo;
Search results
</div>
<form name="resultform" class="checkboxed" action="">
<div style="float: right; margin-top: .5em; margin-left: .7em; margin-bottom: .7em">
<input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',<!-- TMPL_VAR NAME="batch_id" -->,'<!-- TMPL_VAR NAME="type" -->'); return false" />
<input type="button" class="close" value="Done" />
</div>
<div style="float: left; margin-top: .5em; margin-right: .7em; margin-bottom: .7em">
<input id="CheckAll" type="submit" class="icon checkall" value="Check All" onclick="return false" />
<!--<a id="CheckAll" href="/cgi-bin/koha/labels/label-item-search.pl">Select All</a>-->
<input id="CheckNone" type="submit" class="icon checknone" value="Clear All" onclick="return false" />
<!--<a id="CheckNone" href="/cgi-bin/koha/labels/label-item-search.pl">Clear All</a>-->
</div>
<div style="padding-top: 0.7em;">
<input type="hidden" name="ccl_query" value="<!-- TMPL_VAR name="ccl_query" -->" />
<!-- TMPL_LOOP name="result_set" -->
<table id="label-search-results" frame="border" border="2">
<tr>
<td colspan="5">
<label style="font-weight:bold;"><!-- TMPL_VAR NAME="title" --></label>
by <!-- TMPL_VAR NAME="author" --><br />
[<!-- TMPL_VAR NAME="itemtype" -->], <!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --><!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="copyrightdate" --><!-- TMPL_VAR name="copyrightdate" -->, <!-- /TMPL_IF --><!-- TMPL_IF name="pages" --><!-- TMPL_VAR name="pages" --><!-- /TMPL_IF --><!-- TMPL_IF name="isbn" -->, <b>ISBN: </b><!-- TMPL_VAR name="isbn" --><!-- /TMPL_IF --><!-- TMPL_IF name="notes" -->,<br /><!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
</td>
</tr>
<!-- NEW -->
<tr>
<th>Select</th>
<th>Item Call Number</th>
<th>Date Accessioned</th>
<th>Barcode</th>
<th></th>
</tr>
<!-- TMPL_IF name="item" -->
<!-- TMPL_LOOP name="item" -->
<!-- TMPL_IF name="i_itemnumber1" --><tr><td align="center"><label for="itm<!-- TMPL_VAR NAME="i_itemnumber1" -->" ><input type="checkbox" name="i_itemnumber" id="itm<!-- TMPL_VAR NAME="i_itemnumber1" -->" value="<!-- TMPL_VAR NAME="i_itemnumber1" -->" /></label></td><!-- /TMPL_IF -->
<!-- TMPL_IF name="i_itemcallnumber" --><td align="center"><!-- TMPL_VAR name="i_itemcallnumber" --><br /></td><!-- /TMPL_IF -->
<!-- TMPL_IF name="i_dateaccessioned" --><td align="center"><!-- TMPL_VAR name="i_dateaccessioned" --><br /></td><!-- /TMPL_IF -->
<!-- TMPL_IF name="i_barcode" --><td align="center"><!-- TMPL_VAR name="i_barcode" --></td><!-- /TMPL_IF -->
<!-- TMPL_IF name="i_itemnumber2" --><td align="center">
<a onclick="add_item('<!-- TMPL_VAR NAME="i_itemnumber2" -->',<!-- TMPL_VAR NAME="batch_id" -->, '<!-- TMPL_VAR NAME="type" -->'); return false" href="/cgi-bin/koha/barcodes/label-manager.pl?itemnumber=<!-- TMPL_VAR NAME="i_itemnumber2" -->&amp;batch_id=<!-- TMPL_VAR name="batch_id" -->&amp;op=add">Add</a></td></tr>
<!-- /TMPL_IF -->
<!-- /NEW -->
<!-- /TMPL_LOOP --><!-- item -->
<!-- /TMPL_IF -->
</table>
<!-- /TMPL_LOOP -->
</form>
</div>
</tr>
<!-- TMPL_LOOP NAME="item_table" -->
<!-- TMPL_IF NAME="header_fields" -->
<tr>
<!-- TMPL_LOOP NAME="header_fields" -->
<th><!-- TMPL_VAR NAME="field_label" --></th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_ELSE -->
<tr>
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="select_field" -->
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
<!-- TMPL_ELSIF NAME="link_field" -->
<td align="center">
<a onclick="add_item('<!-- TMPL_VAR NAME="field_value" -->',<!-- TMPL_VAR NAME="batch_id" -->, '<!-- TMPL_VAR NAME="type" -->'); return false" href="/cgi-bin/koha/barcodes/label-edit-batch.pl?op=add&amp;batch_id=<!-- TMPL_VAR name="batch_id" -->&amp;item_number=<!-- TMPL_VAR NAME="field_value" -->">Add</a>
</td>
<!-- TMPL_ELSE -->
<td align="center"><!-- TMPL_VAR NAME="field_value" --></td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</table>
<!-- /TMPL_LOOP -->
</div>
</form>
</div>
<div class="results">
<!-- TMPL_IF EXPR="displayprev || displaynext" --><p>
<!-- TMPL_IF NAME="displayprev" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&lt;&lt;</a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME="numbers" -->
<!-- TMPL_IF NAME="highlight" -->
<span class="current"><!-- TMPL_VAR NAME="number" --></span>
<!-- TMPL_ELSE -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME="displaynext" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&gt;&gt;</a>
<!-- /TMPL_IF -->
</p><!-- /TMPL_IF -->
<!-- TMPL_IF EXPR="displayprev || displaynext" -->
<p>
<!-- TMPL_IF NAME="displayprev" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&lt;&lt;</a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME="numbers" -->
<!-- TMPL_IF NAME="highlight" -->
<span class="current"><!-- TMPL_VAR NAME="number" --></span>
<!-- TMPL_ELSE -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME="displaynext" -->
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&amp;ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&amp;resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&amp;op=do_search&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">&gt;&gt;</a>
<!-- /TMPL_IF -->
</p>
<!-- /TMPL_IF -->
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -37,9 +37,13 @@
&rsaquo; Batch <!-- TMPL_VAR name="import_batch_id" -->
<!-- /TMPL_IF -->
</h1>
<!-- TMPL_IF name="label_batch" -->
<div class="dialog message">
<p>Label batch created, with id: <!-- TMPL_VAR name="label_batch" --> </p>
<!-- TMPL_IF name="label_batch_msg" -->
<!-- TMPL_IF name="alert" -->
<div class="alert">
<!-- TMPL_ELSE -->
<div class="dialog">
<!-- /TMPL_IF -->
<b><p><!-- TMPL_VAR name="label_batch_msg" --></p></b>
</div>
<!-- /TMPL_IF -->

View file

@ -20,13 +20,14 @@
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_tools_label_creator" -->
<dt><a href="/cgi-bin/koha/labels/label-home.pl">Label and Patron Card Creator</a></dt>
<dd>Create printable labels and barcodes from catalog data and patron cards from patron data</dd>
<dt><a href="/cgi-bin/koha/labels/label-home.pl">Label Creator</a></dt>
<dd>Create printable labels and barcodes from catalog data</dd>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_tools_label_creator" -->
<dt><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick Spine Label Creator</a></dt>
<dd>Enter a barcode to generate a printable spine label</dd>
<div class="hint"><dd>For use with dedicated label printers</dd></div>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="CAN_user_tools_edit_calendar" -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

View file

@ -10,7 +10,7 @@
use strict;
sub kohaversion {
our $VERSION = '3.01.00.052';
our $VERSION = '3.01.00.053';
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install

110
labels/label-create-csv.pl Executable file
View file

@ -0,0 +1,110 @@
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use Text::CSV_XS;
use Data::Dumper;
use C4::Debug;
use C4::Labels::Batch 1.000000;
use C4::Labels::Template 1.000000;
use C4::Labels::Layout 1.000000;
use C4::Labels::PDF 1.000000;
use C4::Labels::Label 1.000000;
=head
=cut
my $cgi = new CGI;
my $batch_id = $cgi->param('batch_id') if $cgi->param('batch_id');
my $template_id = $cgi->param('template_id') || undef;
my $layout_id = $cgi->param('layout_id') || undef;
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
my $items = undef;
my $csv_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
print $cgi->header(-type => 'application/vnd.sun.xml.calc',
-encoding => 'utf-8',
-attachment => "$csv_file.csv",
);
my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
my $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
my $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
if (@label_ids) {
my $batch_items = $batch->get_attr('items');
grep {
my $label_id = $_;
push(@{$items}, grep{$_->{'label_id'} == $label_id;} @{$batch_items});
} @label_ids;
}
elsif (@item_numbers) {
grep {
push(@{$items}, {item_number => $_});
} @item_numbers;
}
else {
$items = $batch->get_attr('items');
}
my $csv = Text::CSV_XS->new();
CSV_ITEMS:
foreach my $item (@$items) {
my $label = C4::Labels::Label->new(
batch_id => $batch_id,
item_number => $item->{'item_number'},
format_string => $layout->get_attr('format_string'),
);
my $csv_fields = $label->csv_data();
if ($csv->combine(@$csv_fields)) {
print $csv->string() . "\n";
}
else {
warn sprintf('Text::CSV_XS->combine() returned the following error: %s', $csv->error_input);
next CSV_ITEMS;
}
}
exit(1);
=head1 NAME
labels/label-create-csv.pl - A script for creating a csv export of labels and label batches in Koha
=head1 ABSTRACT
This script provides the means of producing a csv of labels for items either individually, in groups, or in batches from within Koha.
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.

View file

@ -1,73 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Output;
use C4::Labels;
use C4::Context;
use HTML::Template::Pro;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-create-layout.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $data = get_label_options();
my $op = $query->param('op');
my $layout_id = $query->param('layout_id');
my $active_template = GetActiveLabelTemplate();
my @label_templates = GetAllLabelTemplates();
my @printingtypes = get_printingtypes();
my @layouts = get_layouts();
my @barcode_types = get_barcode_types();
my @batches = get_batches();
my @barcode_types = get_barcode_types($layout_id);
my @printingtypes = get_printingtypes($layout_id);
my $layout;
$layout = get_layout($layout_id) if($layout_id);
$template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
$template->param( "papertype_$data->{'papertype'}" => 1 );
$template->param( "$data->{'barcodetype'}_checked" => 1 );
$template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 );
$template->param(
op => $op,
active_template => $data->{'active_template'},
label_templates => \@label_templates,
barcode_types => \@barcode_types,
printingtypes => \@printingtypes,
layout_loop => \@layouts,
batches => \@batches,
id => $data->{'id'},
barcodetype => $data->{'barcodetype'},
papertype => $data->{'papertype'},
tx_author => $data->{'author'},
tx_barcode => $data->{'barcode'},
tx_title => $data->{'title'},
tx_subtitle => $data->{'subtitle'},
tx_isbn => $data->{'isbn'},
tx_issn => $data->{'issn'},
tx_itemtype => $data->{'itemtype'},
tx_dewey => $data->{'dewey'},
tx_class => $data->{'class'},
tx_subclass => $data->{'subclass'},
tx_itemcallnumber => $data->{'itemcallnumber'},
startlabel => $data->{'startlabel'},
fontsize => $active_template->{'fontsize'},
);
output_html_with_http_headers $query, $cookie, $template->output;

225
labels/label-create-pdf.pl Executable file
View file

@ -0,0 +1,225 @@
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use C4::Debug;
use C4::Labels::Batch 1.000000;
use C4::Labels::Template 1.000000;
use C4::Labels::Layout 1.000000;
use C4::Labels::PDF 1.000000;
use C4::Labels::Label 1.000000;
my $cgi = new CGI;
my $batch_id = $cgi->param('batch_id') if $cgi->param('batch_id');
my $template_id = $cgi->param('template_id') || undef;
my $layout_id = $cgi->param('layout_id') || undef;
my $start_label = $cgi->param('start_label') || 1;
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
my $items = undef;
my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
print $cgi->header( -type => 'application/pdf',
-encoding => 'utf-8',
-attachment => "$pdf_file.pdf",
);
my $pdf = C4::Labels::PDF->new(InitVars => 0);
my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
my $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
my $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
sub _calc_next_label_pos {
my ($row_count, $col_count, $llx, $lly) = @_;
if ($col_count lt $template->get_attr('cols')) {
$llx = ($llx + $template->get_attr('label_width') + $template->get_attr('col_gap'));
$col_count++;
}
else {
$llx = $template->get_attr('left_margin');
if ($row_count eq $template->get_attr('rows')) {
$pdf->Page();
$lly = ($template->get_attr('page_height') - $template->get_attr('top_margin') - $template->get_attr('label_height'));
$row_count = 1;
}
else {
$lly = ($lly - $template->get_attr('row_gap') - $template->get_attr('label_height'));
$row_count++;
}
$col_count = 1;
}
return ($row_count, $col_count, $llx, $lly);
}
sub _print_text {
my $label_text = shift;
foreach my $text_line (@$label_text) {
my $pdf_font = $pdf->Font($text_line->{'font'});
my $line = "BT /$pdf_font $text_line->{'font_size'} Tf $text_line->{'text_llx'} $text_line->{'text_lly'} Td ($text_line->{'line'}) Tj ET";
$pdf->Add($line);
}
}
$| = 1;
# set the paper size
my $lowerLeftX = 0;
my $lowerLeftY = 0;
my $upperRightX = $template->get_attr('page_width');
my $upperRightY = $template->get_attr('page_height');
$pdf->Compress(1);
$pdf->Mbox($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
my ($row_count, $col_count, $llx, $lly) = $template->get_label_position($start_label);
if (@label_ids) {
my $batch_items = $batch->get_attr('items');
grep {
my $label_id = $_;
push(@{$items}, grep{$_->{'label_id'} == $label_id;} @{$batch_items});
} @label_ids;
}
elsif (@item_numbers) {
grep {
push(@{$items}, {item_number => $_});
} @item_numbers;
}
else {
$items = $batch->get_attr('items');
}
LABEL_ITEMS:
foreach my $item (@{$items}) {
my ($barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor) = 0,0,0,0;
if ($layout->get_attr('printing_type') eq 'ALT') { # we process the ALT style printing type here because it is not an atomic printing type
my $label_a = C4::Labels::Label->new(
batch_id => $batch_id,
item_number => $item->{'item_number'},
llx => $llx,
lly => $lly,
width => $template->get_attr('label_width'),
height => $template->get_attr('label_height'),
top_text_margin => $template->get_attr('top_text_margin'),
left_text_margin => $template->get_attr('left_text_margin'),
barcode_type => $layout->get_attr('barcode_type'),
printing_type => 'BIB',
guidebox => $layout->get_attr('guidebox'),
font => $layout->get_attr('font'),
font_size => $layout->get_attr('font_size'),
callnum_split => $layout->get_attr('callnum_split'),
justify => $layout->get_attr('text_justify'),
format_string => $layout->get_attr('format_string'),
text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
);
my $label_a_text = $label_a->create_label();
_print_text($label_a_text);
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
my $label_b = C4::Labels::Label->new(
batch_id => $batch_id,
item_number => $item->{'item_number'},
llx => $llx,
lly => $lly,
width => $template->get_attr('label_width'),
height => $template->get_attr('label_height'),
top_text_margin => $template->get_attr('top_text_margin'),
left_text_margin => $template->get_attr('left_text_margin'),
barcode_type => $layout->get_attr('barcode_type'),
printing_type => 'BAR',
guidebox => $layout->get_attr('guidebox'),
font => $layout->get_attr('font'),
font_size => $layout->get_attr('font_size'),
callnum_split => $layout->get_attr('callnum_split'),
justify => $layout->get_attr('text_justify'),
format_string => $layout->get_attr('format_string'),
text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
);
my $label_b_text = $label_b->create_label();
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
next LABEL_ITEMS;
}
else {
}
my $label = C4::Labels::Label->new(
batch_id => $batch_id,
item_number => $item->{'item_number'},
llx => $llx,
lly => $lly,
width => $template->get_attr('label_width'),
height => $template->get_attr('label_height'),
top_text_margin => $template->get_attr('top_text_margin'),
left_text_margin => $template->get_attr('left_text_margin'),
barcode_type => $layout->get_attr('barcode_type'),
printing_type => $layout->get_attr('printing_type'),
guidebox => $layout->get_attr('guidebox'),
font => $layout->get_attr('font'),
font_size => $layout->get_attr('font_size'),
callnum_split => $layout->get_attr('callnum_split'),
justify => $layout->get_attr('text_justify'),
format_string => $layout->get_attr('format_string'),
text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
);
my $label_text = $label->create_label();
_print_text($label_text) if $label_text;
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
next LABEL_ITEMS;
}
$pdf->End();
exit(1);
=head1 NAME
labels/label-create-pdf.pl - A script for creating a pdf export of labels and label batches in Koha
=head1 ABSTRACT
This script provides the means of producing a pdf of labels for items either individually, in groups, or in batches from within Koha.
=head1 USAGE
This script is intended to be called as a cgi script although it could be easily modified to accept command line parameters. The script accepts four single
parameters and two "multiple" parameters as follows:
C<batch_id> A single valid batch id to export.
C<template_id> A single valid template id to be applied to the current export. This parameter is manditory.
C<layout_id> A single valid layout id to be applied to the current export. This parameter is manditory.
C<start_label> The number of the label on which to begin the export. This parameter is optional.
C<lable_ids> A single valid label id to export. Multiple label ids may be submitted to export multiple labels.
C<item_numbers> A single valid item number to export. Multiple item numbers may be submitted to export multiple items.
B<NOTE:> One of the C<batch_id>, C<label_ids>, or C<item_number> parameters is manditory. However, do not pass a combination of them or bad things might result.
example:
http://staff-client.kohadev.org/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=1&template_id=1&layout_id=5&start_label=1
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.
=cut

View file

@ -1,103 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
use Data::Dumper;
#use Smart::Comments;
my $dbh = C4::Context->dbh;
my $query = new CGI;
### $query
my $op = $query->param('op');
my $prof_id = $query->param('prof_id');
my $printername = $query->param('printername');
my $paper_bin = $query->param('paper_bin');
my $tmpl_id = $query->param('tmpl_id');
my $offset_horz = $query->param('offset_horz');
my $offset_vert = $query->param('offset_vert');
my $creep_horz = $query->param('creep_horz');
my $creep_vert = $query->param('creep_vert');
my $units = $query->param('unit');
my @resultsloop;
my @tmpllist;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-create-profile.tmpl",
query => $query,
type => "intranet",
authnotrequired => 1,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
if ( $op eq 'blank' || $op eq '' ) {
my @units = (
{ unit => 'INCH', desc => 'Inches' },
{ unit => 'CM', desc => 'Centimeters' },
{ unit => 'MM', desc => 'Millimeters' },
{ unit => 'POINT', desc => 'Postscript Points' },
);
my @tmpl = GetAllLabelTemplates();
foreach my $data (@tmpl) {
push ( @tmpllist, {tmpl_id => $data->{'tmpl_id'},
tmpl_code => $data->{'tmpl_code'}} );
}
$template->param(
tmpllist => \@tmpllist,
unit => \@units,
);
}
elsif ( $op eq 'Save' ) {
my $errmsg;
my $dberror = CreateProfile(
$prof_id, $printername, $paper_bin, $tmpl_id, $offset_horz,
$offset_vert, $creep_horz, $creep_vert, $units
);
unless ( $dberror ) {
print $query->redirect("./label-profiles.pl");
exit;
}
# FIXME: This exposes all CGI vars. Surely there is a better way to do it? -fbcit
if ( $dberror =~ /Duplicate/ && $dberror =~ /$paper_bin/ ) {
$errmsg = "You cannot create duplicate profiles for $printername/$paper_bin.
Click the Back button on your browser and enter a different paper bin
for $printername.";
}
else {
$errmsg = $dberror;
}
$template->param (
dberror => $dberror,
errmsg => $errmsg,
);
warn "DB error: $dberror";
}
elsif ( $op eq 'Cancel' ) {
print $query->redirect("./label-profiles.pl");
exit;
}
output_html_with_http_headers $query, $cookie, $template->output;

View file

@ -1,103 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
#use Data::Dumper;
#use Smart::Comments;
my $dbh = C4::Context->dbh;
my $query = new CGI;
### $query
my $tmpl_code = $query->param('tmpl_code');
my $tmpl_desc = $query->param('tmpl_desc');
my $page_height = $query->param('page_height');
my $page_width = $query->param('page_width');
my $label_height = $query->param('label_height');
my $label_width = $query->param('label_width');
my $topmargin = $query->param('topmargin');
my $leftmargin = $query->param('leftmargin');
my $cols = $query->param('cols');
my $rows = $query->param('rows');
my $colgap = $query->param('colgap');
my $rowgap = $query->param('rowgap');
my $units = $query->param('units');
my $font = $query->param('fonts');
my $fontsize = $query->param('fontsize');
my $batch_id = $query->param('batch_id');
my $op = $query->param('op');
my @resultsloop;
my ( $template, $loggedinuser, $cookie );
if ( $op eq 'blank' ) {
my @units = (
{ unit => 'INCH', desc => 'Inches' },
{ unit => 'CM', desc => 'Centimeters' },
{ unit => 'MM', desc => 'Millimeters' },
{ unit => 'POINT', desc => 'Postscript Points' },
);
my @fonts = ( #FIXME: There is probably a way to discover what additional fonts are installed on a user's system and generate this list dynamically...
{ font => 'TR', name => 'Times Roman' },
{ font => 'TB', name => 'Times Bold' },
{ font => 'TI', name => 'Times Italic' },
{ font => 'TBI', name => 'Times Bold Italic' },
{ font => 'C', name => 'Courier' },
{ font => 'CB', name => 'Courier Bold' },
{ font => 'CO', name => 'Courier Oblique' },
{ font => 'CBO', name => 'Courier Bold Oblique' },
{ font => 'H', name => 'Helvetica' },
{ font => 'HB', name => 'Helvetica Bold' },
{ font => 'HO', name => 'Helvetica Oblique' },
{ font => 'HBO', name => 'Helvetica Bold Oblique' },
);
( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-create-template.tmpl",
query => $query,
type => "intranet",
authnotrequired => 1,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
$template->param(
units => \@units,
fonts => \@fonts,
);
}
elsif ( $op eq 'Create' ) {
CreateTemplate(
$tmpl_code, $tmpl_desc, $page_width,
$page_height, $label_width, $label_height, $topmargin,
$leftmargin, $cols, $rows, $colgap,
$rowgap, $font, $fontsize, $units );
print $query->redirect("./label-templates.pl");
exit;
}
elsif ( $op eq 'Cancel' ) {
print $query->redirect("./label-home.pl");
exit;
}
output_html_with_http_headers $query, $cookie, $template->output;

119
labels/label-create-xml.pl Executable file
View file

@ -0,0 +1,119 @@
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use XML::Simple;
use Data::Dumper;
use C4::Debug;
use C4::Labels::Batch 1.000000;
use C4::Labels::Template 1.000000;
use C4::Labels::Layout 1.000000;
use C4::Labels::PDF 1.000000;
use C4::Labels::Label 1.000000;
=head
=cut
my $cgi = new CGI;
my $batch_id = $cgi->param('batch_id') if $cgi->param('batch_id');
my $template_id = $cgi->param('template_id') || undef;
my $layout_id = $cgi->param('layout_id') || undef;
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
my $items = undef;
my $xml_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
print $cgi->header(-type => 'text/xml',
-encoding => 'utf-8',
-attachment => "$xml_file.xml",
);
my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
my $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
my $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
if (@label_ids) {
my $batch_items = $batch->get_attr('items');
grep {
my $label_id = $_;
push(@{$items}, grep{$_->{'label_id'} == $label_id;} @{$batch_items});
} @label_ids;
}
elsif (@item_numbers) {
grep {
push(@{$items}, {item_number => $_});
} @item_numbers;
}
else {
$items = $batch->get_attr('items');
}
my $xml = XML::Simple->new();
my $xml_data = {'label' => []};
my $item_count = 0;
XML_ITEMS:
foreach my $item (@$items) {
push(@{$xml_data->{'label'}}, {'item_number' => $item->{'item_number'}});
my $label = C4::Labels::Label->new(
batch_id => $batch_id,
item_number => $item->{'item_number'},
format_string => $layout->get_attr('format_string'),
);
my $format_string = $layout->get_attr('format_string');
my @data_fields = split(/, /, $format_string);
my $csv_data = $label->csv_data();
for (my $i = 0; $i < (scalar(@data_fields) - 1); $i++) {
push(@{$xml_data->{'label'}[$item_count]->{$data_fields[$i]}}, $$csv_data[$i]);
}
$item_count++;
}
#die "XML DATA:\n" . Dumper($xml_data);
my $xml_out = $xml->XMLout($xml_data);
#die "XML OUT:\n" . Dumper($xml_out);
print $xml_out;
exit(1);
=head1 NAME
labels/label-create-xml.pl - A script for creating a xml export of labels and label batches in Koha
=head1 ABSTRACT
This script provides the means of producing a xml of labels for items either individually, in groups, or in batches from within Koha. This particular script is provided more as
a demonstration of the multitude of formats Koha labels could be exported in based on the current Label Creator API.
=head1 AUTHOR
Chris Nighswonger <cnighswonger AT foundations DOT edu>
=head1 COPYRIGHT
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.
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
=head1 DISCLAIMER OF WARRANTY
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.

124
labels/label-edit-batch.pl Executable file
View file

@ -0,0 +1,124 @@
#!/usr/bin/perl
#
# Copyright 2006 Katipo Communications.
# 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
# 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
use strict;
use warnings;
use vars qw($debug);
use CGI;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use C4::Branch qw(get_branch_code_from_name);
use C4::Labels::Lib 1.000000 qw(get_label_summary html_table);
use C4::Labels::Batch 1.000000;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-edit-batch.tmpl",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $err = 0;
my $errstr = undef;
my $duplicate_count = undef;
my $duplicate_message = undef;
my $db_rows = {};
my $batch = undef;
my $display_columns = [ {_label_number => {label => 'Label Number', link_field => 0}},
{_summary => {label => 'Summary', link_field => 0}},
{_item_type => {label => 'Item Type', link_field => 0}},
{_barcode => {label => 'Barcode', link_field => 0}},
{select => {label => 'Select', value => '_label_id'}},
];
my $op = $cgi->param('op') || 'edit';
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
my $branch_code = get_branch_code_from_name($template->param('LoginBranchname'));
if ($op eq 'remove') {
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
foreach my $label_id (@label_ids) {
$err = $batch->remove_item($label_id);
}
$errstr = "item(s) not removed from batch $batch_id." if $err;
# Something like this would be nice to avoid problems with the browser's 'refresh' button, but it needs an error handling mechanism...
# print $cgi->redirect("label-edit-batch.pl?op=edit&batch_id=$batch_id");
# exit;
}
elsif ($op eq 'delete') {
$err = C4::Labels::Batch::delete(batch_id => $batch_id, branch_code => $branch_code);
$errstr = "batch $batch_id was not deleted." if $err;
}
elsif ($op eq 'add') {
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
$batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2;
if ($branch_code){
foreach my $item_number (@item_numbers) {
$err = $batch->add_item($item_number);
}
$errstr = "item(s) not added to batch $batch_id." if $err;
}
else {
$err = 1;
$errstr = "items(s) not added, the error was: Branch is not set, you please set your branch before adding items to a batch";
}
}
elsif ($op eq 'new') {
$batch = C4::Labels::Batch->new(branch_code => $branch_code);
$batch_id = $batch->get_attr('batch_id');
}
elsif ($op eq 'de_duplicate') {
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
$duplicate_count = $batch->remove_duplicates();
$duplicate_message = 1 if $duplicate_count != -1;
$errstr = "batch $batch_id not fully de-duplicated." if $duplicate_count == -1;
}
else { # edit
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
}
my $items = $batch->get_attr('items');
$db_rows = get_label_summary(items => $items, batch_id => $batch_id);
my $table = html_table($display_columns, $db_rows);
$template->param(
err => $err,
errstr => $errstr,
) if ($err ne 0);
$template->param(
op => $op,
batch_id => $batch_id,
table_loop => $table,
duplicate_message => $duplicate_message,
duplicate_count => $duplicate_count,
);
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,80 +1,169 @@
#!/usr/bin/perl
#
# Copyright 2006 Katipo Communications.
# 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
# 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
use strict;
use warnings;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
use Text::CSV_XS;
#use Data::Dumper;
#use Smart::Comments;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $layout_id = $query->param('layout_id');
### $query;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
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;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-edit-layout.tmpl",
query => $query,
query => $cgi,
type => "intranet",
authnotrequired => 1,
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $layout = get_layout($layout_id);
my @barcode_types = get_barcode_types($layout_id);
my @printingtypes = get_printingtypes($layout_id);
### @printingtypes
### $layout
my $op = $cgi->param('op') || $ARGV[0] || '';
my $layout_id = $cgi->param('layout_id') || $cgi->param('element_id') || $ARGV[1] || '';
my $layout = '';
$layout_id = $layout->{'id'}; # has it changed since we set it above? --joe
my $layoutname = $layout->{'layoutname'};
my $guidebox = $layout->{'guidebox'};
my $startlabel = $layout->{'startlabel'};
sub _set_selected {
my ($type_list, $object, $data_type) = @_;
SET_SELECTED:
foreach my $type (@$type_list) {
if ($layout->get_attr($data_type)) {
if ($type->{'type'} eq $layout->get_attr($data_type)) {
$type->{'selected'} = 1;
}
}
else {
$type->{'selected'} = 1;
last SET_SELECTED;
}
};
return $type_list;
}
my @title = build_text_dropbox( $layout->{'title'} );
my @subtitle = build_text_dropbox( $layout->{'subtitle'} );
my @author = build_text_dropbox( $layout->{'author'} );
my @barcode = build_text_dropbox( $layout->{'barcode'} );
my @isbn = build_text_dropbox( $layout->{'isbn'} );
my @issn = build_text_dropbox( $layout->{'issn'} );
my @itemtype = build_text_dropbox( $layout->{'itemtype'} );
my @dewey = build_text_dropbox( $layout->{'dewey'} );
my @class = build_text_dropbox( $layout->{'class'} );
my @subclass = build_text_dropbox( $layout->{'subclass'} );
my @itemcallnumber = build_text_dropbox( $layout->{'itemcallnumber'} );
sub _select_format_string { # generate field table based on format_string
my $format_string = shift;
$format_string =~ s/(?<=,) (?![A-Z][a-z][0-9])//g; # remove spaces between fields
my $table = [];
my $fields = [];
my ($row_index, $col_index, $field_index) = (0,0,0);
my $cols = 5; # number of columns to wrap on
my $csv = Text::CSV_XS->new({ allow_whitespace => 1 });
my $status = $csv->parse($format_string);
my @text_fields = $csv->fields();
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) {
$$fields[$col_index] = {field_empty => 0, field_name => ($text_field . "_tbl"), field_label => $text_field, order => [{num => '', selected => 0}]};
for (my $order_i = 1; $order_i <= $field_count; $order_i++) {
$$fields[$col_index]{'order'}[$order_i] = {num => $order_i, selected => ($field_index == $order_i-1 ? 1 : 0)};
}
$col_index++;
$field_index++;
if ((($col_index > 0) && !($col_index % $cols)) || ($field_index == $field_count)) { # wrap to new row
if (($field_index == $field_count) && ($row_index > 0)) { # in this case fill out row with empty fields
while ($col_index < $cols) {
$$fields[$col_index] = {field_empty => 1, field_name => '', field_label => '', order => [{num => '', selected => 0}]};
$col_index++;
}
$$table[$row_index] = {text_fields => $fields};
last POPULATE_TABLE;
}
$$table[$row_index] = {text_fields => $fields};
$row_index++;
$fields = [];
$col_index = 0;
}
}
return $table;
}
### @subclass
if ($op eq 'edit') {
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
my @layout_table = ();
foreach my $cgi_param ($cgi->param()) {
if (($cgi_param =~ m/^(.*)_tbl$/) && ($cgi->param($cgi_param))) {
my $value = $cgi->param($cgi_param);
$layout_table[$value - 1] = $1;
}
}
@layout_table = grep {$_} @layout_table; # this removes numerically 'skipped' fields. ie. user omits a number in sequential order
$format_string = join ', ', @layout_table;
$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'),
guidebox => ($cgi->param('guidebox') ? 1 : 0),
font => $cgi->param('font'),
font_size => $cgi->param('font_size'),
callnum_split => ($cgi->param('callnum_split') ? 1 : 0),
text_justify => $cgi->param('text_justify'),
format_string => $cgi->param('format_string'),
);
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();
}
else { # if no label_id, this is a new layout so insert it
$layout = C4::Labels::Layout->new(@params);
$layout->save();
}
print $cgi->redirect("label-manage.pl?label_element=layout");
exit;
}
else { # if we get here, this is a new layout
$layout = C4::Labels::Layout->new();
}
my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type');
my $label_types = _set_selected(get_label_types(), $layout, 'printing_type');
my $font_types = _set_selected(get_font_types(), $layout, 'font');
my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify');
my $select_text_fields = _select_format_string($layout->get_attr('format_string'));
$template->param(
barcode_types => \@barcode_types,
printingtypes => \@printingtypes,
layoutname => $layoutname,
layout_id => $layout_id,
guidebox => $guidebox,
startlabel => $startlabel,
formatstring => $layout->{'formatstring'},
callnum_split => $layout->{'callnum_split'},
'justify_' . $layout->{'text_justify'} => 1,
tx_title => \@title,
tx_subtitle => \@subtitle,
tx_author => \@author,
tx_isbn => \@isbn,
tx_issn => \@issn,
tx_itemtype => \@itemtype,
tx_dewey => \@dewey,
tx_barcode => \@barcode,
tx_classif => \@class,
tx_subclass => \@subclass,
tx_itemcallnumber => \@itemcallnumber,
barcode_types => $barcode_types,
label_types => $label_types,
font_types => $font_types,
text_justification_types => $text_justification_types,
field_table => $select_text_fields,
layout_id => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '',
layout_name => $layout->get_attr('layout_name'),
guidebox => $layout->get_attr('guidebox'),
font_size => $layout->get_attr('font_size'),
callnum_split => $layout->get_attr('callnum_split'),
format_string => $layout->get_attr('format_string'),
);
output_html_with_http_headers $query, $cookie, $template->output;
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,88 +1,105 @@
#!/usr/bin/perl
#
# Copyright 2006 Katipo Communications.
# 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
# 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
use strict;
use warnings;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
my $DEBUG = 0;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $op = $query->param('op');
my $prof_id = $query->param('prof_id');
my $offset_horz = $query->param('offset_horz');
my $offset_vert = $query->param('offset_vert');
my $creep_horz = $query->param('creep_horz');
my $creep_vert = $query->param('creep_vert');
my $units = $query->param('unit');
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use C4::Labels::Lib 1.000000 qw(get_all_templates get_unit_values);
use C4::Labels::Profile 1.000000;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-edit-profile.tmpl",
query => $query,
query => $cgi,
type => "intranet",
authnotrequired => 1,
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
if ($op eq '' || undef) {
my $prof = GetSinglePrinterProfile($prof_id);
my $op = $cgi->param('op');
my $profile_id = $cgi->param('profile_id') || $cgi->param('element_id');
my $profile = undef;
my $template_list = undef;
my @label_template = ();
my $tmpl = GetSingleLabelTemplate($prof->{'tmpl_id'});
my $units = get_unit_values();
if ( $DEBUG ) {
use Data::Dumper;
warn Dumper($prof);
warn Dumper($tmpl);
}
my @units = (
{ unit => 'INCH', desc => 'Inches' },
{ unit => 'CM', desc => 'Centimeters' },
{ unit => 'MM', desc => 'Millimeters' },
{ unit => 'POINT', desc => 'Postscript Points' },
if ($op eq 'edit') {
$profile = C4::Labels::Profile->retrieve(profile_id => $profile_id);
$template_list = get_all_templates(field_list => 'template_id,template_code, profile_id');
}
elsif ($op eq 'save') {
my @params = (
printer_name => $cgi->param('printer_name'),
paper_bin => $cgi->param('paper_bin'),
offset_horz => $cgi->param('offset_horz'),
offset_vert => $cgi->param('offset_vert'),
creep_horz => $cgi->param('creep_horz'),
creep_vert => $cgi->param('creep_vert'),
units => $cgi->param('units'),
);
foreach my $unit (@units) {
if ( $unit->{'unit'} eq $prof->{'unit'} ) {
$unit->{'selected'} = 1;
}
if ($profile_id) { # if a label_id was passed in, this is an update to an existing layout
$profile = C4::Labels::Profile->retrieve(profile_id => $profile_id);
$profile->set_attr(@params);
$profile->save();
}
$template->param(
units => \@units,
prof_id => $prof->{'prof_id'},
printername => $prof->{'printername'},
paper_bin => $prof->{'paper_bin'},
tmpl_code => $tmpl->{'tmpl_code'},
prof_code => $prof->{'prof_code'},
offset_horz => $prof->{'offset_horz'},
offset_vert => $prof->{'offset_vert'},
creep_horz => $prof->{'creep_horz'},
creep_vert => $prof->{'creep_vert'},
);
}
elsif ($op eq 'Save') {
warn "Units are now $units";
SaveProfile( $prof_id, $offset_horz, $offset_vert, $creep_horz, $creep_vert, $units );
print $query->redirect("./label-profiles.pl");
else { # if no label_id, this is a new layout so insert it
$profile = C4::Labels::Profile->new(@params);
$profile->save();
}
print $cgi->redirect("label-manage.pl?label_element=profile");
exit;
}
elsif ($op eq 'Cancel') {
print $query->redirect("./label-profiles.pl");
exit;
else { # if we get here, this is a new layout
$profile = C4::Labels::Profile->new();
}
output_html_with_http_headers $query, $cookie, $template->output;
if ($profile_id) {
@label_template = grep{($_->{'profile_id'} == $profile->get_attr('profile_id')) && ($_->{'template_id'} == $profile->get_attr('template_id'))} @$template_list;
}
foreach my $unit (@$units) {
if ($unit->{'type'} eq $profile->get_attr('units')) {
$unit->{'selected'} = 1;
}
}
$template->param(profile_id => $profile->get_attr('profile_id')) if $profile->get_attr('profile_id') > 0;
$template->param(
label_template => $label_template[0]->{'template_code'} || '',
printer_name => $profile->get_attr('printer_name'),
paper_bin => $profile->get_attr('paper_bin'),
offset_horz => $profile->get_attr('offset_horz'),
offset_vert => $profile->get_attr('offset_vert'),
creep_horz => $profile->get_attr('creep_horz'),
creep_vert => $profile->get_attr('creep_vert'),
units => $units,
op => $op,
);
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,123 +1,135 @@
#!/usr/bin/perl
#
# Copyright 2006 Katipo Communications.
# 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
# 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
use strict;
use warnings;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
# use Data::Dumper;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $tmpl_id = $query->param('tmpl_id');
my $width = $query->param('width');
my $height = $query->param('height');
my $topmargin = $query->param('topmargin');
my $leftmargin = $query->param('leftmargin');
my $columns = $query->param('columns');
my $rows = $query->param('rows');
my $colgap = $query->param('colgap');
my $rowgap = $query->param('rowgap');
my $prof_id = $query->param('prof_id');
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use C4::Labels::Lib 1.000000 qw(get_all_profiles get_unit_values);
use C4::Labels::Template 1.000000;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-edit-template.tmpl",
query => $query,
query => $cgi,
type => "intranet",
authnotrequired => 1,
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $tmpl = GetSingleLabelTemplate($tmpl_id);
my $curprof = GetAssociatedProfile($tmpl_id);
my @prof = GetAllPrinterProfiles();
my @proflist;
my $op = $cgi->param('op');
my $template_id = $cgi->param('template_id') || $cgi->param('element_id');
my $label_template = undef;
my $profile_list = undef;
# Generate an array of hashes containing possible profiles for given template and mark the currently associated one...
my $units = get_unit_values();
foreach my $prof (@prof) {
if ( $prof->{'tmpl_id'} eq $tmpl->{'tmpl_id'} && $prof->{'prof_id'} eq $curprof->{'prof_id'} ) {
push ( @proflist, {prof_id => $prof->{'prof_id'},
printername => $prof->{'printername'},
paper_bin => $prof->{'paper_bin'},
selected => 1} );
if ($op eq 'edit') {
$label_template = C4::Labels::Template->retrieve(template_id => $template_id);
$profile_list = get_all_profiles(field_list => 'profile_id,printer_name,paper_bin',filter => "template_id=$template_id OR template_id=''");
}
elsif ($op eq 'save') {
my @params = ( profile_id => $cgi->param('profile_id') || '',
template_code => $cgi->param('template_code'),
template_desc => $cgi->param('template_desc'),
page_width => $cgi->param('page_width'),
page_height => $cgi->param('page_height'),
label_width => $cgi->param('label_width'),
label_height => $cgi->param('label_height'),
top_text_margin => $cgi->param('top_text_margin'),
left_text_margin=> $cgi->param('left_text_margin'),
top_margin => $cgi->param('top_margin'),
left_margin => $cgi->param('left_margin'),
cols => $cgi->param('cols'),
rows => $cgi->param('rows'),
col_gap => $cgi->param('col_gap'),
row_gap => $cgi->param('row_gap'),
units => $cgi->param('units'),
);
if ($template_id) { # if a label_id was passed in, this is an update to an existing layout
$label_template = C4::Labels::Template->retrieve(template_id => $template_id);
my $old_profile = C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id'));
my $new_profile = C4::Labels::Profile->retrieve(profile_id => $cgi->param('profile_id'));
if ($label_template->get_attr('template_id') != $new_profile->get_attr('template_id')) {
$new_profile->set_attr(template_id => $label_template->get_attr('template_id'));
$old_profile->set_attr(template_id => 0);
$new_profile->save();
$old_profile->save();
}
$label_template->set_attr(@params);
$label_template->save();
}
elsif ( $prof->{'tmpl_id'} eq $tmpl->{'tmpl_id'} ) {
push ( @proflist, {prof_id => $prof->{'prof_id'},
printername => $prof->{'printername'},
paper_bin => $prof->{'paper_bin'}} );
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();
}
elsif ( !$prof ) {
undef @proflist;
print $cgi->redirect("label-manage.pl?label_element=template");
exit;
}
else { # if we get here, this is a new layout
$label_template = C4::Labels::Template->new();
}
if ($template_id) {
foreach my $profile (@$profile_list) {
if ($profile->{'profile_id'} == $label_template->get_attr('profile_id')) {
$profile->{'selected'} = 1;
}
else {
$profile->{'selected'} = 0;
}
}
}
my @units = (
{ unit => 'INCH', desc => 'Inches' },
{ unit => 'CM', desc => 'Centimeters' },
{ unit => 'MM', desc => 'Millimeters' },
{ unit => 'POINT', desc => 'Postscript Points' },
);
foreach my $unit (@units) {
if ( $unit->{'unit'} eq $tmpl->{'units'} ) {
foreach my $unit (@$units) {
if ($unit->{'type'} eq $label_template->get_attr('units')) {
$unit->{'selected'} = 1;
}
}
my @fonts = ( #FIXME: There is probably a way to discover what additional fonts are installed on a user's system and generate this list dynamically...
{ font => 'TR', name => 'Times Roman' },
{ font => 'TB', name => 'Times Bold' },
{ font => 'TI', name => 'Times Italic' },
{ font => 'TBI', name => 'Times Bold Italic' },
{ font => 'C', name => 'Courier' },
{ font => 'CB', name => 'Courier Bold' },
{ font => 'CO', name => 'Courier Oblique' },
{ font => 'CBO', name => 'Courier Bold Oblique' },
{ font => 'H', name => 'Helvetica' },
{ font => 'HB', name => 'Helvetica Bold' },
{ font => 'HO', name => 'Helvetica Oblique' },
{ font => 'HBO', name => 'Helvetica Bold Oblique' },
);
foreach my $font (@fonts) {
if ( $font->{'font'} eq $tmpl->{'font'} ) {
$font->{'selected'} = 1;
}
}
$template->param(
proflist => \@proflist,
units => \@units,
fonts => \@fonts,
tmpl_id => $tmpl->{'tmpl_id'},
tmpl_code => $tmpl->{'tmpl_code'},
tmpl_desc => $tmpl->{'tmpl_desc'},
page_width => $tmpl->{'page_width'},
page_height => $tmpl->{'page_height'},
label_width => $tmpl->{'label_width'},
label_height => $tmpl->{'label_height'},
topmargin => $tmpl->{'topmargin'},
leftmargin => $tmpl->{'leftmargin'},
cols => $tmpl->{'cols'},
rows => $tmpl->{'rows'},
colgap => $tmpl->{'colgap'},
rowgap => $tmpl->{'rowgap'},
fontsize => $tmpl->{'fontsize'},
active => $tmpl->{'active'},
profile_list => $profile_list,
template_id => ($label_template->get_attr('template_id') > 0) ? $label_template->get_attr('template_id') : '',
template_code => $label_template->get_attr('template_code'),
template_desc => $label_template->get_attr('template_desc'),
page_width => $label_template->get_attr('page_width'),
page_height => $label_template->get_attr('page_height'),
label_width => $label_template->get_attr('label_width'),
label_height => $label_template->get_attr('label_height'),
top_text_margin => $label_template->get_attr('top_text_margin'),
left_text_margin => $label_template->get_attr('left_text_margin'),
top_margin => $label_template->get_attr('top_margin'),
left_margin => $label_template->get_attr('left_margin'),
cols => $label_template->get_attr('cols'),
rows => $label_template->get_attr('rows'),
col_gap => $label_template->get_attr('col_gap'),
row_gap => $label_template->get_attr('row_gap'),
units => $units,
);
output_html_with_http_headers $query, $cookie, $template->output;
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,21 +1,36 @@
#!/usr/bin/perl
#
# Copyright 2006 Katipo Communications.
# 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
# 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
use strict;
use warnings;
use CGI;
use C4::Auth;
use C4::Output;
use C4::Labels;
use C4::Output;
use C4::Context;
use HTML::Template::Pro;
# use Smart::Comments;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
my $query = new CGI;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-home.tmpl",
query => $query,
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
@ -23,64 +38,4 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
# little block for displaying active layout/template/batch in templates
# ----------
my $batch_id = $query->param('batch_id');
my $active_layout = get_active_layout();
my $active_template = GetActiveLabelTemplate();
my $active_layout_name = $active_layout->{'layoutname'};
my $active_template_name = $active_template->{'tmpl_code'};
# ----------
my $data = get_label_options();
my $op = $query->param('op');
my $layout_id = $query->param('layout_id');
my @label_templates = GetAllLabelTemplates();
my @printingtypes = get_printingtypes();
my @layouts = get_layouts();
my @barcode_types = get_barcode_types();
#my @batches = get_batches(); #This is not used afaics -fbcit
if ($op eq 'delete_layout') { # had been assignment! serious error!
delete_layout($layout_id);
}
### $data
$template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
$template->param( "papertype_$data->{'papertype'}" => 1 );
$template->param( "$data->{'barcodetype'}_checked" => 1 );
$template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 );
$template->param(
op => $op,
active_layout_name => $active_layout_name,
active_template_name => $active_template_name,
label_templates => \@label_templates,
barcode_types => \@barcode_types,
printingtypes => \@printingtypes,
layout_loop => \@layouts,
#batches => \@batches, #This is not used afaics -fbcit
id => $data->{'id'},
barcodetype => $data->{'barcodetype'},
papertype => $data->{'papertype'},
tx_author => $data->{'author'},
tx_barcode => $data->{'barcode'},
tx_title => $data->{'title'},
tx_isbn => $data->{'isbn'},
tx_issn => $data->{'issn'},
tx_itemtype => $data->{'itemtype'},
tx_dewey => $data->{'dewey'},
tx_class => $data->{'class'},
tx_subclass => $data->{'subclass'},
tx_itemcallnumber => $data->{'itemcallnumber'},
startlabel => $data->{'startlabel'},
fontsize => $active_template->{'fontsize'},
);
output_html_with_http_headers $query, $cookie, $template->output;
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,5 +1,5 @@
#!/usr/bin/perl
#
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@ -19,26 +19,22 @@
use strict;
use warnings;
use vars qw($debug $cgi_debug);
use CGI;
use C4::Auth;
use HTML::Template::Pro;
use C4::Context;
use C4::Search;
use C4::Auth;
use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Acquisition;
use C4::Search;
use C4::Dates;
use C4::Koha; # XXX subfield_is_koha_internal_p
use C4::Debug;
use List::Util qw( max min );
use POSIX;
use POSIX qw(ceil);
#use Smart::Comments;
#use Data::Dumper;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use C4::Context;
use C4::Dates;
use C4::Search qw(SimpleSearch);
use C4::Biblio qw(TransformMarcToKoha);
use C4::Items qw(GetItemInfosOf get_itemnumbers_of);
use C4::Koha qw(GetItemTypes); # XXX subfield_is_koha_internal_p
use C4::Labels::Lib qw(html_table);
use C4::Debug;
BEGIN {
$debug = $debug || $cgi_debug;
@ -48,29 +44,26 @@ BEGIN {
}
}
# Creates a scrolling list with the associated default value.
# Using more than one scrolling list in a CGI assigns the same default value to all the
# scrolling lists on the page !?!? That's why this function was written.
my $query = new CGI;
my $type = $query->param('type');
my $op = $query->param('op') || '';
my $batch_id = $query->param('batch_id');
my $ccl_query = $query->param('ccl_query');
my $dbh = C4::Context->dbh;
my $startfrom = $query->param('startfrom') || 1;
my ( $template, $loggedinuser, $cookie );
my ($template, $loggedinuser, $cookie) = (undef, undef, undef);
my (
$total_hits, $orderby, $results, $total, $error,
$marcresults, $idx, $datefrom, $dateto, $ccl_textbox
);
my $resultsperpage = C4::Context->preference('numSearchResults') || '20';
my $show_results = 0;
my $display_columns = [ {_add => {label => "Add Item", link_field => 1}},
{_item_call_number => {label => "Call Number", link_field => 0}},
{_date_accessioned => {label => "Accession Date", link_field => 0}},
{_barcode => {label => "Barcode", link_field => 0}},
{select => {label => "Select", value => "_item_number"}},
];
if ( $op eq "do_search" ) {
$idx = $query->param('idx');
@ -82,18 +75,6 @@ if ( $op eq "do_search" ) {
$datefrom = $query->param('datefrom');
$dateto = $query->param('dateto');
( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/result.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { borrowers => 1 },
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
if ($datefrom) {
$datefrom = C4::Dates->new($datefrom);
$ccl_query .= ' and ' if $ccl_textbox;
@ -111,7 +92,7 @@ if ( $op eq "do_search" ) {
( $error, $marcresults, $total_hits ) =
SimpleSearch( $ccl_query, $offset, $resultsperpage );
if ($marcresults) {
if (scalar($marcresults) > 0) {
$show_results = scalar @$marcresults;
}
else {
@ -123,71 +104,55 @@ if ( $op eq "do_search" ) {
if ($show_results) {
my $hits = $show_results;
my ( @results, @items );
my @results_set = ();
my @items =();
# This code needs to be refactored using these subs...
#my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' );
#my $dat = &GetBiblioData( $biblio->{biblionumber} );
for ( my $i = 0 ; $i < $hits ; $i++ ) {
my @row_data= ();
#DEBUG Notes: Decode the MARC record from each resulting MARC record...
my $marcrecord = MARC::File::USMARC::decode( $marcresults->[$i] );
#DEBUG Notes: Transform it to Koha form...
my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
# Begin building the hash for the template...
# I don't think we need this with the current template design, but I'm leaving it in place. -fbcit
#$biblio->{highlight} = ($i % 2)?(1):(0);
#DEBUG Notes: Stuff the bib into @results...
push @results, $biblio;
#DEBUG Notes: Stuff the bib into @biblio_data...
push (@results_set, $biblio);
my $biblionumber = $biblio->{'biblionumber'};
#DEBUG Notes: Grab the item numbers associated with this MARC record...
my $itemnums = get_itemnumbers_of($biblionumber);
#DEBUG Notes: Retrieve the item data for each number...
my $iii = $itemnums->{$biblionumber};
if ($iii) {
if (my $iii = $itemnums->{$biblionumber}) {
my $item_results = GetItemInfosOf(@$iii);
foreach my $item ( keys %$item_results ) {
#DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data...
if ( $item_results->{$item}->{'biblionumber'} eq
$results[$i]->{'biblionumber'} )
{
# NOTE: The order of the elements in this array must be preserved or the table dependent on it will be incorrectly rendered.
# This is a real hack, but I can't think of a better way right now. -fbcit
# It is conceivable that itemcallnumber and/or barcode fields might be empty so the trinaries cover this possibility.
push @{ $results[$i]->{'item'} }, { i_itemnumber1 =>
$item_results->{$item}->{'itemnumber'} };
push @{ $results[$i]->{'item'} },
{
i_itemcallnumber => (
$item_results->{$item}->{'itemcallnumber'}
? $item_results->{$item}->{'itemcallnumber'}
: 'NA'
)
};
push @{ $results[$i]->{'item'} }, { i_dateaccessioned =>
$item_results->{$item}->{'dateaccessioned'} };
push @{ $results[$i]->{'item'} },
{
i_barcode => (
$item_results->{$item}->{'barcode'}
? $item_results->{$item}->{'barcode'}
: 'NA'
)
};
push @{ $results[$i]->{'item'} }, { i_itemnumber2 =>
$item_results->{$item}->{'itemnumber'} };
#DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data...
if ($item_results->{$item}->{'biblionumber'} eq $results_set[$i]->{'biblionumber'}) {
my $item_data->{'_item_number'} = $item_results->{$item}->{'itemnumber'};
$item_data->{'_item_call_number'} = ($item_results->{$item}->{'itemcallnumber'} ? $item_results->{$item}->{'itemcallnumber'} : 'NA');
$item_data->{'_date_accessioned'} = $item_results->{$item}->{'dateaccessioned'};
$item_data->{'_barcode'} = ( $item_results->{$item}->{'barcode'} ? $item_results->{$item}->{'barcode'} : 'NA');
$item_data->{'_add'} = $item_results->{$item}->{'itemnumber'};
unshift (@row_data, $item_data); # item numbers are given to us in descending order by get_itemnumbers_of()...
}
}
$results_set[$i]->{'item_table'} = html_table($display_columns, \@row_data);
}
else {
# FIXME: Some error trapping code needed
warn sprintf('No item numbers retrieved for biblio number: %s', $biblionumber);
}
}
$debug and warn "**********\@results**********\n";
$debug and warn Dumper(@results);
( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/result.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { borrowers => 1 },
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
# build page nav stuff.
my ( @field_data, @numbers );
@ -242,7 +207,8 @@ if ($show_results) {
);
$template->param(
result => \@results,
results => ($show_results ? 1 : 0),
result_set=> \@results_set,
batch_id => $batch_id,
type => $type,
idx => $idx,

113
labels/label-manage.pl Executable file
View file

@ -0,0 +1,113 @@
#!/usr/bin/perl
#
# Copyright 2006 Katipo Communications.
# 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
# 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
use strict;
use warnings;
use vars qw($debug);
use CGI;
use Data::Dumper;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use autouse 'C4::Branch' => qw(get_branch_code_from_name);
use C4::Labels::Lib 1.000000 qw(get_all_templates get_all_layouts get_all_profiles get_batch_summary html_table);
use C4::Labels::Layout 1.000000;
use C4::Labels::Template 1.000000;
use C4::Labels::Profile 1.000000;
use C4::Labels::Batch 1.000000;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-manage.tmpl",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $error = 0;
my $db_rows = {};
my $display_columns = { layout => [ # db column => {col label is link?
{layout_id => {label => 'Layout ID', link_field => 0}},
{layout_name => {label => 'Layout', link_field => 0}},
{barcode_type => {label => 'Barcode Type', link_field => 0}},
{printing_type => {label => 'Print Type', link_field => 0}},
{format_string => {label => 'Fields to Print',link_field => 0}},
{select => {label => 'Select', value => 'layout_id'}},
],
template => [ {template_id => {label => 'Template ID', link_field => 0}},
{template_code => {label => 'Template Name', link_field => 0}},
{template_desc => {label => 'Description', link_field => 0}},
{select => {label => 'Select', value => 'template_id'}},
],
profile => [ {profile_id => {label => 'Profile ID', link_field => 0}},
{printer_name => {label => 'Printer Name', link_field => 0}},
{paper_bin => {label => 'Paper Bin', link_field => 0}},
{_template_code => {label => 'Template Name', link_field => 0}}, # this display column does not have a corrisponding db column in the profile table, hence the underscore
{select => {label => 'Select', value => 'profile_id'}},
],
batch => [ {batch_id => {label => 'Batch ID', link_field => 0}},
{_item_count => {label => 'Item Count', link_field => 0}},
{select => {label => 'Select', value => 'batch_id'}},
],
};
my $label_element = $cgi->param('label_element') || undef;
my $op = $cgi->param('op') || 'none';
my $element_id = $cgi->param('element_id') || undef;
my $branch_code = ($label_element eq 'batch' ? get_branch_code_from_name($template->param('LoginBranchname')) : '');
if ($op eq 'delete') {
if ($label_element eq 'layout') {$error = C4::Labels::Layout::delete(layout_id => $element_id);}
elsif ($label_element eq 'template') {$error = C4::Labels::Template::delete(template_id => $element_id);}
elsif ($label_element eq 'profile') {$error = C4::Labels::Profile::delete(profile_id => $element_id);}
elsif ($label_element eq 'batch') {$error = C4::Labels::Batch::delete(batch_id => $element_id, branch_code => $branch_code);}
else {} # FIXME: Some error trapping code
}
if ($label_element eq 'layout') {$db_rows = get_all_layouts();}
elsif ($label_element eq 'template') {$db_rows = get_all_templates();}
elsif ($label_element eq 'profile') {$db_rows = get_all_profiles();}
elsif ($label_element eq 'batch') {$db_rows = get_batch_summary(filter => "branch_code=\'$branch_code\' OR branch_code=\'NB\'");}
else {} # FIXME: Some error trapping code
my $table = html_table($display_columns->{$label_element}, $db_rows);
$template->param(error => $error) if ($error ne 0);
$template->param(print => 1) if ($label_element eq 'batch');
$template->param(
op => $op,
element_id => $element_id,
table_loop => $table,
label_element => $label_element,
label_element_title => ($label_element eq 'layout' ? 'Layouts' :
$label_element eq 'template' ? 'Templates' :
$label_element eq 'profile' ? 'Profiles' :
$label_element eq 'batch' ? 'Batches' :
''
),
);
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,192 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Labels;
use C4::Output;
use HTML::Template::Pro;
#use POSIX qw(ceil);
#use Data::Dumper;
#use Smart::Comments;
use vars qw($debug);
BEGIN {
$debug = $ENV{DEBUG} || 0;
}
my $dbh = C4::Context->dbh;
my $query = new CGI;
$query->param('debug') and $debug = $query->param('debug');
my $op = $query->param('op');
my $layout_id = $query->param('layout_id');
my $layoutname = $query->param('layoutname');
my $barcodetype = $query->param('barcodetype');
my $bcn = $query->param('tx_barcode');
my $title = $query->param('tx_title');
my $subtitle = $query->param('tx_subtitle');
my $isbn = $query->param('tx_isbn');
my $issn = $query->param('tx_issn');
my $itemtype = $query->param('tx_itemtype');
my $itemcallnumber = $query->param('tx_itemcallnumber');
my $author = $query->param('tx_author');
my $tmpl_id = $query->param('tmpl_id');
my $summary = $query->param('summary');
my $startlabel = $query->param('startlabel');
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';
my @itemnumber;
($batch_type eq 'labels') ? (@itemnumber = $query->param('itemnumber')) : (@itemnumber = $query->param('borrowernumber'));
# little block for displaying active layout/template/batch in templates
# ----------
my $batch_id = $query->param('batch_id');
my $active_layout = get_active_layout();
my $active_template = GetActiveLabelTemplate();
my $active_layout_name = $active_layout->{'layoutname'};
my $active_template_name = $active_template->{'tmpl_code'};
# ----------
#if (!$batch_id ) {
# $batch_id = get_highest_batch();
#}
#my $batch_type = "labels"; #FIXME: Hardcoded for testing/development...
my @messages;
my ($itemnumber) = @itemnumber if (scalar(@itemnumber) == 1);
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-manager.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
if ( $op eq 'save_layout' ) {
save_layout(
$barcodetype, $title, $subtitle, $isbn,
$issn, $itemtype, $bcn, $text_justify,
$callnum_split, $itemcallnumber, $author,
$tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
, $formatstring , $layout_id
);
### $layoutname
print $query->redirect("label-home.pl");
exit;
}
elsif ( $op eq 'add_layout' ) {
add_layout(
$barcodetype, $title, $subtitle, $isbn,
$issn, $itemtype, $bcn, $text_justify,
$callnum_split, $itemcallnumber, $author,
$tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
$formatstring , $layout_id
);
### $layoutname
print $query->redirect("label-home.pl");
exit;
}
# FIXME: The trinary conditionals here really need to be replaced with a more robust form of db abstraction -fbcit
elsif ( $op eq 'add' ) { # add item
my $query2 = ($batch_type eq 'patroncards') ?
"INSERT INTO patroncards (borrowernumber, batch_id) values (?,?)" :
"INSERT INTO labels (itemnumber, batch_id) values (?,?)" ;
my $sth2 = $dbh->prepare($query2);
for my $inum (@itemnumber) {
# warn "INSERTing " . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . ":$inum for batch $batch_id";
$sth2->execute($inum, $batch_id);
}
}
elsif ( $op eq 'deleteall' ) {
my $query2 = "DELETE FROM $batch_type";
my $sth2 = $dbh->prepare($query2);
$sth2->execute();
}
elsif ( $op eq 'delete' ) {
my @labelids = $query->param((($batch_type eq 'labels') ? 'labelid' : 'cardid'));
scalar @labelids or push @messages, (($batch_type eq 'labels') ? "ERROR: No labelid(s) supplied for deletion." : "ERROR: No cardid(s) supplied for deletion.");
my $ins = "?," x (scalar @labelids);
$ins =~ s/\,$//;
my $query2 = "DELETE FROM $batch_type WHERE " . (($batch_type eq 'labels') ? 'labelid' : 'cardid') ." IN ($ins) ";
$debug and push @messages, "query2: $query2 -- (@labelids)";
my $sth2 = $dbh->prepare($query2);
$sth2->execute(@labelids);
}
elsif ( $op eq 'delete_batch' ) {
delete_batch($batch_id, $batch_type);
print $query->redirect("label-manager.pl?type=$batch_type");
exit;
}
elsif ( $op eq 'add_batch' ) {
$batch_id= add_batch($batch_type);
}
elsif ( $op eq 'set_active_layout' ) {
set_active_layout($layout_id);
print $query->redirect("label-home.pl");
exit;
}
elsif ( $op eq 'deduplicate' ) {
warn "\$batch_id=$batch_id and \$batch_type=$batch_type";
my ($return, $dberror) = deduplicate_batch($batch_id, $batch_type);
my $msg = (($return) ? "Removed $return" : "Error removing") . " duplicate items from Batch $batch_id." . (($dberror) ? " Database returned: $dberror" : "");
push @messages, $msg;
}
# first lets do a read of the labels table , to get the a list of the
# currently entered items to be prinited
my @batches = get_batches($batch_type);
my @resultsloop = ($batch_type eq 'labels') ? GetLabelItems($batch_id) : GetPatronCardItems($batch_id);
#warn "$batches[0] (id $batch_id)";
#warn Dumper(@resultsloop);
#calc-ing number of sheets
#my $number_of_results = scalar @resultsloop;
#my $sheets_needed = ceil( ( --$number_of_results + $startrow ) / 8 ); # rounding up
#my $tot_labels = ( $sheets_needed * 8 );
#my $start_results = ( $number_of_results + $startrow );
#my $labels_remaining = ( $tot_labels - $start_results );
if (scalar @messages) {
$template->param(message => 1);
my @complex = ();
foreach (@messages) {
my %hash = (message_text => $_);
push @complex, \%hash;
}
$template->param(message_loop => \@complex);
}
if ($batch_type eq 'labels' or $batch_type eq 'patroncards') {
$template->param("batch_is_$batch_type" => 1);
}
$template->param(
batch_type => $batch_type,
batch_id => $batch_id,
batch_count => scalar @resultsloop,
active_layout_name => $active_layout_name,
active_template_name => $active_template_name,
outputformat => ( $active_layout->{'printingtype'} eq 'CSV' ) ? 'csv' : 'pdf' ,
layout_tx => ( $active_layout->{'formatstring'}) ? 0 : 1 ,
layout_string => ( $active_layout->{'formatstring'}) ? 1 : 0 ,
resultsloop => \@resultsloop,
batches => \@batches,
tmpl_desc => $active_template->{'tmpl_desc'},
# startrow => $startrow,
# sheets => $sheets_needed,
# labels_remaining => $labels_remaining,
);
output_html_with_http_headers $query, $cookie, $template->output;

View file

@ -1,55 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Labels;
use C4::Auth;
use C4::Output;
use C4::Context;
use C4::Biblio;
use Text::CSV_XS;
my $DEBUG = 0;
my $DEBUG_LPT = 0;
my $htdocs_path = C4::Context->config('intrahtdocs');
my $cgi = new CGI;
# get the printing settings
my $template = GetActiveLabelTemplate();
my $conf_data = get_label_options();
my $batch_id = $cgi->param('batch_id');
my $exportname = 'koha_label_' . $batch_id . '.csv';
print $cgi->header(-type => 'application/vnd.sun.xml.calc',
-encoding => 'utf-8',
-attachment => $exportname,
-filename => $exportname );
my $batch_type = $conf_data->{'type'};
my $barcodetype = $conf_data->{'barcodetype'};
my $printingtype = $conf_data->{'printingtype'};
my @resultsloop = GetLabelItems($batch_id);
my $csv = Text::CSV_XS->new();
my @str_fields = get_text_fields($conf_data->{'id'}, 'codes' );
for my $item (@resultsloop) {
my $record = GetMarcBiblio($item->{biblionumber});
my @datafields = map { C4::Labels::GetBarcodeData($_->{'code'},$item,$record) } @str_fields ;
my $csvout ;
if($csv->combine(@datafields)) {
$csvout = $csv->string();
print "$csvout\n";
} else {
warn "CSV ERROR: " . $csv->error_input;
}
} # end for item loop
exit(1);
# is that the right way to do this ?

View file

@ -1,260 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use C4::Labels; # GetActiveLabelTemplate get_label_options GetAssociatedProfile
# GetPatronCardItems GetLabelItems GetUnitsValue...
use C4::Auth;
use C4::Output;
use C4::Context;
use C4::Members;
use C4::Branch;
use HTML::Template::Pro;
use PDF::Reuse;
use PDF::Reuse::Barcode;
use POSIX; # ceil
use Data::Dumper;
my $DEBUG = 0;
my $DEBUG_LPT = 0;
my $cgi = new CGI;
#### Tons of Initialization ####
# get the printing settings
my $template = GetActiveLabelTemplate();
my $conf_data = get_label_options() or die "get_label_options failed";
my $profile = GetAssociatedProfile($template->{'tmpl_id'});
my $batch_id = $cgi->param('batch_id');
my @resultsloop;
my $batch_type = $conf_data->{'type'};
my $barcodetype = $conf_data->{'barcodetype'};
my $printingtype = $conf_data->{'printingtype'} or die "No printingtype in conf_data";
my $guidebox = $conf_data->{'guidebox'};
my $start_label = $conf_data->{'startlabel'};
if ($cgi->param('startlabel')) {
$start_label = $cgi->param('startlabel'); # A bit of a hack to allow setting the starting label from the address bar... -fbcit
}
warn "Starting on label #$start_label" if $DEBUG;
my $units = $template->{'units'};
if ($printingtype eq 'PATCRD') {
@resultsloop = GetPatronCardItems($batch_id);
} else {
@resultsloop = GetLabelItems($batch_id);
}
#warn "UNITS $units";
#warn "fontsize = $fontsize";
#warn Dumper $template;
my $unitvalue = GetUnitsValue($units);
my $prof_unitvalue = GetUnitsValue($profile->{'unit'});
warn "Template units: $units which converts to $unitvalue PostScript Points" if $DEBUG;
warn "Profile units: $profile->{'unit'} which converts to $prof_unitvalue PostScript Points" if $DEBUG;
my $tmpl_code = $template->{'tmpl_code'};
my $tmpl_desc = $template->{'tmpl_desc'};
my $page_height = ( $template->{'page_height'} * $unitvalue );
my $page_width = ( $template->{'page_width'} * $unitvalue );
my $label_height = ( $template->{'label_height'} * $unitvalue );
my $label_width = ( $template->{'label_width'} * $unitvalue );
my $spine_width = ( $template->{'label_width'} * $unitvalue );
my $circ_width = ( $template->{'label_width'} * $unitvalue );
my $top_margin = ( $template->{'topmargin'} * $unitvalue );
my $left_margin = ( $template->{'leftmargin'} * $unitvalue );
my $colspace = ( $template->{'colgap'} * $unitvalue );
my $rowspace = ( $template->{'rowgap'} * $unitvalue );
warn "Converted dimensions are:" if $DEBUG;
warn "pghth=$page_height, pgwth=$page_width, lblhth=$label_height, lblwth=$label_width, spinwth=$spine_width, circwth=$circ_width, tpmar=$top_margin, lmar=$left_margin, colsp=$colspace, rowsp=$rowspace" if $DEBUG;
my $label_cols = $template->{'cols'};
my $label_rows = $template->{'rows'};
my $margin = $top_margin;
my $left_text_margin = 3; # FIXME: This value should not be hardcoded
my $str;
# Some peritent notes from PDF::Reuse regarding prFont()...
# If a font wasn't found, Helvetica will be set.
# These names are always recognized: Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Courier, Courier-Bold,
# Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique
# They can be abbreviated: TR, TB, TI, TBI, C, CB, CO, CBO, H, HB, HO, HBO
my $fontsize = $template->{'fontsize'};
my $fontname = $template->{'font'};
my $text_wrap_cols = GetTextWrapCols( $fontname, $fontsize, $label_width, $left_text_margin );
#warn $label_cols, $label_rows;
# set the paper size
my $lowerLeftX = 0;
my $lowerLeftY = 0;
my $upperRightX = $page_width;
my $upperRightY = $page_height;
my $codetype; # = 'Code39';
warn "Active profile: " . ($profile->{prof_id} || "None") if $DEBUG;
#### PRINT PRELIMINARY DATA ####
print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' );
# Don't print header until very last possible moment
# That way if error or die occurs, fatals_to_browser will still work.
# After we print this header, there is no way back to HTML. All we can do is deliver PDF.
prInitVars();
$| = 1;
prFile(); # No args means to STDOUT
prCompress(1); # turn on zip compression which dramatically reduces file size
prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
# drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY ); #do page border
# draw margin box for alignment page
drawbox($left_margin, $top_margin, $page_width-(2*$left_margin), $page_height-(2*$top_margin)) if $DEBUG_LPT;
#### TWEAKS and DEBUGGING ###
# Adjustments for image position and creep -fbcit
# NOTE: *All* of these factor in to image position and creep. Keep this in mind when makeing adjustments.
# Suggested proceedure: Adjust margins until both top and left margins are correct. Then adjust the label
# height and width to correct label creep across and down page. Units are PostScript Points (72 per inch).
sub debug_drop {
my $title = @_ || "";
warn "-------------------------$title-----------------------------\n"
. " top margin = $top_margin points\n"
. " left margin = $left_margin points\n"
. "label height = $label_height points\n"
. "label width = $label_width points\n";
}
debug_drop('INITIAL VALUES') if ($DEBUG);
if ( $profile->{'prof_id'} ) {
$top_margin += ($profile->{'offset_vert'} * $prof_unitvalue); # controls vertical offset
$label_height += ($profile->{'creep_vert'} * $prof_unitvalue); # controls vertical creep
$left_margin += ($profile->{'offset_horz'} * $prof_unitvalue); # controls horizontal offset
$label_width += ($profile->{'creep_horz'} * $prof_unitvalue); # controls horizontal creep
}
if ($DEBUG) {
if ($profile->{'prof_id'}) {
debug_drop('ADJUSTED VALUES');
} else {
warn "No profile associated so no adjustment applied.";
}
}
#warn " $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY";
#warn "$label_rows, $label_cols\n";
#warn "$label_height, $label_width\n";
#warn "$page_height, $page_width\n";
my ($rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp);
if ( $start_label and $start_label == 1 ) {
$rowcount = 1;
$colcount = 1;
$x_pos = $left_margin;
$y_pos = ( $page_height - $top_margin - $label_height );
} else {
$rowcount = ceil( $start_label / $label_cols );
$colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) );
$x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) +
( $colspace * ( $colcount - 1 ) );
$y_pos = $page_height - $top_margin - ( $label_height * $rowcount ) -
( $rowspace * ( $rowcount - 1 ) );
$DEBUG and warn "Start label: $start_label. Beginning in row $rowcount, column $colcount\n"
. "(X,Y) positions = ($x_pos,$y_pos)\n"
. "Rowspace = $rowspace, Label height = $label_height";
}
#
#### main foreach loop ####
#
foreach my $item (@resultsloop) {
warn "Label parameters: xpos=$x_pos, ypos=$y_pos, lblwid=$label_width, lblhig=$label_height" if $DEBUG;
drawbox($x_pos, $y_pos, $label_width, $label_height) if $guidebox; # regardless of printingtype
if ( $printingtype eq 'BAR' ) {
DrawBarcode( $x_pos, $y_pos, $label_height, $label_width, $item->{'barcode'}, $barcodetype );
}
elsif ( $printingtype eq 'BARBIB' ) {
# reposoitioning barcode up the top of label
my $barcode_height = ($label_height / 1.5 ); ## scaling voodoo
my $text_height = $label_height / 2;
my $barcode_y = $y_pos + ( $label_height / 2.5 ); ## scaling voodoo
DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width, $item->{'barcode'}, $barcodetype );
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
} # correct
elsif ( $printingtype eq 'BIBBAR' ) {
my $barcode_height = $label_height / 2;
DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $item->{'barcode'}, $barcodetype );
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
}
elsif ( $printingtype eq 'ALT' ) {
DrawBarcode( $x_pos, $y_pos, $label_height, $label_width, $item->{'barcode'}, $barcodetype );
CalcNextLabelPos();
drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
}
elsif ( $printingtype eq 'BIB' ) {
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
}
elsif ( $printingtype eq 'PATCRD' ) {
my $patron_data = $item;
#FIXME: This needs to be paramatized and passed in from the user...
#Each element of this hash is a separate line on the patron card. Keys are the text to print and the associated data is the point size.
my $text = {
$patron_data->{'description'} => $fontsize,
$patron_data->{'branchname'} => ($fontsize + 3),
};
$DEBUG and warn "Generating patron card for cardnumber $patron_data->{'cardnumber'}";
my $barcode_height = $label_height / 2.75; #FIXME: Scaling barcode height; this needs to be a user parameter.
DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $patron_data->{'cardnumber'}, $barcodetype );
DrawPatronCardText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
$left_text_margin, $text_wrap_cols, $text, $printingtype );
}
else {
die "CANNOT PRINT: Unknown printingtype '$printingtype'";
}
CalcNextLabelPos(); # regardless of printingtype
} # end for item loop
prEnd();
sub CalcNextLabelPos {
if ($colcount < $label_cols) {
# warn "new col";
$x_pos = ( $x_pos + $label_width + $colspace );
$colcount++;
} else {
$x_pos = $left_margin;
if ($rowcount == $label_rows) {
# warn "new page";
prPage();
$y_pos = ( $page_height - $top_margin - $label_height );
$rowcount = 1;
} else {
# warn "new row";
$y_pos = ( $y_pos - $rowspace - $label_height );
$rowcount++;
}
$colcount = 1;
}
}

131
labels/label-print.pl Executable file
View file

@ -0,0 +1,131 @@
#!/usr/bin/perl
#
# 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
# 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
use strict;
use warnings;
use CGI;
use Data::Dumper;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use C4::Labels::Lib 1.000000 qw(get_all_templates get_all_layouts get_label_output_formats);
use C4::Labels::Batch 1.000000;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-print.tmpl",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $op = $cgi->param('op') || 'none';
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); # this will handle individual label printing
my @batch_ids = $cgi->param('batch_id') if $cgi->param('batch_id');
my $layout_id = $cgi->param('layout_id') || undef;
my $template_id = $cgi->param('template_id') || undef;
my $start_label = $cgi->param('start_label') || 1;
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
my $output_format = $cgi->param('output_format') || 'pdf';
my $referer = $cgi->param('referer') || undef;
my $layouts = undef;
my $templates = undef;
my $label_output_formats = undef;
my @batches = ();
my $multi_batch_count = scalar(@batch_ids);
my $label_count = scalar(@label_ids);
my $item_count = scalar(@item_numbers);
if ($op eq 'export') {
if (@label_ids) {
my $label_id_param = '&amp;label_id=';
$label_id_param .= join ('&amp;label_id=',@label_ids);
push (@batches, {create_script => ($output_format eq 'pdf' ? 'label-create-pdf.pl' : 'label-create-csv.pl'),
batch_id => $batch_ids[0],
template_id => $template_id,
layout_id => $layout_id,
start_label => $start_label,
label_ids => $label_id_param,
label_count => scalar(@label_ids),
});
$template->param(
batches => \@batches,
referer => $referer,
);
}
elsif (@item_numbers) {
my $item_number_param = '&amp;item_number=';
$item_number_param .= join ('&amp;item_number=',@item_numbers);
push (@batches, {create_script => ($output_format eq 'pdf' ? 'label-create-pdf.pl' : 'label-create-csv.pl'),
template_id => $template_id,
layout_id => $layout_id,
start_label => $start_label,
item_numbers => $item_number_param,
label_count => scalar(@item_numbers),
});
$template->param(
batches => \@batches,
referer => $referer,
);
}
elsif (@batch_ids) {
foreach my $batch_id (@batch_ids) {
push (@batches, {create_script => ($output_format eq 'pdf' ? 'label-create-pdf.pl' : 'label-create-csv.pl'),
batch_id => $batch_id,
template_id => $template_id,
layout_id => $layout_id,
start_label => $start_label,
});
}
$template->param(
batches => \@batches,
referer => $referer,
);
}
}
elsif ($op eq 'none') {
# setup select menus for selecting layout and template for this run...
$referer = $ENV{'HTTP_REFERER'};
$referer =~ s/^.*?:\/\/.*?(\/.*)$/$1/m;
@batch_ids = grep{$_ = {batch_id => $_}} @batch_ids;
@label_ids = grep{$_ = {label_id => $_}} @label_ids;
@item_numbers = grep{$_ = {item_number => $_}} @item_numbers;
$templates = get_all_templates(field_list => 'template_id, template_code');
$layouts = get_all_layouts(field_list => 'layout_id, layout_name');
$label_output_formats = get_label_output_formats();
$template->param(
batch_ids => \@batch_ids,
label_ids => \@label_ids,
item_numbers => \@item_numbers,
templates => $templates,
layouts => $layouts,
label_output_formats => $label_output_formats,
multi_batch_count => $multi_batch_count,
label_count => $label_count,
item_count => $item_count,
referer => $referer,
);
}
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -1,63 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $op = $query->param('op');
#my $prof_code = $query->param('prof_code');
my $prof_id = $query->param('prof_id');
#my $printername = $query->param('printername');
#my $tmpl_id = $query->param('tmpl_id');
#my $paper_bin = $query->param('paper_bin');
#my $offset_horz = $query->param('offset_horz');
#my $offset_vert = $query->param('offset_vert');
#my $creep_horz = $query->param('creep_horz');
#my $creep_vert = $query->param('creep_vert');
# little block for displaying active layout/template/batch in templates
# ----------
my $batch_id = $query->param('batch_id');
my $active_layout = get_active_layout();
my $active_template = GetActiveLabelTemplate();
my $active_layout_name = $active_layout->{'layoutname'};
my $active_template_name = $active_template->{'tmpl_code'};
# ----------
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-profiles.tmpl",
query => $query,
type => "intranet",
authnotrequired => 1,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my @resultsloop;
if ( $op eq 'delete' ) {
my $dberror = DeleteProfile($prof_id);
warn "DB returned error: $dberror" if $dberror;
}
@resultsloop = GetAllPrinterProfiles();
$template->param(
batch_id => $batch_id,
active_layout_name => $active_layout_name,
active_template_name => $active_template_name,
resultsloop => \@resultsloop,
);
output_html_with_http_headers $query, $cookie, $template->output;

View file

@ -1,53 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
#use Data::Dumper;
#use Smart::Comments;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $tmpl_id = $query->param('tmpl_id');
my $tmpl_code = $query->param('tmpl_code');
my $tmpl_desc = $query->param('tmpl_desc');
my $page_height = $query->param('page_height');
my $page_width = $query->param('page_width');
my $label_height = $query->param('label_height');
my $label_width = $query->param('label_width');
my $topmargin = $query->param('topmargin');
my $leftmargin = $query->param('leftmargin');
my $cols = $query->param('cols');
my $rows = $query->param('rows');
my $colgap = $query->param('colgap');
my $rowgap = $query->param('rowgap');
my $font = $query->param('fonts');
my $fontsize = $query->param('fontsize');
my $units = $query->param('units');
my $active = $query->param('active');
my $prof_id = $query->param('prof_id');
my $dberror = SaveTemplate(
$tmpl_id, $tmpl_code, $tmpl_desc, $page_width,
$page_height, $label_width, $label_height, $topmargin,
$leftmargin, $cols, $rows, $colgap,
$rowgap, $font, $fontsize, $units
);
SetAssociatedProfile( $prof_id, $tmpl_id ) if $prof_id;
warn "Database returned the following error: $dberror" if $dberror;
print $query->redirect("./label-templates.pl");

View file

@ -1,77 +0,0 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Labels;
use HTML::Template::Pro;
use POSIX;
#use Data::Dumper;
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $op = $query->param('op');
my $tmpl_code = $query->param('tmpl_code');
my $tmpl_id = $query->param('tmpl_id');
my $width = $query->param('width');
my $height = $query->param('height');
my $topmargin = $query->param('topmargin');
my $leftmargin = $query->param('leftmargin');
my $columns = $query->param('columns');
my $rows = $query->param('rows');
my $colgap = $query->param('colgap');
my $rowgap = $query->param('rowgap');
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/label-templates.tmpl",
query => $query,
type => "intranet",
authnotrequired => 1,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my @resultsloop;
if ( $op eq 'set_active_template' ) {
SetActiveTemplate($tmpl_id);
}
elsif ( $op eq 'delete' ) {
DeleteTemplate($tmpl_id);
}
elsif ( $op eq 'save' ) {
SaveTemplate($tmpl_code);
}
@resultsloop = GetAllLabelTemplates();
# little block for displaying active layout/template/batch in templates
# ----------
my $batch_id = $query->param('batch_id');
my $active_layout = get_active_layout();
my $active_template = GetActiveLabelTemplate();
my $active_layout_name = $active_layout->{'layoutname'};
my $active_template_name = $active_template->{'tmpl_code'};
# ----------
$template->param(
batch_id => $batch_id,
active_layout_name => $active_layout_name,
active_template_name => $active_template_name,
resultsloop => \@resultsloop,
);
output_html_with_http_headers $query, $cookie, $template->output;

View file

@ -0,0 +1,82 @@
#!/usr/bin/perl
#
# Copyright 2007 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
# 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
use strict;
use warnings;
use Test::More tests => 22;
use C4::Context;
use Data::Dumper;
BEGIN {
use_ok('C4::Labels::Batch');
}
my $sth = C4::Context->dbh->prepare('SELECT branchcode FROM branches b LIMIT 0,1');
$sth->execute();
my $branch_code = $sth->fetchrow_hashref()->{'branchcode'};
diag sprintf('Database returned the following error: %s', $sth->errstr) if $sth->errstr;
my $expected_batch = {
items => [],
branch_code => $branch_code,
batch_stat => 0, # False if any data has changed and the db has not been updated
};
my $batch = 0;
my $item_number = 0;
diag "Testing Batch->new() method.";
ok($batch = C4::Labels::Batch->new(branch_code => $branch_code)) || diag "Batch->new() FAILED.";
my $batch_id = $batch->get_attr('batch_id');
$expected_batch->{'batch_id'} = $batch_id;
is_deeply($batch, $expected_batch) || diag "New batch object FAILED to verify.";
diag "Testing Batch->get_attr() method.";
foreach my $key (keys %{$expected_batch}) {
if (ref($expected_batch->{$key}) eq 'ARRAY') {
ok(ref($expected_batch->{$key}) eq ref($batch->get_attr($key))) || diag "Batch->get_attr() FAILED on attribute $key.";
}
else {
ok($expected_batch->{$key} eq $batch->get_attr($key)) || diag "Batch->get_attr() FAILED on attribute $key.";
}
}
diag "Testing Batch->add_item() method.";
my $sth1 = C4::Context->dbh->prepare('SELECT itemnumber FROM items LIMIT 0,10');
$sth1->execute();
while (my $row = $sth1->fetchrow_hashref()) {
diag sprintf('Database returned the following error: %s', $sth1->errstr) if $sth1->errstr;
ok($batch->add_item($row->{'itemnumber'}) eq 0 ) || diag "Batch->add_item() FAILED.";
$item_number = $row->{'itemnumber'};
}
diag "Testing Batch->retrieve() method.";
ok(my $saved_batch = C4::Labels::Batch->retrieve(batch_id => $batch_id)) || diag "Batch->retrieve() FAILED.";
is_deeply($saved_batch, $batch) || diag "Retrieved batch object FAILED to verify.";
diag "Testing Batch->remove_item() method.";
ok($batch->remove_item($item_number) eq 0) || diag "Batch->remove_item() FAILED.";
my $updated_batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
is_deeply($updated_batch, $batch) || diag "Updated batch object FAILED to verify.";
diag "Testing Batch->delete() method.";
my $del_results = $batch->delete();
ok($del_results eq 0) || diag "Batch->delete() FAILED.";

View file

@ -0,0 +1,100 @@
#!/usr/bin/perl
#
# Copyright 2007 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
# 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
use strict;
use warnings;
use Test::More tests => 28;
use C4::Context;
use Data::Dumper;
BEGIN {
use_ok('C4::Labels::Layout');
}
my $default_layout = {
barcode_type => 'CODE39',
printing_type => 'BAR',
layout_name => 'TEST',
guidebox => 0,
font => 'TR',
font_size => 3,
callnum_split => 0,
text_justify => 'L',
format_string => 'title, author, isbn, issn, itemtype, barcode, callnumber',
};
my $layout;
diag "Testing Layout->new() method.";
ok($layout = C4::Labels::Layout->new(layout_name => 'TEST')) || diag "Layout->new() FAILED";
is_deeply($layout, $default_layout) || diag "New layout object FAILED to verify.";
diag "Testing Layout->get_attr() method.";
foreach my $key (keys %{$default_layout}) {
ok($default_layout->{$key} eq $layout->get_attr($key)) || diag "Layout->get_attr() FAILED on attribute $key.";
}
diag "Testing Layout->set_attr() method.";
my $new_attr = {
barcode_type => 'CODE39',
printing_type => 'BIBBAR',
layout_name => 'TEST',
guidebox => 1,
font => 'TR',
font_size => 10,
callnum_split => 1,
text_justify => 'L',
format_string => 'callnumber, title, author, barcode',
};
foreach my $key (keys %{$new_attr}) {
$layout->set_attr($key => $new_attr->{$key});
ok($new_attr->{$key} eq $layout->get_attr($key)) || diag "Layout->set_attr() FAILED on attribute $key.";
}
diag "Testing Layout->save() method with a new object.";
my $sav_results = $layout->save();
ok($sav_results ne -1) || diag "Layout->save() FAILED";
my $saved_layout;
if ($sav_results ne -1) {
diag "Testing Layout->retrieve() method.";
$new_attr->{'layout_id'} = $sav_results;
ok($saved_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results)) || diag "Layout->retrieve() FAILED";
is_deeply($saved_layout, $new_attr) || diag "Retrieved layout object FAILED to verify.";
}
diag "Testing Layout->save() method with an updated object.";
$saved_layout->set_attr(font => 'C');
my $upd_results = $saved_layout->save();
ok($upd_results ne -1) || diag "Layout->save() FAILED";
my $updated_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results);
is_deeply($updated_layout, $saved_layout) || diag "Updated layout object FAILED to verify.";
diag "Testing Layout->get_text_wrap_cols() method.";
ok($updated_layout->get_text_wrap_cols(label_width => 180, left_text_margin => 18) eq 21) || diag "Layout->get_text_wrap_cols() FAILED.";
diag "Testing Layout->delete() method.";
my $del_results = $updated_layout->delete();
ok($del_results eq 0) || diag "Layout->delete() FAILED";

View file

@ -0,0 +1,95 @@
#!/usr/bin/perl
#
# Copyright 2007 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
# 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
use strict;
use warnings;
use Test::More tests => 25;
use C4::Context;
use Data::Dumper;
BEGIN {
use_ok('C4::Labels::Profile');
}
my $expected_profile = {
printer_name => 'Circulation Desk',
template_id => '',
paper_bin => 'bypass',
offset_horz => 0,
offset_vert => 0,
creep_horz => 0,
creep_vert => 0,
units => 'POINT',
};
my $err = 0;
diag "Testing Profile->new() method.";
ok(my $profile = C4::Labels::Profile->new(printer_name => 'Circulation Desk',paper_bin => 'bypass')) || diag"Profile->new() FAILED.";
is_deeply($profile, $expected_profile) || diag "New profile object FAILED to verify.";
diag "Testing Profile->get_attr() method.";
foreach my $key (keys %{$expected_profile}) {
ok($expected_profile->{$key} eq $profile->get_attr($key)) || diag "Profile->get_attr() FAILED on attribute $key.";
}
diag "Testing Profile->set_attr() method.";
my $new_attr = {
printer_name => 'Cataloging Desk',
template_id => '1',
paper_bin => 'tray 1',
offset_horz => 0.3,
offset_vert => 0.85,
creep_horz => 0.156,
creep_vert => 0.67,
units => 'INCH',
};
foreach my $key (keys %{$new_attr}) {
$err = $profile->set_attr($key, $new_attr->{$key});
ok(($new_attr->{$key} eq $profile->get_attr($key)) && ($err lt 1)) || diag "Profile->set_attr() FAILED on attribute $key.";
}
diag "Testing Profile->save() method with a new object.";
my $sav_results = $profile->save();
ok($sav_results ne -1) || diag "Profile->save() FAILED.";
my $saved_profile;
if ($sav_results ne -1) {
diag "Testing Profile->retrieve() method.";
$new_attr->{'profile_id'} = $sav_results;
ok($saved_profile = C4::Labels::Profile->retrieve(profile_id => $sav_results)) || diag "Profile->retrieve() FAILED.";
is_deeply($saved_profile, $new_attr) || diag "Retrieved profile object FAILED to verify.";
}
diag "Testing Profile->save() method with an updated object.";
$err = 0; # Reset error code
$err = $saved_profile->set_attr(units => 'CM');
my $upd_results = $saved_profile->save();
ok(($upd_results ne -1) && ($err lt 1)) || diag "Profile->save() FAILED.";
my $updated_profile = C4::Labels::Profile->retrieve(profile_id => $sav_results);
is_deeply($updated_profile, $saved_profile) || diag "Updated layout object FAILED to verify.";
diag "Testing Profile->delete() method.";
my $del_results = $updated_profile->delete();
ok($del_results ne -1) || diag "Profile->delete() FAILED.";

View file

@ -0,0 +1,133 @@
#!/usr/bin/perl
#
# Copyright 2007 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
# 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
use strict;
use warnings;
use Test::More tests => 52;
use C4::Context;
use Data::Dumper;
BEGIN {
use_ok('C4::Labels::Template');
}
my $expect_template = {
profile_id => 0,
template_code => 'DEFAULT TEMPLATE',
template_desc => 'Default description',
page_width => 8.5,
page_height => 0,
label_width => 0,
label_height => 0,
top_text_margin => 0,
left_text_margin => 0,
top_margin => 0,
left_margin => 0,
cols => 3,
rows => 0,
col_gap => 0,
row_gap => 0,
units => 'POINT',
template_stat => 0,
};
my $template;
diag "Testing Template->new() method.";
ok($template = C4::Labels::Template->new(page_width => 8.5,cols => 3)) || diag "Template->new() FAILED.";
is_deeply($template, $expect_template) || diag "New template object FAILED to verify.";
diag "Testing Template->get_attr() method.";
foreach my $key (keys %{$expect_template}) {
ok($expect_template->{$key} eq $template->get_attr($key)) || diag "Template->get_attr() FAILED on attribute $key.";
}
diag "Testing Template->set_attr() method.";
my $new_attr = {
profile_id => 0,
template_code => 'Avery 5160 | 1 x 2-5/8',
template_desc => '3 columns, 10 rows of labels',
page_width => 8.5,
page_height => 11,
label_width => 2.63,
label_height => 1,
top_text_margin => 0.139,
left_text_margin => 0.0417,
top_margin => 0.35,
left_margin => 0.23,
cols => 3,
rows => 10,
col_gap => 0.13,
row_gap => 0,
units => 'INCH',
template_stat => 1,
};
foreach my $key (keys %{$new_attr}) {
next if ($key eq 'template_stat');
$template->set_attr($key, $new_attr->{$key});
ok($new_attr->{$key} eq $template->get_attr($key)) || diag "Template->set_attr() FAILED on attribute $key.";
}
diag "Testing Template->save() method with a new object.";
my $sav_results = $template->save();
ok($sav_results ne -1) || diag "Template->save() FAILED.";
my $saved_template;
if ($sav_results ne -1) {
diag "Testing Template->retrieve() method.";
$new_attr->{'template_id'} = $sav_results;
ok($saved_template = C4::Labels::Template->retrieve(template_id => $sav_results)) || diag "Template->retrieve() FAILED.";
is_deeply($saved_template, $new_attr) || diag "Retrieved template object FAILED to verify.";
}
diag "Testing Template->save method with an updated object.";
$saved_template->set_attr(template_desc => 'A test template');
my $upd_results = $saved_template->save();
ok($upd_results ne -1) || diag "Template->save() FAILED.";
my $updated_template = C4::Labels::Template->retrieve(template_id => $sav_results);
is_deeply($updated_template, $saved_template) || diag "Updated template object FAILED to verify.";
diag "Testing Template->retrieve() convert points option.";
my $conv_template = C4::Labels::Template->retrieve(template_id => $sav_results, convert => 1);
my $expect_conv = {
page_width => 612,
page_height => 792,
label_width => 189.36,
label_height => 72,
top_text_margin => 10.008,
left_text_margin => 3.0024,
top_margin => 25.2,
left_margin => 16.56,
col_gap => 9.36,
row_gap => 0,
};
foreach my $key (keys %{$expect_conv}) {
ok($expect_conv->{$key} eq $conv_template->get_attr($key)) || diag "Template->retrieve() convert points option FAILED. Expected " . $expect_conv->{$key} . " but got " . $conv_template->get_attr($key) . ".";
}
diag "Testing Template->delete() method.";
my $del_results = $updated_template->delete();
ok($del_results ne -1) || diag "Template->delete() FAILED.";

View file

@ -33,7 +33,8 @@ use C4::Biblio;
use C4::ImportBatch;
use C4::Matcher;
use C4::BackgroundJob;
use C4::Labels qw(add_batch);
use C4::Labels::Batch 1.000000;
use C4::Branch qw(get_branch_code_from_name);
my $script_name = "/cgi-bin/koha/tools/manage-marc-import.pl";
@ -63,7 +64,16 @@ my $dbh = C4::Context->dbh;
if ($op eq "create_labels") {
#create a batch of labels, then lose $op & $import_batch_id so we get back to import batch list.
my $label_batch_id = create_labelbatch_from_importbatch($import_batch_id);
$template->param( label_batch => $label_batch_id );
if ($label_batch_id == -1) {
$template->param( label_batch_msg => "Error attempting to create label batch. Please ask your system administrator to check the log for more details.",
message_type => 'alert',
);
}
else {
$template->param( label_batch_msg => "Label batch #$label_batch_id created.",
message_type => 'dialog',
);
}
$op='';
$import_batch_id='';
}
@ -166,9 +176,22 @@ sub redo_matching {
sub create_labelbatch_from_importbatch {
my ($batch_id) = @_;
my $err = undef;
my $branch_code = get_branch_code_from_name($template->param('LoginBranchname'));
my $batch = C4::Labels::Batch->new(branch_code => $branch_code);
my @items = GetItemNumbersFromImportBatch($batch_id);
my $labelbatch = add_batch('labels',\@items);
return $labelbatch;
if (grep{$_ == 0} @items) {
warn sprintf('create_labelbatch_from_importbatch() : Call to C4::ImportBatch::GetItemNumbersFromImportBatch returned no item number(s) from import batch #%s.', $batch_id);
return -1;
}
foreach my $item_number (@items) {
$err = $batch->add_item($item_number);
if ($err == -1) {
warn sprintf('create_labelbatch_from_importbatch() : Error attempting to add item #%s of import batch #%s to label batch.', $item_number, $batch_id);
return -1;
}
}
return $batch->get_attr('batch_id');
}
sub import_batches_list {