[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/barcodes barcodesGenerator.pl barcodes.pl ...
From: |
paul poulain |
Subject: |
[Koha-cvs] koha/barcodes barcodesGenerator.pl barcodes.pl ... |
Date: |
Fri, 09 Mar 2007 14:31:28 +0000 |
CVSROOT: /sources/koha
Module name: koha
Changes by: paul poulain <tipaul> 07/03/09 14:31:28
Modified files:
barcodes : barcodesGenerator.pl barcodes.pl label-home.pl
label-item-search.pl label-manager.pl
label-print-opus-pdf.pl label-print-pdf.pl
label-print.pl pdfViewer.pl printerConfig.pl
test.textblock.pl
Log message:
rel_3_0 moved to HEAD
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/barcodesGenerator.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/barcodes.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-home.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-item-search.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-opus-pdf.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/pdfViewer.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/printerConfig.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/test.textblock.pl?cvsroot=koha&r1=1.1&r2=1.2
Patches:
Index: barcodesGenerator.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/barcodesGenerator.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- barcodesGenerator.pl 12 Sep 2005 01:52:41 -0000 1.5
+++ barcodesGenerator.pl 9 Mar 2007 14:31:27 -0000 1.6
@@ -27,23 +27,25 @@
use CGI;
use C4::Context;
use C4::Output;
-use HTML::Template;
+
+
+#FIXME : module deprecated ?
use PDF::API2;
use PDF::API2::Page;
-use PDF::API2::PDF::Utils;
+use PDF::API2::Util;
use C4::Barcodes::PrinterConfig;
use Time::localtime;
-
# This function returns the path to deal with the correct files, considering
# templates set and language.
sub getPath {
my $type = shift @_;
my $templatesSet = C4::Context->preference('template');
my $lang = C4::Context->preference('opaclanguages');
- if ($type eq "intranet") {
+ if ( $type eq "intranet" ) {
return
"$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
- } else {
+ }
+ else {
return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
}
}
@@ -66,18 +68,18 @@
# Save settings to a configuration file. It delete previous configuration
settings.
sub saveConfToFile {
my $fileName = shift @_;
- my %keyValues = %{shift @_};
+ my %keyValues = %{ shift @_ };
my $i;
open FILE, ">$fileName";
- my $i;
- foreach $i (keys(%keyValues)) {
- print FILE $i." = ".$keyValues{$i}."\n";
+ foreach $i ( keys(%keyValues) ) {
+ print FILE $i . " = " . $keyValues{$i} . "\n";
}
close FILE;
}
# Load the config file.
-my $filenameConf =
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+ &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
my %labelConfig = &loadConfFromFile($filenameConf);
# Creates a CGI object and take its parameters
@@ -99,18 +101,20 @@
my $sum = 0;
my $odd_parity = 1;
my $i;
- for ($i = length($code) - 1; $i >= 0; $i--){
- if ( $odd_parity ) {
- $sum = $sum + ( 3 * substr($code, $i, 1) );
- } else {
- $sum = $sum + substr($code, $i, 1); }
+ for ( $i = length($code) - 1 ; $i >= 0 ; $i-- ) {
+ if ($odd_parity) {
+ $sum = $sum + ( 3 * substr( $code, $i, 1 ) );
+ }
+ else {
+ $sum = $sum + substr( $code, $i, 1 );
+ }
$odd_parity = !$odd_parity;
}
- my $check_digit = 10 - ($sum%10);
- if ($check_digit==10) {
- $check_digit=0;
+ my $check_digit = 10 - ( $sum % 10 );
+ if ( $check_digit == 10 ) {
+ $check_digit = 0;
}
- return $code.$check_digit;
+ return $code . $check_digit;
}
my $currentCode = shift @_;
@@ -120,61 +124,92 @@
# Assigns a temporary name to the PDF file
sub assingFilename {
- my ($from, $to) = @_;
+ my ( $from, $to ) = @_;
my $ip = $cgi->remote_addr();
- my $random = int(rand(1000000));
+ my $random = int( rand(1000000) );
my $timeObj = localtime();
- my ($day, $month, $year, $hour, $min, $sec) = ($timeObj->mday,
+ my ( $day, $month, $year, $hour, $min, $sec ) = (
+ $timeObj->mday,
$timeObj->mon + 1,
$timeObj->year + 1900,
-
$timeObj->hour,
-
$timeObj->min,
-
$timeObj->sec);
- my $tmpFileName = $random.'-'.$ip.'-(From '.$from.' to
'.$to.')-['.$day.'.'.$month.'.'.$year.']-['.$hour.':'.$min.':'.$sec.'].pdf';
+ $timeObj->hour, $timeObj->min, $timeObj->sec
+ );
+ my $tmpFileName =
+ $random . '-' . $ip
+ . '-(From '
+ . $from . ' to '
+ . $to . ')-['
+ . $day . '.'
+ . $month . '.'
+ . $year . ']-['
+ . $hour . ':'
+ . $min . ':'
+ . $sec . '].pdf';
return $tmpFileName;
}
+
sub getCallnum {
-#grabs a callnumber for the specified barcode
-my ($barcode) = @_;
-my $query = "select dewey from items,biblioitems where
items.biblionumber=biblioitems.biblionumber and items.barcode=?";
-my $dbh = C4::Context->dbh;
-my $sth = $dbh->prepare($query);
-$sth->execute($barcode);
-my ($callnum) = $sth->fetchrow_array();
-warn "Call number is:".$barcode;
-return $callnum;
+
+ #grabs a callnumber for the specified barcode
+ my ($barcode) = @_;
+ my $query =
+"select dewey from items,biblioitems where
items.biblionumber=biblioitems.biblionumber and items.barcode=?";
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare($query);
+ $sth->execute($barcode);
+ my ($callnum) = $sth->fetchrow_array();
+ warn "Call number is:" . $barcode;
+ return $callnum;
}
+
# Takes inventary codes from database and if they are between
# the interval specify by parameters, it generates the correspond barcodes
sub barcodesGenerator {
- my ($from, $to, $rangeType, $individualCodes,$text_under_label) = @_;
+ my ( $from, $to, $rangeType, $individualCodes, $text_under_label ) = @_;
+
# Returns a database handler
my $dbh = C4::Context->dbh;
+
# Create the query to database
# Assigns a temporary filename for the pdf file
- my $tmpFileName = &assingFilename($from, $to);
+ my $tmpFileName = &assingFilename( $from, $to );
+
# warn "range type: ".$rangeType;
- if ($rangeType eq 'continuous') {
+ if ( $rangeType eq 'continuous' ) {
+
# Set the temp directory for pdf´s files
- if (!defined($ENV{'TEMP'})) {
+ if ( !defined( $ENV{'TEMP'} ) ) {
$ENV{'TEMP'} = '/tmp/';
}
- $tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+ $tmpFileName = $ENV{'TEMP'} . $tmpFileName;
+
# Creates a PDF object
- my $pdf = PDF::API2->new(-file => $tmpFileName);
+ my $pdf = PDF::API2->new( -file => $tmpFileName );
+
# Set the positions where barcodes are going to be placed
-
C4::Barcodes::PrinterConfig::setPositionsForX($labelConfig{'marginLeft'},
$labelConfig{'labelWidth'}, $labelConfig{'columns'}, $labelConfig{'pageType'});
-
C4::Barcodes::PrinterConfig::setPositionsForY($labelConfig{'marginBottom'},
$labelConfig{'labelHeigth'}, $labelConfig{'rows'}, $labelConfig{'pageType'});
+ C4::Barcodes::PrinterConfig::setPositionsForX(
+ $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'},
+ $labelConfig{'columns'}, $labelConfig{'pageType'}
+ );
+ C4::Barcodes::PrinterConfig::setPositionsForY(
+ $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'},
+ $labelConfig{'rows'}, $labelConfig{'pageType'}
+ );
+
# Creates a font object
my $tr = $pdf->corefont('Helvetica-Bold');
+
# Barcode position
- my ($page, $gfx, $text);
- for (my $code=$from; $code<=$to; $code++) {
+ my ( $page, $gfx, $text );
+ for ( my $code = $from ; $code <= $to ; $code++ ) {
+
# Generetase checksum
my $codeC = &checksum($code);
+
# Generate the corresponde barcode to $code
# warn "Code is :-->".$codeC."<--";
- my $barcode = $pdf->barcode(-font => $tr, # The
font object to use
+ my $barcode = $pdf->barcode(
+ -font => $tr, # The font object to use
-type => 'ean128', # Standard of codification
-code => $codeC, # Text to codify
-extn => '012345', # Barcode extension (if it is aplicable)
@@ -187,69 +222,97 @@
-text => ''
);
- (my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label) =
C4::Barcodes::PrinterConfig::getLabelPosition(
-
$label,
-
$pdf,
-
$page,
-
$gfx,
-
$text,
-
$tr,
-
$pageType);
+ ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) =
+ C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf,
+ $page, $gfx, $text, $tr, $pageType );
+
# Assigns a barcodes to $gfx
- $gfx->barcode($barcode, $x, $y ,
(72/$labelConfig{'systemDpi'}));
+ $gfx->barcode( $barcode, $x, $y,
+ ( 72 / $labelConfig{'systemDpi'} ) );
+
# Assigns the additional information to the barcode
(Legend)
- $text->translate($x - 48, $y - 22);
- warn "code is ".$codeC;
+ $text->translate( $x - 48, $y - 22 );
+
+ #warn "code is ".$codeC;
if ($text_under_label) {
$text->text($text_under_label);
- } else {
- $text->text(getCallnum($code));
}
+ else {
+ $text->text( getCallnum($code) );
}
+ }
+
# Writes the objects added in $gfx to $page
- $pdf->finishobjects($page,$gfx, $text);
+ $pdf->finishobjects( $page, $gfx, $text );
+
# Save changes to the PDF
$pdf->saveas;
+
# Close the conection with the PDF file
$pdf->end;
+
# Show the PDF file
- print
$cgi->redirect("/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
- } else {
+ print $cgi->redirect(
+ "/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
+ }
+ else {
my $rangeCondition;
- if ($individualCodes ne "") {
+ if ( $individualCodes ne "" ) {
$rangeCondition = "AND (I.barcode IN " .
$individualCodes . ")";
- } else {
- $rangeCondition = "AND (I.barcode >= " . $from . " AND
I.barcode <=" . $to . " )";
}
- warn "above the query";
- my $query = "SELECT CONCAT('$numbersystem',REPEAT('0',((12 -
LENGTH('$numbersystem')) - LENGTH(I.barcode))), I.barcode) AS Codigo, I.dewey
as dewey B.title, B.author FROM biblio B, items I WHERE (I.biblionumber =
B.biblioNumber ) " .$rangeCondition. " AND (I.barcode <> 'FALTA') ORDER BY
Codigo";
+ else {
+ $rangeCondition =
+ "AND (I.barcode >= " . $from . " AND I.barcode <=" . $to . " )";
+ }
+
+ my $query =
+"SELECT CONCAT('$numbersystem',REPEAT('0',((12 - LENGTH('$numbersystem')) -
LENGTH(I.barcode))), I.barcode) AS Codigo, B.title, B.author FROM biblio B,
items I WHERE (I.biblionumber = B.biblioNumber ) "
+ . $rangeCondition
+ . " AND (I.barcode <> 'FALTA') ORDER BY Codigo";
# Prepare the query
my $sth = $dbh->prepare($query);
+
# Executes the query
$sth->execute;
- if ($sth->rows) { # There are inventary codes
+ if ( $sth->rows ) { # There are inventary codes
# Set the temp directory for pdf´s files
- if (!defined($ENV{'TEMP'})) {
+ if ( !defined( $ENV{'TEMP'} ) ) {
$ENV{'TEMP'} = '/tmp/';
}
+
# Assigns a temporary filename for the pdf file
- my $tmpFileName = &assingFilename($from, $to);
- $tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+ my $tmpFileName = &assingFilename( $from, $to );
+ $tmpFileName = $ENV{'TEMP'} . $tmpFileName;
+
# Creates a PDF object
- my $pdf = PDF::API2->new(-file => $tmpFileName);
+ my $pdf = PDF::API2->new( -file => $tmpFileName );
+
# Set the positions where barcodes are going to be
placed
-
C4::Barcodes::PrinterConfig::setPositionsForX($labelConfig{'marginLeft'},
$labelConfig{'labelWidth'}, $labelConfig{'columns'}, $labelConfig{'pageType'});
-
C4::Barcodes::PrinterConfig::setPositionsForY($labelConfig{'marginBottom'},
$labelConfig{'labelHeigth'}, $labelConfig{'rows'}, $labelConfig{'pageType'});
+ C4::Barcodes::PrinterConfig::setPositionsForX(
+ $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'},
+ $labelConfig{'columns'}, $labelConfig{'pageType'}
+ );
+ C4::Barcodes::PrinterConfig::setPositionsForY(
+ $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'},
+ $labelConfig{'rows'}, $labelConfig{'pageType'}
+ );
+
# Creates a font object
my $tr = $pdf->corefont('Helvetica-Bold');
+
# Barcode position
- my ($page, $gfx, $text);
- while (my ($code,$dewey,$title,$author) =
$sth->fetchrow_array) {
+ my ( $page, $gfx, $text );
+ while ( my ( $code, $dewey, $title, $author ) =
+ $sth->fetchrow_array )
+ {
+
# Generetase checksum
$code = &checksum($code);
+
# Generate the corresponde barcode to $code
- my $barcode = $pdf->barcode(-font => $tr,
# The font object to use
+ my $barcode = $pdf->barcode(
+ -font => $tr, # The font object to use
-type => 'ean13', # Standard of codification
-code => $code, # Text to codify
-extn => '012345', # Barcode extension (if it is aplicable)
@@ -262,36 +325,43 @@
-text => ''
);
- (my $x, my $y, $pdf, $page, $gfx, $text, $tr,
$label) = C4::Barcodes::PrinterConfig::getLabelPosition(
-
$label,
-
$pdf,
-
$page,
-
$gfx,
-
$text,
-
$tr,
-
$pageType);
+ ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) =
+ C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf,
+ $page, $gfx, $text, $tr, $pageType );
+
# Assigns a barcodes to $gfx
- $gfx->barcode($barcode, $x, $y ,
(72/$labelConfig{'systemDpi'}));
+ $gfx->barcode( $barcode, $x, $y,
+ ( 72 / $labelConfig{'systemDpi'} ) );
+
# Assigns the additional information to the
barcode (Legend)
- $text->translate($x - 48, $y - 22);
+ $text->translate( $x - 48, $y - 22 );
if ($text_under_label) {
$text->text($text_under_label);
- } else {
- warn "here a dewey:".$dewey;
- $text->text(substr $dewey, 0, 30);
- $text->translate($x - 48, $y - 29);
+ }
+ else {
+ $text->text( substr $title, 0, 30 );
+ $text->translate( $x - 48, $y - 29 );
+
#$text->text(substr $author, 0, 30);
+ $text->text( substr $author, 0, 30 );
}
}
+
# Writes the objects added in $gfx to $page
- $pdf->finishobjects($page,$gfx, $text);
+ $pdf->finishobjects( $page, $gfx, $text );
+
# Save changes to the PDF
$pdf->saveas;
+
# Close the conection with the PDF file
$pdf->end;
+
# Show the PDF file
- print
$cgi->redirect("/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
- } else {
+ print $cgi->redirect(
+
"/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
+ }
+ else {
+
# Rollback and shows the error legend
print
$cgi->redirect("/cgi-bin/koha/barcodes/barcodes.pl?error=1");
}
@@ -299,4 +369,5 @@
}
}
-barcodesGenerator($from, $to, $rangeType, $individualCodes,$text_under_label);
+barcodesGenerator( $from, $to, $rangeType, $individualCodes,
+ $text_under_label );
Index: barcodes.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/barcodes.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- barcodes.pl 4 Jul 2006 14:36:51 -0000 1.5
+++ barcodes.pl 9 Mar 2007 14:31:27 -0000 1.6
@@ -25,22 +25,19 @@
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;
-use C4::Database;
-use HTML::Template;
use C4::Context;
use C4::Barcodes::PrinterConfig;
-
-
# This function returns the path to deal with the correct files, considering
# templates set and language.
sub getPath {
my $type = shift @_;
my $templatesSet = C4::Context->preference('template');
my $lang = C4::Context->preference('opaclanguages');
- if ($type eq "intranet") {
+ if ( $type eq "intranet" ) {
return
"$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
- } else {
+ }
+ else {
return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
}
}
@@ -63,85 +60,103 @@
# Save settings to a configuration file. It delete previous configuration
settings.
sub saveConfToFile {
my $fileName = shift @_;
- my %keyValues = %{shift @_};
+ my %keyValues = %{ shift @_ };
my $i;
open FILE, ">$fileName";
- my $i;
- foreach $i (keys(%keyValues)) {
- print FILE $i." = ".$keyValues{$i}."\n";
+ foreach $i ( keys(%keyValues) ) {
+ print FILE $i . " = " . $keyValues{$i} . "\n";
}
close FILE;
}
# Load the config file.
-my $filenameConf =
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+ &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
my %labelConfig = &loadConfFromFile($filenameConf);
my $input = new CGI;
+
# Defines type of page to use in the printer process
-my @labelTable = C4::Barcodes::PrinterConfig::labelsPage($labelConfig{'rows'},
$labelConfig{'columns'});
+my @labelTable =
+ C4::Barcodes::PrinterConfig::labelsPage( $labelConfig{'rows'},
+ $labelConfig{'columns'} );
# It creates a list of posible intervals to choose codes to generate
-my %list = ('continuous' => 'Continuous Range of items', 'individuals' =>
'Individual Codes');
+my %list = (
+ 'continuous' => 'Continuous Range of items',
+ 'individuals' => 'Individual Codes'
+);
my @listValues = keys(%list);
-my $rangeType = CGI::scrolling_list(-name => 'rangeType',
+my $rangeType = CGI::scrolling_list(
+ -name => 'rangeType',
-values => address@hidden,
-labels => \%list,
-size => 1,
-default => ['continuous'],
-multiple => 0,
-id =>
"rangeType",
-
-onChange => "changeRange(this)");
+ -onChange => "changeRange(this)"
+);
+
# It creates a list of posible standard codifications. First checks if the
user has just added a new code.
-if ($input->param('addCode')) {
+if ( $input->param('addCode') ) {
my $newCountryName = $input->param('countryName');
my $newCountryCode = $input->param('countryCode');
- my $countryCodesFilename =
&getPath("intranet")."/includes/countryCodes/countryCodes.dat";
+ my $countryCodesFilename =
+ &getPath("intranet") . "/includes/countryCodes/countryCodes.dat";
open COUNTRY_CODES, ">>$countryCodesFilename";
- print COUNTRY_CODES $newCountryCode." = ".$newCountryName."\n";
+ print COUNTRY_CODES $newCountryCode . " = " . $newCountryName . "\n";
close COUNTRY_CODES;
}
# Takes the country codes from a file and use them to set the country list.
-my $countryCodes =
&getPath("intranet")."/includes/countryCodes/countryCodes.dat";
-my %list = &loadConfFromFile($countryCodes);
+my $countryCodes =
+ &getPath("intranet") . "/includes/countryCodes/countryCodes.dat";
+%list = &loadConfFromFile($countryCodes);
@listValues = keys(%list);
-my $number_system = CGI::scrolling_list(-name => 'numbersystem',
+my $number_system = CGI::scrolling_list(
+ -name => 'numbersystem',
-values => address@hidden,
-labels => \%list,
-size => 1,
- -multiple => 0);
+ -multiple => 0
+);
# Set the script name
my $script_name = "/cgi-bin/koha/barcodes/barcodesGenerator.pl";
-
# Get the template to use
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "barcodes/barcodes.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/barcodes.tmpl",
type => "intranet",
query => $input,
authnotrequired => 0,
- flagsrequired => {parameters => 1},
+ flagsrequired => { tools => 1 },
debug => 1,
- });
+ }
+);
# Replace the template values with the real ones
-$template->param(SCRIPT_NAME => $script_name);
-$template->param(NUMBER_SYSTEM => $number_system);
-$template->param(PAGES => $labelConfig{'pageType'});
-$template->param(RANGE_TYPE => $rangeType);
-$template->param(LABEL_TABLE => address@hidden);
-$template->param(COL_SPAN => $labelConfig{'columns'});
-if ($input->param('error')) {
- $template->param(ERROR => 1);
-} else {
- $template->param(ERROR => 0);
+$template->param( SCRIPT_NAME => $script_name );
+$template->param( NUMBER_SYSTEM => $number_system );
+$template->param( PAGES => $labelConfig{'pageType'} );
+$template->param( RANGE_TYPE => $rangeType );
+$template->param( LABEL_TABLE => address@hidden );
+$template->param( COL_SPAN => $labelConfig{'columns'} );
+if ( $input->param('error') ) {
+ $template->param( ERROR => 1 );
}
-$template->param(intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
+else {
+ $template->param( ERROR => 0 );
+}
+$template->param(
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet =>
C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
- );
+);
+
# Shows the template with the real values replaced
output_html_with_http_headers $input, $cookie, $template->output;
Index: label-home.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-home.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- label-home.pl 19 Jul 2006 01:09:42 -0000 1.3
+++ label-home.pl 9 Mar 2007 14:31:27 -0000 1.4
@@ -1,14 +1,28 @@
#!/usr/bin/perl
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
use strict;
use CGI;
use C4::Auth;
use C4::Output;
+use C4::Labels;
use C4::Interface::CGI::Output;
use C4::Context;
-use HTML::Template;
-#use Data::Dumper;
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -17,28 +31,30 @@
query => $query,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { catalogue => 1 },
+ flagsrequired => { tools => 1 },
debug => 1,
}
);
-my $dbh = C4::Context->dbh;
-my $query2 = "SELECT * FROM labels_conf LIMIT 1";
-my $sth = $dbh->prepare($query2);
-$sth->execute();
+my $data = get_label_options();
-my $data = $sth->fetchrow_hashref;
-$sth->finish;
+my $active_template = GetActiveLabelTemplate();
+my @label_templates = GetAllLabelTemplates();
$template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
$data->{'printingtype'} = 'both' if ( !$data->{'printingtype'} );
$template->param( "printingtype_$data->{'printingtype'}" => 1 );
+$template->param( "papertype_$data->{'papertype'}" => 1 );
$template->param( "$data->{'barcodetype'}_checked" => 1 );
+
$template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 );
$template->param(
itemtype => $data->{'itemtype'},
+ active_template => $data->{'active_template'},
+ label_templates => address@hidden,
+
papertype => $data->{'papertype'},
author => $data->{'author'},
barcode => $data->{'barcode'},
@@ -49,6 +65,10 @@
dewey => $data->{'dewey'},
class => $data->{'class'},
startrow => $data->{'startrow'},
+ subclass => $data->{'subclass'},
+ itemcallnumber => $data->{'itemcallnumber'},
+ startlabel => $data->{'startlabel'},
+ fontsize => $active_template->{'fontsize'},
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
Index: label-item-search.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-item-search.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- label-item-search.pl 10 Aug 2006 13:00:27 -0000 1.4
+++ label-item-search.pl 9 Mar 2007 14:31:27 -0000 1.5
@@ -23,15 +23,13 @@
use CGI;
use C4::Koha;
use C4::Auth;
-use HTML::Template;
+
use C4::Context;
-use C4::Search;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::Acquisition;
-#use C4::SearchMarc;
use C4::Koha; # XXX subfield_is_koha_internal_p
# Creates a scrolling list with the associated default value.
@@ -88,8 +86,7 @@
query => $query,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { borrowers => 1 },
- flagsrequired => { catalogue => 1 },
+ flagsrequired => { tools => 1 },
debug => 1,
}
);
@@ -149,9 +146,10 @@
for ( $i = 0 ; $i <= ( $total - 1 ) ; $i++ )
{ #total-1 coz the array starts at 0
#warn $i;
- #warn Dumper $results->[$i]{'bibid'};
+
my $type = 'intra';
- my @item_results = &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type
);
+ my @item_results =
+ &GetItemsInfo( $results->[$i]{'biblionumber'}, $type );
foreach my $item (@item_results) {
@@ -183,7 +181,7 @@
query => $query,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { catalogue => 1 },
+ flagsrequired => { tools => 1 },
debug => 1,
}
);
Index: label-manager.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-manager.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- label-manager.pl 19 Jul 2006 01:09:42 -0000 1.4
+++ label-manager.pl 9 Mar 2007 14:31:27 -0000 1.5
@@ -1,11 +1,27 @@
#!/usr/bin/perl
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
use strict;
use CGI;
use C4::Auth;
+use C4::Labels;
use C4::Output;
use C4::Interface::CGI::Output;
-use HTML::Template;
+
use POSIX;
my $dbh = C4::Context->dbh;
@@ -18,15 +34,18 @@
my $bcn = $query->param('bcn');
my $dcn = $query->param('dcn');
my $classif = $query->param('classif');
+my $itemcallnumber = $query->param('itemcallnumber');
+my $subclass = $query->param('subclass');
my $author = $query->param('author');
-my $papertype = $query->param('papertype');
+my $tmpl_id = $query->param('tmpl_id');
my $itemnumber = $query->param('itemnumber');
my $summary = $query->param('summary');
-my $startrow = $query->param('startrow');
+my $startlabel = $query->param('startlabel');
my $printingtype = $query->param('printingtype');
my $guidebox = $query->param('guidebox');
+my $fontsize = $query->param('fontsize');
-warn $printingtype;
+#warn "ID =$tmpl_id";
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -34,28 +53,18 @@
query => $query,
type => "intranet",
authnotrequired => 1,
- flagsrequired => { catalogue => 1 },
+ flagsrequired => { tools => 1 },
debug => 1,
}
);
if ( $op eq 'save_conf' ) {
- my $query2 = "DELETE FROM labels_conf";
- my $sth2 = $dbh->prepare($query2);
- $sth2->execute();
- $sth2->finish;
- my $query2 = "INSERT INTO labels_conf
- ( barcodetype, title, isbn, itemtype, barcode,
- dewey, class, author, papertype, printingtype,
- guidebox, startrow)
- values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
- my $sth2 = $dbh->prepare($query2);
- $sth2->execute(
+ SaveConf(
$barcodetype, $title, $isbn, $itemtype,
- $bcn, $dcn, $classif, $author,
- $papertype, $printingtype, $guidebox, $startrow
+ $bcn, $dcn, $classif, $subclass,
+ $itemcallnumber, $author, $tmpl_id, $printingtype,
+ $guidebox, $startlabel
);
- $sth2->finish;
}
elsif ( $op eq 'add' ) {
@@ -115,33 +124,29 @@
# this script can be run from the side nav, and is not passed a value for
$startrow
# so lets get it from the DB
-if ( !$startrow ) {
- my $dbh = C4::Context->dbh;
- my $query2 = "SELECT * FROM labels_conf LIMIT 1";
- my $sth = $dbh->prepare($query2);
- $sth->execute();
-
- my $data = $sth->fetchrow_hashref;
- $startrow = $data->{'startrow'};
- $sth->finish;
-}
+my $dbh = C4::Context->dbh;
+my $query2 = "SELECT * FROM labels_conf LIMIT 1";
+my $sth = $dbh->prepare($query2);
+$sth->execute();
+
+my $data = $sth->fetchrow_hashref;
+$sth->finish;
#calc-ing number of sheets
-my $number_of_results = scalar @resultsloop;
-my $sheets_needed = ( ( --$number_of_results + $startrow ) / 8 );
-$sheets_needed = ceil($sheets_needed); # rounding up int's
-
-my $tot_labels = ( $sheets_needed * 8 );
-my $start_results = ( $number_of_results + $startrow );
-my $labels_remaining = ( $tot_labels - $start_results );
+
+#$sheets_needed = ceil($sheets_needed); # rounding up int's
+
+#my $tot_labels = ( $sheets_needed * 8 );
+#my $start_results = ( $number_of_results + $startrow );
+#my $labels_remaining = ( $tot_labels - $start_results );
$template->param(
resultsloop => address@hidden,
- startrow => $startrow,
- sheets => $sheets_needed,
- labels_remaining => $labels_remaining,
+ # startrow => $startrow,
+ # sheets => $sheets_needed,
+ # labels_remaining => $labels_remaining,
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
Index: label-print-opus-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-opus-pdf.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- label-print-opus-pdf.pl 21 Jul 2006 13:55:57 -0000 1.2
+++ label-print-opus-pdf.pl 9 Mar 2007 14:31:27 -0000 1.3
@@ -1,62 +1,190 @@
#!/usr/bin/perl
-#use lib '/usr/local/opus-dev/intranet/modules';
-#use C4::Context("/etc/koha-opus-dev.conf");
+# 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 CGI;
use C4::Labels;
use C4::Auth;
-use C4::Serials;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
use PDF::Reuse;
use PDF::Reuse::Barcode;
-use PDF::Report;
-use PDF::Create;
-use PDF::Labels;
-use Acme::Comment;
-use Data::Dumper;
-warn "-------";
+use POSIX;
+use Text::Wrap;
-my $htdocs_path = C4::Context->config('intrahtdocs');
-my $cgi = new CGI;
-my $pdf = new PDF::Labels(
- $PDF::Labels::PageFormats[1],
- filename => "$htdocs_path/barcodes/opus.pdf",
- Author => 'PDF Labelmaker',
- 'PageMode' => 'UseOutlines',
- Title => 'My Labels'
-);
+$Text::Wrap::columns = 39;
+$Text::Wrap::separator = "\n";
-warn "$htdocs_path/barcodes/opus.pdf";
+my $htdocs_path = C4::Context->config('intrahtdocs');
+my $cgi = new CGI;
+my $spine_text = "";
+# get the printing settings
+my $conf_data = get_label_options();
my @resultsloop = get_label_items();
-
-#warn Dumper @resultsloop;
-warn Dumper $pdf->{'filename'};
-
-$pdf->setlabel(0); # Start with label 5 on first page
-
-foreach my $result (@resultsloop) {
- warn Dumper $result;
- $pdf->label( $result->{'itemtype'}, $result->{'number'}, 'LAK',
- $result->{'barcode'} );
- $pdf->label( $result->{'itemtype'}, $result->{'dewey'}, 'LAK',
- $result->{'barcode'} );
-
+my $barcodetype = $conf_data->{'barcodetype'};
+my $printingtype = $conf_data->{'printingtype'};
+my $guidebox = $conf_data->{'guidebox'};
+my $startrow = $conf_data->{'startrow'};
+
+# if none selected, then choose 'both'
+if ( !$printingtype ) {
+ $printingtype = 'both';
}
-warn "HERE";
-$pdf->close();
-#--------------------------------------------------
+# opus paper dims. in *millimeters*
+# multiply values by '2.83465', to find their value in Postscript points.
-use PDF::Reuse;
-prFile("$htdocs_path/barcodes/opus1.pdf");
-prDoc("$htdocs_path/barcodes/opus.pdf");
+# $xmargin = 12;
+# $label_height = 34;
+# $label_width = 74;
+# $x_pos_spine = 12;
+# $pageheight = 304;
+# $pagewidth = 174;
+# $line_spacer = 10;
+# $label_rows = 8;
+
+# sheet dimensions in PS points.
+
+my $top_margin = 7;
+my $left_margin = 34;
+my $top_text_margin = 20;
+my $left_text_margin = 10;
+my $label_height = 96;
+my $spine_width = 210;
+my $colspace = 9;
+my $rowspace = 11;
+my $x_pos_spine = 36;
+my $pageheight = 861;
+my $pagewidth = 493;
+my $line_spacer = 10;
+my $label_rows = 8;
+
+# setting up the pdf doc
+#remove the file before write, for testing
+#unlink "$htdocs_path/barcodes/new.pdf";
+#prFile("$htdocs_path/barcodes/new.pdf");
+#prLogDir("$htdocs_path/barcodes");
+
+# fix, no longer writes to temp dir
+prInitVars(); # To initiate ALL global variables and tables
+$| = 1;
+print STDOUT "Content-Type: application/pdf \n\n";
+prFile();
+
+prMbox( 0, 0, $pagewidth, $pageheight );
+prFont('courier'); # Just setting a font
+prFontSize(9);
+
+my $str;
+
+my $y_pos_initial = ( ( $pageheight - $top_margin ) - $label_height );
+my $y_pos_initial_startrow =
+ ( ( $pageheight - $top_margin ) - ( $label_height * $startrow ) );
+my $y_pos = $y_pos_initial_startrow;
+
+my $page_break_count = $startrow;
+my $codetype = 'Code39';
+
+#do page border
+# commented out coz it was running into the side-feeds of the paper.
+# drawbox( 0, 0 , $pagewidth, $pageheight );
+
+my $item;
+
+# for loop
+my $i2 = 1;
+
+foreach $item (@resultsloop) {
+ my $x_pos_spine_tmp = $x_pos_spine;
+
+ for ( 1 .. 2 ) {
+
+ if ( $guidebox == 1 ) {
+ warn
+"COUNT1, PBREAKCNT=$page_break_count, y=$y_pos, labhght = $label_height";
+ drawbox( $x_pos_spine_tmp, $y_pos, $spine_width, $label_height );
+ }
+
+ #-----------------draw spine text
+ if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
+
+ #warn "PRINTTYPE = $printingtype";
+
+ # add your printable fields manually in here
+ my @fields = qw (itemtype dewey isbn classification);
+ my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
+ my $hPos = ( $x_pos_spine_tmp + $left_text_margin );
+ foreach my $field (@fields) {
+
+ # if the display option for this field is selected in the DB,
+ # and the item record has some values for this field, display
it.
+ if ( $conf_data->{"$field"} && $item->{"$field"} ) {
+
+ #warn "CONF_TYPE = $field";
+
+ # get the string
+ $str = $item->{"$field"};
+
+ # strip out naughty existing nl/cr's
+ $str =~ s/\n//g;
+ $str =~ s/\r//g;
+
+ # chop the string up into _upto_ 12 chunks
+ # and seperate the chunks with newlines
+
+ $str = wrap( "", "", "$str" );
+ $str = wrap( "", "", "$str" );
+
+ # split the chunks between newline's, into an array
+ my @strings = split /\n/, $str;
+
+ # then loop for each string line
+ foreach my $str (@strings) {
+
+ warn "HPOS , VPOS $hPos, $vPos ";
+ prText( $hPos, $vPos, $str );
+ $vPos = $vPos - $line_spacer;
+ }
+ } # if field is valid
+ } # foreach @field
+ } #if spine
+
+ $x_pos_spine_tmp = ( $x_pos_spine_tmp + $spine_width + $colspace );
+ } # for 1 ..2
+ warn " $y_pos - $label_height - $rowspace";
+ $y_pos = ( $y_pos - $label_height - $rowspace );
+ warn " $y_pos - $label_height - $rowspace";
+
+ #-----------------draw spine text
+
+ # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
+ if ( $page_break_count == $label_rows ) {
+ prPage();
+ $page_break_count = 0;
+ $i2 = 0;
+ $y_pos = $y_pos_initial;
+ }
+ $page_break_count++;
+ $i2++;
+}
prEnd();
-print $cgi->redirect("/intranet-tmpl/barcodes/opus1.pdf");
+#print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- label-print-pdf.pl 21 Jul 2006 13:55:57 -0000 1.14
+++ label-print-pdf.pl 9 Mar 2007 14:31:27 -0000 1.15
@@ -1,289 +1,215 @@
#!/usr/bin/perl
-#----------------------------------------------------------------------
-# this script is really divided into 2 differenvt section,
+# 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
+
+# $Id: label-print-pdf.pl,v 1.15 2007/03/09 14:31:27 tipaul Exp $
+
+=head1 label-print-pdf.pl
+
+ this script is really divided into 2 differenvt section,
+
+ the first section creates, and defines the new PDF file the barcodes
+ using PDF::Reuse::Barcode, then saves the file to disk.
-# the first section creates, and defines the new PDF file the barcodes
-# using PDF::Reuse::Barcode, then saves the file to disk.
+ the second section then opens the pdf file off disk, and places the spline
label
+ text in the left-most column of the page. then save the file again.
-# the second section then opens the pdf file off disk, and places the spline
label
-# text in the left-most column of the page. then save the file again.
+ the reason for this goofyness, it that i couldnt find a single perl package
that handled both barcodes and decent text placement.
-# the reason for this goofyness, it that i couldnt find a single perl package
that handled both barcodes and decent text placement.
+=cut
-#use lib '/usr/local/hlt/intranet/modules';
-#use C4::Context("/etc/koha-hlt.conf");
-
-#use strict;
+use strict;
use CGI;
use C4::Labels;
use C4::Auth;
-use C4::Serials;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
-use HTML::Template;
+
use PDF::Reuse;
use PDF::Reuse::Barcode;
-use PDF::Report;
-use Data::Dumper;
+use POSIX;
+use C4::Labels;
+use Acme::Comment;
-#use Acme::Comment;
-#use Data::Dumper;
my $htdocs_path = C4::Context->config('intrahtdocs');
my $cgi = new CGI;
-
my $spine_text = "";
# get the printing settings
-
+my $template = GetActiveLabelTemplate();
my $conf_data = get_label_options();
my @resultsloop = get_label_items();
-
-warn Dumper $conf_data;
-
-
my $barcodetype = $conf_data->{'barcodetype'};
my $printingtype = $conf_data->{'printingtype'};
my $guidebox = $conf_data->{'guidebox'};
-my $startrow = $conf_data->{'startrow'};
-
-if (!$printingtype) {
- $printingtype = 'both';
-}
+my $start_label = $conf_data->{'startlabel'};
+my $fontsize = $template->{'fontsize'};
+my $units = $template->{'units'};
+
+warn "UNITS $units";
+warn "fontsize = $fontsize";
+
+my $unitvalue = GetUnitsValue($units);
+warn $unitvalue;
+warn $units;
+
+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 $printingtype;
-warn $guidebox;
+my $label_cols = $template->{'cols'};
+my $label_rows = $template->{'rows'};
+my $text_wrap_cols = GetTextWrapCols( $fontsize, $label_width );
-#warn Dumper @resultsloop;
+warn $label_cols, $label_rows;
-# dimensions of gaylord paper
+# set the paper size
my $lowerLeftX = 0;
my $lowerLeftY = 0;
-my $upperRightX = 612;
-my $upperRightY = 792;
+my $upperRightX = $page_width;
+my $upperRightY = $page_height;
-#----------------------------------
-# setting up the pdf doc
+prInitVars();
+$| = 1;
+print STDOUT "Content-Type: application/pdf \r\n\r\n";
+prFile();
-#remove the file before write, for testing
-unlink "$htdocs_path/barcodes/new.pdf";
+prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
-prFile("$htdocs_path/barcodes/new.pdf");
-prLogDir("$htdocs_path/barcodes");
+# later feature, change the font-type and size?
+prFont('C'); # Just setting a font
+prFontSize($fontsize);
-#prMbox ( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
-prMbox( 0, 0, 612, 792 );
+my $margin = $top_margin;
+my $left_text_margin = 3;
-prFont('Times-Roman'); # Just setting a font
-prFontSize(10);
+my $str;
-my $margin = 36;
+#warn "STARTROW = $startrow\n";
-my $label_height = 90;
-my $spine_width = 72;
-my $circ_width = 207;
-my $colspace = 27;
+#my $page_break_count = $startrow;
+my $codetype = 'Code39';
-my $x_pos_spine = 36;
-my $x_pos_circ1 = 135;
-my $x_pos_circ2 = 369;
+#do page border
+#drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
-my $pageheight = 792;
+my $item;
+my ( $i, $i2 ); # loop counters
-warn "STARTROW = $startrow\n";
+# big row loop
-#my $y_pos_initial = ( ( 792 - 36 ) - 90 );
-my $y_pos_initial = ( ( $pageheight - $margin ) - $label_height );
-my $y_pos_initial_startrow =
- ( ( $pageheight - $margin ) - ( $label_height * $startrow ) );
+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 eq 1 ) {
+ $rowcount = 1;
+ $colcount = 1;
+ $x_pos = $left_margin;
+ $y_pos = ( $page_height - $top_margin - $label_height );
+}
-my $y_pos = $y_pos_initial_startrow;
+else {
+ $rowcount = ceil( $start_label / $label_cols );
+ $colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) );
-warn "Y POS INITAL : $y_pos_initial";
-warn "Y POS : $y_pos";
-warn "Y START ROW = $y_pos_initial_startrow";
+ $x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) +
+ ( $colspace * ( $colcount - 1 ) );
-my $rowspace = 36;
-my $page_break_count = $startrow;
-my $codetype = 'Code39';
+ $y_pos = $page_height - $top_margin - ( $label_height * $rowcount ) -
+ ( $rowspace * ( $rowcount - 1 ) );
-# do border---------------
-my $str = "q\n"; # save the graphic state
-$str .= "4 w\n"; # border color red
-$str .= "0.0 0.0 0.0 RG\n"; # border color red
-$str .= "1 1 1 rg\n"; # fill color blue
-$str .= "0 0 612 792 re\n"; # a rectangle
-$str .= "B\n"; # fill (and a little more)
-$str .= "Q\n"; # save the graphic state
-
-# do border---------------
+}
-prAdd($str);
-my $item;
+warn "ROW COL $rowcount, $colcount";
-# for loop
+#my $barcodetype = 'Code39';
-my $i2 = 1;
foreach $item (@resultsloop) {
- if ( $i2 == 1 && $guidebox == 1) {
- draw_boundaries(
- $x_pos_spine, $x_pos_circ1, $x_pos_circ2, $y_pos,
- $spine_width, $label_height, $circ_width
- );
- }
- #warn Dumper $item->{'itemtype'};
- #warn "COUNT = $cnt1";
+ warn "-----------------";
+ if ($guidebox) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height );
+ }
- #building up spine text
- my $line = 75;
- my $line_spacer = 16;
+ if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
+ if ($guidebox) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height );
+ }
- $DB::single = 1;
+ DrawSpineText( $y_pos, $label_height, $fontsize, $x_pos,
+ $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
+ CalcNextLabelPos();
+ }
- warn
-"COUNT=$i2, PBREAKCNT=$page_break_count, X,Y POS x=$x_pos_circ1, y=$y_pos";
if ( $printingtype eq 'barcode' || $printingtype eq 'both' ) {
- build_circ_barcode( $x_pos_circ1, $y_pos, $item->{'barcode'},
- $conf_data->{'barcodetype'}, \$item );
- build_circ_barcode( $x_pos_circ2, $y_pos, $item->{'barcode'},
- $conf_data->{'barcodetype'}, \$item );
-}
-# added for xpdf compat. doesnt use type3 fonts., but increases filesize from
20k to 200k
-# i think its embedding extra fonts in the pdf file.
-# mode => 'graphic',
-
- $y_pos = ( $y_pos - $label_height );
-
- # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
- if ( $page_break_count == 8 ) {
- prPage();
-
- #warn "############# PAGEBREAK ###########";
- $page_break_count = 0;
- $i2 = 0;
- $y_pos = $y_pos_initial;
+ if ($guidebox) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height );
}
- $page_break_count++;
- $i2++;
-}
-############## end of loop
+ DrawBarcode( $x_pos, $y_pos, $label_height, $label_width,
+ $item->{'barcode'}, $barcodetype );
+ CalcNextLabelPos();
+ }
+} # end for item loop
prEnd();
-#----------------------------------------------------------------------------
-# this second section of the script uses a diff perl class than the previous
section
-# it opens the 'new.pdf' file that the previous section has just saved
-
-if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
-
- $file = "$htdocs_path/barcodes/new.pdf";
-
- my $pdf = new PDF::Report( File => $file );
-
- # my $pdf = new PDF::Report(PageSize => "letter",
- # PageOrientation => "Landscape");
-
- #$pdf->newpage($nopage);
- my $pagenumber = 1;
- $pdf->openpage($pagenumber);
-
- ( $pagewidth, $pageheight ) = $pdf->getPageDimensions();
-
- #warn "PAGE DIM = $pagewidth, $pageheight";
- #warn "Y START ROW = $y_pos_initial_startrow";
- my $y_pos = ( $y_pos_initial_startrow + 90 );
-
- #my $y_pos = ( $y_pos_initial_startrow );
- #warn "Y POS = $y_pos";
-
- # now needed now we are using centerString().
- #$pdf->setAlign('left');
-
- # SET THE FONT SIZE
- $pdf->setSize(9);
-
- my $page_break_count = $startrow;
-
- #warn "INIT PAGEBREAK COUNT = $page_break_count";
-
- #warn "#----------------------------------\n";
- #warn "INIT VPOS = $vPos, hPos = $hPos";
-
- my $vPosSpacer = 15;
- my $start_text_pos = 39; # ( 36 - 5 = 31 ) 5 is an inside border for
text.
- my $spine_label_text_with = 67;
-
- foreach $item (@resultsloop) {
-
- #warn Dumper $item;
- #warn "START Y_POS=$y_pos";
- my $firstrow = 0;
-
- $pdf->setAddTextPos( $start_text_pos, ( $y_pos - 20 ) )
- ; # INIT START POS
- ( $hPos, $vPos ) = $pdf->getAddTextPos();
+print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
- my $hPosEnd = ( $hPos + $spine_label_text_with ); # 72
- if ( $conf_data->{'dewey'} && $item->{'dewey'} ) {
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'dewey'} );
- $vPos = $vPos - $vPosSpacer;
- }
+sub CalcNextLabelPos {
+ if ( $colcount lt $label_cols ) {
- if ( $conf_data->{'isbn'} && $item->{'isbn'} ) {
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'isbn'} );
- $vPos = $vPos - $vPosSpacer;
+ # warn "new col";
+ $x_pos = ( $x_pos + $label_width + $colspace );
+ $colcount++;
}
- if ( $conf_data->{'class'} && $item->{'classification'} ) {
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $pdf->centerString( $hPos, $hPosEnd, $vPos,
- $item->{'classification'} );
- $vPos = $vPos - $vPosSpacer;
- }
+ else {
+ $x_pos = $left_margin;
+ if ( $rowcount eq $label_rows ) {
- if ( $conf_data->{'itemtype'} && $item->{'itemtype'} ) {
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'itemtype'} );
- $vPos = $vPos - $vPosSpacer;
+ # warn "new page";
+ prPage();
+ $y_pos = ( $page_height - $top_margin - $label_height );
+ $rowcount = 1;
}
+ else {
- #$pdf->drawRect(
- # $x_pos_spine, $y_pos,
- # ( $x_pos_spine + $spine_width ),
- # ( $y_pos - $label_height )
- #);
-
- $y_pos = ( $y_pos - $label_height );
-
- #warn "END LOOP Y_POS =$y_pos";
- # warn "PAGECOUNT END LOOP=$page_break_count";
- if ( $page_break_count == 8 ) {
- $pagenumber++;
- $pdf->openpage($pagenumber);
-
- #warn "############# PAGEBREAK ###########";
- $page_break_count = 0;
- $i2 = 0;
- $y_pos = ( $y_pos_initial + 90 );
+ # warn "new row";
+ $y_pos = ( $y_pos - $rowspace - $label_height );
+ $rowcount++;
}
-
- $page_break_count++;
- $i2++;
-
- #warn "#----------------------------------\n";
-
+ $colcount = 1;
}
- $DB::single = 1;
- $pdf->saveAs($file);
}
-#------------------------------------------------
-
-print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
Index: label-print.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- label-print.pl 21 Jul 2006 13:55:57 -0000 1.4
+++ label-print.pl 9 Mar 2007 14:31:27 -0000 1.5
@@ -1,5 +1,20 @@
#!/usr/bin/perl
+# This file is part of koha
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
use strict;
use CGI;
use C4::Auth;
@@ -7,14 +22,12 @@
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
-use HTML::Template;
+
use GD::Barcode::UPCE;
use Data::Random qw(:all);
my $htdocs_path = C4::Context->config('intrahtdocs');
-use Data::Dumper;
-
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -23,7 +36,7 @@
query => $query,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { catalogue => 1 },
+ flagsrequired => { tools => 1 },
debug => 1,
}
);
@@ -35,8 +48,6 @@
my $conf_data = $sth->fetchrow_hashref;
-#warn Dumper $conf_data;
-
$sth->finish;
my @data;
@@ -66,54 +77,43 @@
}
$sth->finish;
-#warn Dumper @resultsloop;
-
-
-
-
#------------------------------------------------------
#lets write barcode files to tmp dir for every item in @resultsloop
-
-
binmode(FILE);
-foreach my $item (@resultsloop){
+foreach my $item (@resultsloop) {
+ my $random = int( rand(100000000000) ) + 999999999999;
-my $random = int( rand(100000000000)) + 999999999999;
-#warn "$random\n";
+ #warn "$random\n";
$item->{'barcode'} = $random;
-# my $itembarcode = $item->{'barcode'};
-# warn $item->{'barcode'};
-
+ # my $itembarcode = $item->{'barcode'};
+ # warn $item->{'barcode'};
my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
+
#warn $filename;
- open(FILE, ">$filename");
+ open( FILE, ">$filename" );
+
+ print FILE GD::Barcode->new( 'EAN13', $item->{'barcode'} )->plot->png;
- print FILE GD::Barcode->new('EAN13', $item->{'barcode'})->plot->png;
-# warn $GD::Barcode::errStr;
+ # warn $GD::Barcode::errStr;
close(FILE);
-#warn Dumper $item->{'barcode'};
+ #warn Dumper $item->{'barcode'};
}
-
-
-
-
# lets pass the config setting
$template->param(
resultsloop => address@hidden,
-
itemtype_opt => $conf_data->{'itemtype'},
papertype_opt => $conf_data->{'papertype'},
author_opt => $conf_data->{'author'},
@@ -124,9 +124,8 @@
isbn_opt => $conf_data->{'isbn'},
dewey_opt => $conf_data->{'dewey'},
class_opt => $conf_data->{'class'},
-
-
-
+ subclass_opt => $conf_data->{'subclass'},
+ itemcallnumber_opt => $conf_data->{'itemcallnumber'},
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
@@ -135,4 +134,3 @@
);
output_html_with_http_headers $query, $cookie, $template->output;
-
Index: pdfViewer.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/pdfViewer.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- pdfViewer.pl 5 Sep 2005 22:25:11 -0000 1.3
+++ pdfViewer.pl 9 Mar 2007 14:31:27 -0000 1.4
@@ -31,8 +31,8 @@
my $filename = "barcodes.pdf";
my $tmpFileName = $cgi->param('tmpFileName');
print "Content-Disposition: attachment; filename = $filename\n\n";
-print $cgi->header(-type => 'application/pdf'),
- $cgi->start_html(-title=>"Codify to PDF");
+print $cgi->header( -type => 'application/pdf' ),
+ $cgi->start_html( -title => "Codify to PDF" );
open fh, "<$tmpFileName";
while (<fh>) {
print;
Index: printerConfig.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/printerConfig.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- printerConfig.pl 4 Jul 2006 14:36:51 -0000 1.3
+++ printerConfig.pl 9 Mar 2007 14:31:27 -0000 1.4
@@ -27,10 +27,10 @@
use C4::Context;
use C4::Output;
use C4::Auth;
-use HTML::Template;
+
use PDF::API2;
use PDF::API2::Page;
-use PDF::API2::PDF::Utils;
+use PDF::API2::Util;
use C4::Interface::CGI::Output;
# This function returns the path to deal with the correct files, considering
@@ -39,9 +39,10 @@
my $type = shift @_;
my $templatesSet = C4::Context->preference('template');
my $lang = C4::Context->preference('opaclanguages');
- if ($type eq "intranet") {
+ if ( $type eq "intranet" ) {
return
"$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
- } else {
+ }
+ else {
return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
}
}
@@ -64,12 +65,12 @@
# Save settings to a configuration file.
sub saveConfToFile {
my $fileName = shift @_;
- my %keyValues = %{shift @_};
+ my %keyValues = %{ shift @_ };
my $i;
open FILE, ">$fileName";
my $i;
- foreach $i (keys(%keyValues)) {
- print FILE $i." = ".$keyValues{$i}."\n";
+ foreach $i ( keys(%keyValues) ) {
+ print FILE $i . " = " . $keyValues{$i} . "\n";
}
close FILE;
}
@@ -77,44 +78,52 @@
# Creates a CGI object and take his parameters
my $input = new CGI;
-if ($input->param('saveSettings')) {
- my $labelConf =
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
- my %newConfiguration = (pageType => $input->param('pageType'),
+if ( $input->param('saveSettings') ) {
+ my $labelConf =
+ &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
+ my %newConfiguration = (
+ pageType => $input->param('pageType'),
columns =>
$input->param('columns'),
rows =>
$input->param('rows'),
systemDpi =>
$input->param('systemDpi'),
labelWidth =>
$input->param('labelWidth'),
labelHeigth =>
$input->param('labelHeigth'),
marginBottom =>
$input->param('marginBottom'),
- marginLeft =>
$input->param('marginLeft'));
- saveConfToFile($labelConf, \%newConfiguration);
- print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl')
+ marginLeft => $input->param('marginLeft')
+ );
+ saveConfToFile( $labelConf, \%newConfiguration );
+ print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl');
}
# Get the template to use
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "barcodes/printerConfig.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/printerConfig.tmpl",
type => "intranet",
query => $input,
authnotrequired => 0,
- flagsrequired => {parameters => 1},
+ flagsrequired => { tools => 1 },
debug => 1,
- });
+ }
+);
-my $filenameConf =
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+ &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
my %labelConfig = &loadConfFromFile($filenameConf);
-$template->param(COLUMNS => $labelConfig{'columns'});
-$template->param(ROWS => $labelConfig{'rows'});
-$template->param(SYSTEM_DPI => $labelConfig{'systemDpi'});
-$template->param(LABEL_WIDTH => $labelConfig{'labelWidth'});
-$template->param(LABEL_HEIGTH => $labelConfig{'labelHeigth'});
-$template->param(MARGIN_TOP => $labelConfig{'marginBottom'});
-$template->param(MARGIN_LEFT => $labelConfig{'marginLeft'});
-$template->param(SCRIPT_NAME => '/cgi-bin/koha/barcodes/printerConfig.pl');
-$template->param("$labelConfig{'pageType'}" => 1);
-$template->param(intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
+$template->param( COLUMNS => $labelConfig{'columns'} );
+$template->param( ROWS => $labelConfig{'rows'} );
+$template->param( SYSTEM_DPI => $labelConfig{'systemDpi'} );
+$template->param( LABEL_WIDTH => $labelConfig{'labelWidth'} );
+$template->param( LABEL_HEIGTH => $labelConfig{'labelHeigth'} );
+$template->param( MARGIN_TOP => $labelConfig{'marginBottom'} );
+$template->param( MARGIN_LEFT => $labelConfig{'marginLeft'} );
+$template->param( SCRIPT_NAME => '/cgi-bin/koha/barcodes/printerConfig.pl' );
+$template->param( "$labelConfig{'pageType'}" => 1 );
+$template->param(
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet =>
C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
- );
+);
output_html_with_http_headers $input, $cookie, $template->output;
Index: test.textblock.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/test.textblock.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- test.textblock.pl 19 Jul 2006 01:09:42 -0000 1.1
+++ test.textblock.pl 9 Mar 2007 14:31:27 -0000 1.2
@@ -11,10 +11,10 @@
my $fnt = $pdf->corefont('Helvetica-Bold');
my $page = $pdf->page; # returns the last page
my $txt = $page->text;
-$txt->{' font'}=$fnt;
+$txt->{' font'} = $fnt;
$text_to_place = "moo moo";
-($width_of_last_line, $ypos_of_last_line, $left_over_text) =
+( $width_of_last_line, $ypos_of_last_line, $left_over_text ) =
$pdftable->text_block(
$txt,
$text_to_place,
@@ -28,6 +28,6 @@
# -parspace => 0,
# -align => "left",
# -hang => 1,
-);
+ );
$pdf->saveas("$htdocs_path/barcodes/foo.pdf");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha/barcodes barcodesGenerator.pl barcodes.pl ...,
paul poulain <=