adding barcode generator to Koha
authortipaul <tipaul>
Mon, 20 Sep 2004 15:03:27 +0000 (15:03 +0000)
committertipaul <tipaul>
Mon, 20 Sep 2004 15:03:27 +0000 (15:03 +0000)
C4/Barcodes/PrinterConfig.pm [new file with mode: 0644]
barcodes/barcodes.pl [new file with mode: 0755]
barcodes/barcodesGenerator.pl [new file with mode: 0755]
barcodes/pdfViewer.pl [new file with mode: 0755]
barcodes/printerConfig.pl [new file with mode: 0755]
koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes-bottom.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes-top.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/barcodes/printerConfig.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/includes/countryCodes/countryCodes.dat [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/includes/labelConfig/itemsLabelConfig.conf [new file with mode: 0644]

diff --git a/C4/Barcodes/PrinterConfig.pm b/C4/Barcodes/PrinterConfig.pm
new file mode 100644 (file)
index 0000000..44e08c3
--- /dev/null
@@ -0,0 +1,220 @@
+package C4::Barcodes::PrinterConfig;
+
+# 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;
+require Exporter;
+use vars qw($VERSION @EXPORT);
+
+use PDF::API2;
+use PDF::API2::Page;
+
+# set the version for version checking
+$VERSION = 0.01;
+
+=head1 NAME
+
+C4::Barcodes::PrinterConfig - Koha module dealing with labels in a PDF.
+
+=head1 SYNOPSIS
+
+       use C4::Barcodes::PrinterConfig;
+
+=head1 DESCRIPTION
+
+This package is used to deal with labels in a pdf file. Giving some parameters,
+this package contains several functions to handle every label considering the 
+environment of the pdf file.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+@EXPORT = qw(&labelsPage &getLabelPosition setPositionsForX setPositionsForY);
+
+my @positionsForX; # Takes all the X positions of the pdf file.
+my @positionsForY; # Takes all the Y positions of the pdf file.
+my $firstLabel = 1; # Test if the label passed as a parameter is the first label to be printed into the pdf file.
+
+=item setPositionsForX
+
+       C4::Barcodes::PrinterConfig::setPositionsForX($marginLeft, $labelWidth, $columns, $pageType);
+
+Calculate and stores all the X positions across the pdf page.
+
+C<$marginLeft> Indicates how much left margin do you want in your page type.
+
+C<$labelWidth> Indicates the width of the label that you are going to use.
+
+C<$columns> Indicates how many columns do you want in your page type.
+
+C<$pageType> Page type to print (eg: a4, legal, etc).
+
+=cut
+#'
+sub setPositionsForX {
+       my ($marginLeft, $labelWidth, $columns, $pageType) = @_;
+       my $defaultDpi = 72/25.4; # By default we know 25.4 mm -> 1 inch -> 72 dots per inch
+       my $whereToStart = ($marginLeft + ($labelWidth/2));
+       my $firstLabel = $whereToStart*$defaultDpi;
+       my $spaceBetweenLabels = $labelWidth*$defaultDpi;
+       my @positions;
+       for (my $i = 0; $i < $columns ; $i++) {
+               push @positions, ($firstLabel+($spaceBetweenLabels*$i));
+       }
+       @positionsForX = @positions;
+}
+
+=item setPositionsForY
+
+       C4::Barcodes::PrinterConfig::setPositionsForY($marginBottom, $labelHeigth, $rows, $pageType);
+
+Calculate and stores all tha Y positions across the pdf page.
+
+C<$marginBottom> Indicates how much bottom margin do you want in your page type.
+
+C<$labelHeigth> Indicates the height of the label that you are going to use.
+
+C<$rows> Indicates how many rows do you want in your page type.
+
+C<$pageType> Page type to print (eg: a4, legal, etc).
+
+=cut
+#'
+sub setPositionsForY {
+       my ($marginBottom, $labelHeigth, $rows, $pageType) = @_;
+       my $defaultDpi = 72/25.4; # By default we know 25.4 mm -> 1 inch -> 72 dots per inch
+       my $whereToStart = ($marginBottom + ($labelHeigth/2));
+       my $firstLabel = $whereToStart*$defaultDpi;
+       my $spaceBetweenLabels = $labelHeigth*$defaultDpi;
+       my @positions;
+       for (my $i = 0; $i < $rows; $i++) {
+               unshift @positions, ($firstLabel+($spaceBetweenLabels*$i));
+       }
+       @positionsForY = @positions;
+}
+
+=item getLabelPosition
+
+       (my $x, my $y, $pdfObject, $pageObject, $gfxObject, $textObject, $coreObject, $labelPosition) = 
+                                       C4::Barcodes::PrinterConfig::getLabelPosition($labelPosition, 
+                                                                                                                                 $pdfObject, 
+                                                                                                                                 $page,
+                                                                                                                                 $gfx,
+                                                                                                                                 $text,
+                                                                                                                                 $fontObject,
+                                                                                                                                 $pageType);   
+
+Return the (x,y) position of the label that you are going to print considering the environment.
+
+C<$labelPosition> Indicates which label positions do you want to place by x and y coordinates.
+
+C<$pdfObject> The PDF object in use.
+
+C<$page> The page in use.
+
+C<$gfx> The gfx resource to handle with barcodes objects.
+
+C<$text> The text resource to handle with text.
+
+C<$fontObject> The font object
+
+C<$pageType> Page type to print (eg: a4, legal, etc).
+
+=cut
+#'
+sub getLabelPosition {
+       my ($labelNum, $pdf, $page, $gfxObject, $textObject, $fontObject, $pageType) = @_;
+       my $indexX = $labelNum % @positionsForX;
+       my $indexY = int($labelNum / @positionsForX);
+       # Calculates the next label position and return that label number
+       my $nextIndexX = $labelNum % @positionsForX;
+       my $nextIndexY = $labelNum % @positionsForY;
+       if ($firstLabel) {
+          $page = $pdf->page;
+          $page->mediabox($pageType);
+          $gfxObject = $page->gfx;
+          $textObject = $page->text;
+          $textObject->font($fontObject, 7);
+                 $firstLabel = 0;
+       } elsif (($nextIndexX == 0) && ($nextIndexY == 0)) {
+          $page = $pdf->page;
+          $page->mediabox($pageType);
+          $gfxObject = $page->gfx;
+          $textObject = $page->text;
+          $textObject->font($fontObject, 7);
+       }
+       $labelNum = $labelNum + 1;      
+       if ($labelNum == (@positionsForX*@positionsForY)) {
+               $labelNum = 0;
+       }
+       return ($positionsForX[$indexX], $positionsForY[$indexY], $pdf, $page, $gfxObject, $textObject, $fontObject, $labelNum);
+}
+
+=item labelsPage
+
+       my @labelTable = C4::Barcodes::PrinterConfig::labelsPage($rows, $columns);
+
+This function will help you to build the labels panel, where you can choose
+wich label position do you want to start the printer process.
+
+C<$rows> Indicates how many rows do you want in your page type.
+
+C<$columns> Indicates how many rows do you want in your page type.
+
+=cut
+#'
+sub labelsPage{
+       my ($rows, $columns) = @_;
+       my @pageType;
+       my $tagname = 0;
+       my $labelname = 1;
+       my $check;
+       for (my $i = 1; $i <= $rows; $i++) {
+               my @column;
+               for (my $j = 1; $j <= $columns; $j++) {
+                       my %cell;
+                       if ($tagname == 0) {
+                               $check = 'checked';
+                       } else {
+                               $check = '';
+                       }               
+                       %cell = (check => $check,
+                                        tagname => $tagname,
+                                labelname => $labelname);
+                       $tagname = $tagname + 1;        
+                       $labelname = $labelname + 1;    
+                       push @column, \%cell;
+               }
+               my %columns = (columns => \@column);
+               push @pageType, \%columns;
+       }
+       return @pageType;
+}
+
+1;
+
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Koha Physics Library UNLP <matias_veleda@hotmail.com>
+
+=cut
\ No newline at end of file
diff --git a/barcodes/barcodes.pl b/barcodes/barcodes.pl
new file mode 100755 (executable)
index 0000000..fb6b3c6
--- /dev/null
@@ -0,0 +1,143 @@
+#!/usr/bin/perl
+
+# script to generate items barcodes
+# written 07/04
+# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and
+#    CastaƱeda Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina and
+
+# 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::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") {
+               return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
+       } else {
+               return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
+       }
+}
+
+# Load a configuration file. Before use this function, check if that file exists.
+sub loadConfFromFile {
+  my $fileName = shift @_;
+       my %keyValues;
+       open FILE, "<$fileName";
+       while (<FILE>) {
+               chomp;
+               if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) {
+                       $keyValues{$1} = $2;
+               }
+       }
+       close FILE;
+       return %keyValues;
+}
+
+# Save settings to a configuration file. It delete previous configuration settings.
+sub saveConfToFile {
+       my $fileName = shift @_;
+       my %keyValues = %{shift @_};
+       my $i;
+       open FILE, ">$fileName";                        
+       my $i;
+       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 %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'});
+
+# It creates a list of posible intervals to choose codes to generate
+my %list = ('continuous' => 'Continuous Range', 'individuals' => 'Individual Codes');
+my @listValues = keys(%list);
+my $rangeType = CGI::scrolling_list(-name => 'rangeType',
+                                       -values => \@listValues,
+                                               -labels => \%list,
+                                               -size => 1,
+                                                                       -default => ['continuous'],
+                                               -multiple => 0,
+                                                                       -id => "rangeType",
+                                                                       -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')) {
+       my $newCountryName = $input->param('countryName');
+       my $newCountryCode = $input->param('countryCode'); 
+
+       my $countryCodesFilename = &getPath("intranet")."/includes/countryCodes/countryCodes.dat";
+       open COUNTRY_CODES, ">>$countryCodesFilename";                  
+    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);
+@listValues = keys(%list);
+my $number_system = CGI::scrolling_list(-name => 'numbersystem',
+                                           -values => \@listValues,
+                                                   -labels   => \%list,
+                                                   -size     => 1,
+                                                   -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",
+                                        type => "intranet",
+                                        query => $input,
+                                        authnotrequired => 0,
+                                        flagsrequired => {parameters => 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 => \@labelTable);
+$template->param(COL_SPAN => $labelConfig{'columns'});
+if ($input->param('error')) {
+       $template->param(ERROR => 1);
+} else {
+       $template->param(ERROR => 0);
+}
+# Shows the template with the real values replaced
+output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file
diff --git a/barcodes/barcodesGenerator.pl b/barcodes/barcodesGenerator.pl
new file mode 100755 (executable)
index 0000000..867f9ee
--- /dev/null
@@ -0,0 +1,220 @@
+#!/usr/bin/perl
+
+# script to generate items barcodes
+# written 07/04
+# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and
+#    CastaƱeda Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina and
+
+# 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
+
+require Exporter;
+
+use strict;
+
+use CGI;
+use C4::Context;
+use C4::Output;
+use HTML::Template;
+use PDF::API2;
+use PDF::API2::Page;
+use PDF::API2::PDF::Utils;
+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") {
+               return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
+       } else {
+               return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
+       }
+}
+
+# Load a configuration file. Before use this function, check if that file exists.
+sub loadConfFromFile {
+  my $fileName = shift @_;
+       my %keyValues;
+       open FILE, "<$fileName";
+       while (<FILE>) {
+               chomp;
+               if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) {
+                       $keyValues{$1} = $2;
+               }
+       }
+       close FILE;
+       return %keyValues;
+}
+
+# Save settings to a configuration file. It delete previous configuration settings.
+sub saveConfToFile {
+       my $fileName = shift @_;
+       my %keyValues = %{shift @_};
+       my $i;
+       open FILE, ">$fileName";                        
+       my $i;
+       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 %labelConfig = &loadConfFromFile($filenameConf);
+
+# Creates a CGI object and take its parameters
+my $cgi = new CGI;
+my $from = $cgi->param('from');
+my $to = $cgi->param('to');
+my $individualCodes = $cgi->param('individualCodes');
+my $pageType = $cgi->param('pages');
+my $label = $cgi->param('label');
+my $numbersystem = $cgi->param('numbersystem');
+
+# Generate the checksum from an inventary code
+sub checksum {
+
+  sub calculateDigit {
+    my $code = shift @_;
+    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); }
+                 $odd_parity = !$odd_parity;
+          }
+    my $check_digit = 10 - ($sum%10);
+       if ($check_digit==10) {
+               $check_digit=0;
+       }
+         return $code.$check_digit;
+  }
+
+  my $currentCode = shift @_;
+  $currentCode = &calculateDigit($currentCode);
+  return $currentCode;
+}
+
+# Assigns a temporary name to the PDF file
+sub assingFilename {
+       my ($from, $to) = @_;
+       my $ip = $cgi->remote_addr();
+       my $random = int(rand(1000000));
+    my $timeObj = localtime();
+       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';
+       return $tmpFileName;
+}
+
+# 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, $individualCodes) = @_;
+  # Returns a database handler
+  my $dbh = C4::Context->dbh;
+  # Create the query to database
+  my $rangeCondition;
+  if ($individualCodes ne "") {
+    $rangeCondition = "AND (I.barcode IN " . $individualCodes . ")";
+  } 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
+       # Set the temp directory for pdfĀ“s files
+       if (!defined($ENV{'TEMP'})) {
+               $ENV{'TEMP'} = '/tmp/';
+       }       
+       # Assigns a temporary filename for the pdf file
+       my $tmpFileName = &assingFilename($from, $to);
+       $tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+    # Creates a PDF object
+    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'});
+    # Creates a font object
+    my $tr = $pdf->corefont('Helvetica-Bold');
+    # Barcode position
+       my ($page, $gfx, $text);
+    while (my ($code,$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
+                                     -type => 'ean13', # Standard of codification
+                                     -code => $code, # Text to codify
+                                     -extn     => '012345',    # Barcode extension (if it is aplicable)
+                                     -umzn => 10,              # Top limit of the finished bar
+                                     -lmzn => 10,              # Bottom limit of the finished bar
+                                     -zone => 15,              # Bars size
+                                         -quzn => 0,           # Space destinated for legend
+                                     -ofwt => 0.01,    # Bars width
+                                         -fnsz => 8,           # Font size
+                                         -text => ''
+                                    );
+       
+         (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'}));
+      # Assigns the additional information to the barcode (Legend)
+         $text->translate($x - 48, $y - 22);
+      $text->text(substr $title, 0, 30);
+      $text->translate($x - 48, $y - 29);
+      $text->text(substr $author, 0, 30);
+    }
+    # Writes the objects added in $gfx to $page
+    $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 {
+       # Rollback and shows the error legend
+    print $cgi->redirect("/cgi-bin/koha/barcodes/barcodes.pl?error=1");
+  }
+  $sth->finish;
+}
+
+barcodesGenerator($from, $to, $individualCodes);
\ No newline at end of file
diff --git a/barcodes/pdfViewer.pl b/barcodes/pdfViewer.pl
new file mode 100755 (executable)
index 0000000..b80d23d
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+
+# script to show a PDF file.
+# written 07/04
+# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and
+#    CastaƱeda Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina and
+
+# 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
+
+require Exporter;
+
+use strict;
+use C4::Context;
+use CGI;
+
+# This script take a pdf filename as a parameter and output it to the browser.
+my $cgi = new CGI;
+my $tmpFileName = $cgi->param('tmpFileName');
+print $cgi->header(-type => 'application/pdf'),
+      $cgi->start_html(-title=>"Codify to PDF");
+open fh, "<$tmpFileName";
+while (<fh>) {
+ print;
+}
+print $cgi->end_html();
\ No newline at end of file
diff --git a/barcodes/printerConfig.pl b/barcodes/printerConfig.pl
new file mode 100755 (executable)
index 0000000..62e6e50
--- /dev/null
@@ -0,0 +1,116 @@
+#!/usr/bin/perl
+
+# script to set the labels configuration for the printer process.
+# written 07/04
+# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and
+
+# 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
+
+require Exporter;
+
+use strict;
+
+use CGI;
+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 C4::Interface::CGI::Output;
+
+# 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") {
+               return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
+       } else {
+               return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
+       }
+}
+
+# Load a configuration file.
+sub loadConfFromFile {
+  my $fileName = shift @_;
+       my %keyValues;
+       open FILE, "<$fileName";
+       while (<FILE>) {
+               chomp;
+               if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) {
+                       $keyValues{$1} = $2;
+               }
+       }
+       close FILE;
+       return %keyValues;
+}
+
+# Save settings to a configuration file.
+sub saveConfToFile {
+       my $fileName = shift @_;
+       my %keyValues = %{shift @_};
+       my $i;
+       open FILE, ">$fileName";                        
+       my $i;
+       foreach $i (keys(%keyValues)) {
+    print FILE $i." = ".$keyValues{$i}."\n";
+       }
+       close FILE;
+}
+
+# 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'),  
+                                                       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')
+}
+
+# Get the template to use
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "barcodes/printerConfig.tmpl",
+                                        type => "intranet",
+                                        query => $input,
+                                        authnotrequired => 0,
+                                        flagsrequired => {parameters => 1},
+                                                debug => 1,
+                                      });
+
+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);
+output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes-bottom.inc b/koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes-bottom.inc
new file mode 100644 (file)
index 0000000..0872ba5
--- /dev/null
@@ -0,0 +1,17 @@
+<br clear="all">
+<p> &nbsp; </p>
+
+<div class="center">
+<a href="/cgi-bin/koha/mainpage.pl">Home</a> ||
+<a href="/cgi-bin/koha/loadmodules.pl?module=search&amp;type=intranet">Catalogue</a> ||
+<a href="/cgi-bin/koha/members/members-home.pl">Members</a> ||
+<a href="/cgi-bin/koha/loadmodules.pl?module=acquisitions">Acquisitions</a> ||
+<a href="/cgi-bin/koha/circ/circulation.pl">Circulation</a> ||
+<a href="/cgi-bin/koha/reports-home.pl">Reports</a> ||
+<a href="/cgi-bin/koha/admin-home.pl">Parameters</a> ||
+<a href="/cgi-bin/koha/about.pl">About</a> || 
+Help
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes-top.inc b/koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes-top.inc
new file mode 100644 (file)
index 0000000..28d7f01
--- /dev/null
@@ -0,0 +1,229 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
+\r
+<html>\r
+<head>\r
+<title>KOHA: INTRANET: Parameters</title>\r
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\r
+<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/includes/common-style.css">\r
+<style>\r
+.parameters {\r
+       background-color: #86c268;\r
+       color: #FFFFFF;\r
+       text-decoration: normal;\r
+       font-weight: bold;\r
+       }\r
+a.parameters:hover {\r
+       background-color: #86c268;\r
+       color: #FFFFFF;\r
+       text-decoration: normal;\r
+       font-weight: bold;\r
+       }\r
+.ranges {\r
+       border:0;\r
+}\r
+\r
+.myTable TD{\r
+  border-width: 0px;\r
+  border-color: navy;\r
+  border-style: solid;\r
+}\r
+\r
+.panel { \r
+       position:relative;\r
+}\r
+\r
+.countryPanel {\r
+       z-index:1;\r
+       width:300px;\r
+       display:none;\r
+       border:1px solid #000000;\r
+       padding:0px;\r
+}\r
+</style>\r
+\r
+\r
+<script type="text/javascript">\r
+       // Captura el evento onmousemove para cualquier navegador\r
+       if (document.layers) { // Netscape\r
+               document.captureEvents(Event.MOUSEMOVE);\r
+           document.onmousemove = captureMousePosition;\r
+       } else if (document.all) { // Internet Explorer\r
+           document.onmousemove = captureMousePosition;\r
+       } else if (document.getElementById) { // Netcsape 6\r
+           document.onmousemove = captureMousePosition;\r
+       }\r
+\r
+       var mouseXMax = 0;\r
+       var mouseYMax = 0;\r
+       var mouseX = 0;\r
+       var mouseY = 0;\r
+\r
+       function captureMousePosition(e) {\r
+           if (document.layers) {\r
+                   mouseX = e.pageX;\r
+                       mouseY = e.pageY;\r
+               mouseXMax = window.innerWidth + window.pageXOffset;\r
+                   mouseYMax = window.innerHeight + window.pageYOffset;\r
+           } else if (document.all) {\r
+                   mouseX = window.event.x + document.body.scrollLeft;\r
+               mouseY = window.event.y + document.body.scrollTop;\r
+               mouseXMax = document.body.clientWidth + document.body.scrollLeft;\r
+               mouseYMax = document.body.clientHeight + document.body.scrollTop;\r
+           } else if (document.getElementById) {\r
+               mouseX = e.pageX;\r
+                   mouseY = e.pageY;\r
+               mouseXMax = window.innerWidth + window.pageXOffset;\r
+               mouseYMax = window.innerHeight + window.pageYOffset;\r
+           }\r
+       }\r
+\r
+/* Devuelve true si el explorador es Internet Explorer */\r
+var IE = document.all?true:false;\r
+\r
+function Help() {\r
+       newin=window.open("/cgi-bin/koha/help.pl","Koha Help",'width=600,height=600,toolbar=false,scrollbars=yes');\r
+}\r
+\r
+function correctRange (from, to) {\r
+       if (from <= to) {\r
+               return true;\r
+       } else {\r
+               return false;\r
+       }\r
+}\r
+\r
+function emptyField (field) {\r
+       if ((field == null) || (field == "")) {\r
+               return true;\r
+       } else {\r
+               return false;\r
+       }\r
+}\r
+\r
+function checkFields (aForm) {\r
+  var option = document.getElementById('rangeType').value;\r
+  if (option == 'continuous') {\r
+       if (emptyField(aForm.from.value) || emptyField(aForm.to.value)) {\r
+               alert("Please, complete all fields");\r
+           return false;\r
+       } else {\r
+               if (correctRange(aForm.from.value, aForm.to.value)) {\r
+                       return true;                    \r
+               } else {\r
+                       alert("The selected range is not correct");\r
+                       return false;\r
+               }\r
+       }\r
+  } else {\r
+       var codeCount = document.getElementById('inventaryList').options.length;\r
+       if (codeCount == 0) {\r
+               alert("Please, complete all fields"); \r
+           return false;\r
+       } else {\r
+               var inventaryList = document.getElementById('inventaryList');\r
+               var allCodes = '';\r
+               for (i = 0; i <= inventaryList.options.length - 1; i++) {\r
+                       allCodes = allCodes + "'" + inventaryList.options[i].text + "',";\r
+               }\r
+               allCodes = '(' + allCodes.substr(0, allCodes.length - 1) + ')';\r
+               document.getElementById('individualCodes').value = allCodes;\r
+           return true;\r
+       }\r
+  }\r
+}\r
+\r
+function changeRange(selectBox) {\r
+       var option = selectBox.value;\r
+       var panel = document.getElementById(option);\r
+       panel.style.display = 'inline';\r
+       if (option == 'continuous') {\r
+               document.getElementById('inventaryList').options.length = 0;\r
+               document.getElementById('individuals').style.display = 'none';\r
+               document.getElementById('individualCodes').value = "";\r
+       } else {\r
+               document.getElementById('from').value = "";\r
+               document.getElementById('to').value = "";\r
+               document.getElementById('continuous').style.display = 'none';\r
+       }\r
+}\r
+\r
+function itemExists(code, list) {\r
+  var ok = false;\r
+  var listLength = list.length - 1;\r
+  var count = 0;\r
+  while (!(ok) && (count <= listLength)) {\r
+       if (code == list[count].value) {\r
+         ok = true;\r
+       }\r
+       count = count + 1;\r
+  }\r
+  return ok;   \r
+}\r
+\r
+function addItem() {\r
+  var codeObject = document.getElementById('inventaryCode');\r
+  var inventaryCode = document.getElementById('inventaryCode').value;\r
+  var inventaryList = document.getElementById('inventaryList');\r
+  if (inventaryCode == "") {\r
+    alert('You canĀ“t add an empty code.');\r
+  } else {\r
+    if (itemExists(inventaryCode, inventaryList.options)) {\r
+         codeObject.value = "";\r
+         alert("The code is already included."); \r
+    } else {   \r
+         var optionObject = new Option(inventaryCode, inventaryCode);\r
+          if (!IE) {\r
+            inventaryList.add(optionObject, inventaryList.options[inventaryList.options.length]); \r
+      } else {\r
+           inventaryList.add(optionObject, inventaryList.options.length);\r
+         }\r
+      codeObject.value = "";\r
+    }\r
+  }    \r
+}\r
+\r
+function removeItem() {\r
+  var inventaryList = document.getElementById('inventaryList');\r
+  if (inventaryList.selectedIndex == -1) {\r
+       alert('You have to select a code first.');\r
+  } else {\r
+       inventaryList.options[inventaryList.selectedIndex] = null;\r
+  }\r
+}\r
+\r
+       function addCountryCode() {\r
+               var panel = document.getElementById('addCountryCode');\r
+               panel.style.display = 'inline';\r
+               panel.style.top = mouseY;\r
+               panel.style.left = mouseX;\r
+       }\r
+</script>\r
+</head>\r
+<body onload="javascript: changeRange(document.getElementById('rangeType'))">\r
+<!-- MENUS -->\r
+<div id="menubar">\r
+       <span class="koha">KOHA</span>\r
+       <a class="home" href="/cgi-bin/koha/mainpage.pl">Home</a>\r
+       <a class="catalogue" href="/cgi-bin/koha/loadmodules.pl?module=search&amp;type=intranet">Catalogue</a>\r
+       <a class="members" href="/cgi-bin/koha/members/members-home.pl">Members</a>\r
+       <a class="acquisition" href="/cgi-bin/koha/loadmodules.pl?module=acquisitions">Acquisitions</a>\r
+       <a class="circulation"  href="/cgi-bin/koha/circ/circulation.pl">Circulation</a>\r
+       <a class="authority" href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>\r
+       <a class="reports" href="/cgi-bin/koha/reports-home.pl">Reports</a>\r
+       <a class="parameters" href="/cgi-bin/koha/admin-home.pl">Parameters</a>\r
+       <a class="about" href="/cgi-bin/koha/about.pl">About</a>\r
+       <a class="catalogue" href="/cgi-bin/koha/help.pl" onclick="Help(); return false;">Help</a>\r
+</div>\r
+<div id="submenu">\r
+       <span class="koha">options &gt;&gt;&nbsp;&nbsp;</span>\r
+       <a href="/cgi-bin/koha/admin/aqbookfund.pl" class="submenu">Funds</a>\r
+       <a href="/cgi-bin/koha/admin/authorised_values.pl" class="submenu2">Auth value</a>\r
+       <a href="/cgi-bin/koha/admin/thesaurus.pl" class="submenu">Thesaurus</a>\r
+       <a href="/cgi-bin/koha/admin/currency.pl" class="submenu2">Currencies</a>\r
+       <a href="/cgi-bin/koha/admin/printers.pl" class="submenu">Printers</a>\r
+</div>\r
+<!-- TMPL_IF NAME="loggedinusername" -->\r
+    <p align="left">Logged in as: <!-- TMPL_VAR NAME="loggedinusername" --> [<a href="/cgi-bin/koha/mainpage.pl?logout.x=1">Log Out</a>]</p>\r
+<!-- TMPL_ELSE -->\r
+    <p align="left"><a href="/cgi-bin/koha/opac-user.pl">Log In</a> to Koha</p>\r
+<!-- /TMPL_IF -->\r
diff --git a/koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes.tmpl b/koha-tmpl/intranet-tmpl/default/en/barcodes/barcodes.tmpl
new file mode 100644 (file)
index 0000000..16557e5
--- /dev/null
@@ -0,0 +1,180 @@
+<!-- TMPL_INCLUDE NAME="barcodes-top.inc" -->\r
+\r
+<!-- ******************************************************************************************************** -->\r
+<!-- ******                             START OF ADD COUNTRY CODE PANEL                                ****** -->\r
+<!-- ******************************************************************************************************** -->\r
+\r
+<div class="countryPanel" style="position:absolute" id="addCountryCode">\r
+       <form action="/cgi-bin/koha/barcodes/barcodes.pl" method="post" style="display:inline">\r
+               <input type="hidden" name="addCode" value="1">\r
+               <table style="background-color:#EFEFEF;border:1px" align="center">\r
+                       <tr>\r
+                               <th colspan="2">\r
+                                       Add a new Country Code\r
+                               </th>\r
+                       </tr>\r
+                       <tr>\r
+                               <td>\r
+                                       Country Name&nbsp<input type="text" size="10" id="countryName" name="countryName"  \r
+                                                               style="background-color:#FFFFFF;color:Black"/>\r
+                               </td>\r
+                               <td>\r
+                                       Country Code&nbsp<input type="text" size="3" id="countryCode" name="countryCode"  \r
+                                                               style="background-color:#FFFFFF;color:Black"/>\r
+                               </td>\r
+                       </tr>\r
+                       <tr>\r
+                               <td align="right">\r
+                                       <input type="submit" name="submit" id="submit" value="Save Code"/>\r
+                               </td>\r
+                               <td align="left">\r
+                                       <input type="button" name="cancel" id="cancel" value="Cancel"\r
+                                              onclick="javascript: document.getElementById('addCountryCode').style.display = 'none'"/>\r
+                               </td>\r
+                       </tr>\r
+               </table>\r
+       </form>\r
+</div>\r
+\r
+<!-- ******************************************************************************************************** -->\r
+<!-- ******                              END OF ADD COUNTRY CODE PANEL                                 ****** -->\r
+<!-- ******************************************************************************************************** -->\r
+\r
+<div id="mainbloc">\r
+       <h1>Barcodes Generator</h1>\r
+       <table bgcolor="#ffcc00" width="80%" cellpadding="3">\r
+               <tr valign="center">\r
+                       <td><font size="4">Generate barcodes from inventary codes</font></td>\r
+               </tr>\r
+       </table>\r
+       <ul>\r
+               <li>Select a range of inventary codes. You can select wether a continuous range or individual inventary codes</li>\r
+               <li>Select the standard type to generate barcodes.</li>\r
+               <li>Define the page size for output the PDF.</li>\r
+               <li>Depending on page size, Koha will show you how the page is arranged\r
+                   for each barcode. You can define wich point to start printing the page.\r
+               </li>\r
+       </ul>\r
+       <br>\r
+       <form id="formulario" method="POST" action='<!-- TMPL_VAR NAME="SCRIPT_NAME" -->' name="form1"\r
+             onsubmit="return checkFields(this);" target="_blank">\r
+               \r
+               <table cellpadding="3" border=0 class="myTable">\r
+                       <!-- TMPL_IF NAME="ERROR" -->\r
+                       <tr align="center">\r
+                               <td colspan="2" >\r
+                                       <p style="font-size:13pt;color:red">CanĀ“t find inventary codes on that range. Please try again.</p>\r
+                               </td>\r
+                       </tr>\r
+                       <!-- /TMPL_IF -->\r
+                       <tr valign="top">\r
+                               <td align="right" style="width:50%;padding-right:20px"> \r
+                                       <table style="border:0px">\r
+                                               <tr align="right">\r
+                                                       <td>Type of Interval</td>\r
+                                               </tr>\r
+                                               <tr align="right">\r
+                                                       <td><!-- TMPL_VAR NAME="RANGE_TYPE" --></td>\r
+                                               </tr>\r
+                                       </table>\r
+                               </td>\r
+                               <td style="width:50%;padding-left:20px"> \r
+                                       <div id="continuous" class="panel" style="display:inline">\r
+                                               <table class="ranges">\r
+                                                       <tr>\r
+                                                               <td>From:</td> \r
+                                                               <td><input id="from" type="text" name="from" size="20"></td>\r
+                                                       </tr>\r
+                                                       <tr>\r
+                                                               <td>To:</td>\r
+                                                               <td><input id="to" type="text" name="to" size="20"></td>\r
+                                                       </tr>\r
+                                               </table>\r
+                                       </div> \r
+                                   <div id="individuals" class="panel" style="display:none">\r
+                                               <table class="ranges">\r
+                                                       <tr valign="top">\r
+                                                               <td width="5%">\r
+                                                                       Inventary Code <BR>\r
+                                                                       <input id="inventaryCode" type="text" name="inventaryCode" size="20">\r
+                                                               <td>\r
+                                                               <td align="center">     \r
+                                                                       <img src="<!-- TMPL_VAR NAME="themelang" -->/images/rightarrow.png" onclick="addItem()"\r
+                                                                            border="0" onclick="javascript: addItem();" style="cursor:pointer" style="display:table-cell">\r
+                                                                       <img src="<!-- TMPL_VAR NAME="themelang" -->/images/leftarrow.png" onclick="javascript: removeItem();" border="0" style="cursor:pointer" style="display:table-cell">\r
+                                                               </td>\r
+                                                               <td width="95%">                   \r
+                                                                       <select id='inventaryList' size='5' style="width:150px">\r
+                                                                       </select>\r
+                                                                       <input type="hidden" id='individualCodes' name="individualCodes">                                                                                                                                                                               \r
+                                                               </td>\r
+                                                       </tr>\r
+                                               </table>        \r
+                                       </div>                                          \r
+                               </td> <!-- Fin Rangos -->\r
+                       </tr>\r
+                       <tr> \r
+                               <td align="right" style="padding-right:20px">\r
+                                       <table style="border:0px">\r
+                                               <tr align="right">\r
+                                                       <td>Country Code</td>\r
+                                               </tr>\r
+                                               <tr align="right">\r
+                                                       <td>\r
+                                                               <div style="display:inline">\r
+                                                                       <img src="<!-- TMPL_VAR NAME="themelang" -->/images/more.gif" hspace="0" vspace="0" border="0" \r
+                                                                            style="vertical-align:bottom;cursor:pointer"\r
+                                                                            onclick="javascript: addCountryCode()">\r
+                                                                       <!-- TMPL_VAR NAME="NUMBER_SYSTEM" -->\r
+                                                               </div>\r
+                                                       </td>\r
+                                               </tr>\r
+                                       </table>\r
+                               </td>\r
+                               <td style="padding-left:20px"> \r
+                                       <table style="border:0px">\r
+                                               <tr>\r
+                                                       <td>Page Size</td>\r
+                                               </tr>\r
+                                               <tr>\r
+                                                       <td>\r
+                                                               <input type="text" name="pageType" readonly value="<!-- TMPL_VAR NAME="PAGES" -->"\r
+                                                                      size="10">\r
+                                                               <a href="/cgi-bin/koha/barcodes/printerConfig.pl">[Go to Printer Configuration]</a>\r
+                                                       </td>\r
+                                               </tr>\r
+                                       </table>\r
+                               </td>\r
+                       </tr>   \r
+                       <tr valign="top">\r
+                           <td colspan="2" align="center">\r
+                               <table style='width:50%'>\r
+                                               <tr style="border-color:#000FCD">\r
+                                                       <th colspan="<!-- TMPL_VAR NAME="COL_SPAN" -->">Label number to start printing</th>\r
+                                               </tr>\r
+                                               <!-- TMPL_LOOP NAME="LABEL_TABLE" -->\r
+                                                       <tr style="align:left">\r
+                                                               <!-- TMPL_LOOP NAME="columns" -->\r
+                                                                       <td style="border:1px solid #000000">\r
+                                                                               <input type="radio" id="label" value="<!-- TMPL_VAR NAME="tagname" -->"      \r
+                                                                                      name="label" <!-- TMPL_VAR NAME="check" -->>\r
+                                                                                      Label  <!-- TMPL_VAR NAME="labelname" -->\r
+                                                                       </td>\r
+                                                               <!-- /TMPL_LOOP -->\r
+                                                       </tr>\r
+                                               <!-- /TMPL_LOOP -->                         \r
+                                       </table>\r
+                               </td>\r
+                       </tr>\r
+                       <tr valign="top">\r
+                           <td align="right">\r
+                                       <input type="submit" value="Generate Barcodes" name="B1" class="button">\r
+                               </td>\r
+                           <td align="left">\r
+                               <input type="reset" value="Clear Fields" name="B2" class="button">\r
+                               </td>\r
+                       </tr>\r
+               </table>                \r
+       </form>\r
+</div>\r
+<!-- TMPL_INCLUDE NAME="barcodes-bottom.inc" -->\r
diff --git a/koha-tmpl/intranet-tmpl/default/en/barcodes/printerConfig.tmpl b/koha-tmpl/intranet-tmpl/default/en/barcodes/printerConfig.tmpl
new file mode 100644 (file)
index 0000000..55bb0ca
--- /dev/null
@@ -0,0 +1,104 @@
+<!-- TMPL_INCLUDE NAME="barcodes-top.inc" -->\r
+<div id="mainbloc">\r
+       <h1>Printer Configuration</h1>\r
+       <table bgcolor="#ffcc00" width="80%" cellpadding="3">\r
+               <tr valign="center">\r
+                       <td><font size="4">Set de printer configuration corresponding to your environment</font></td>\r
+               </tr>\r
+       </table>\r
+       <ul>\r
+               <li>Set width and heigth of the label that you are going to work with.</li>\r
+               <li>Set your system dpi by default.</li>\r
+               <li>Set the page type.</li>\r
+               <li>Select how many columns and rows are in your page type.</li>\r
+               <li>Set margin left and margin bottom of the page that you are going to use. This parameters will\r
+                   help to center the barcodes into the labels.</li>\r
+       </ul>\r
+       <br>\r
+       <form id="formulario" method="POST" action='<!-- TMPL_VAR NAME="SCRIPT_NAME" -->' name="form1">\r
+               <input type="hidden" name="saveSettings" value="1">\r
+               <table cellpadding="3" border=0 class="myTable">\r
+                       <tr>\r
+                               <td>\r
+                                       Label width (Expressed in mm)\r
+                               </td>\r
+                               <td>\r
+                                       Label heigth (Expressed in mm)\r
+                               </td>\r
+                               <td>\r
+                                       System dpi\r
+                               </td>\r
+                               <td>\r
+                                       Page Type\r
+                               </td>\r
+                               <td>\r
+                                       Columns\r
+                               </td>\r
+                               <td>\r
+                                       Rows\r
+                               </td>\r
+                               <td>\r
+                                       Margin Bottom (Expressed in mm)\r
+                               </td>\r
+                               <td>\r
+                                       Margin Left (Expressed in mm)\r
+                               </td>\r
+                       <tr>\r
+                       <tr valign="top">\r
+                               <td align="left"> \r
+                                       <input id="labelWidth" type="text" name="labelWidth" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="LABEL_WIDTH" -->">\r
+                               </td>\r
+                               <td align="left"> \r
+                                       <input id="labelHeigth" type="text" name="labelHeigth" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="LABEL_HEIGTH" -->">\r
+                               </td>\r
+                               <td align="left">\r
+                                       <input id="systemDpi" type="text" name="systemDpi" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="SYSTEM_DPI" -->">\r
+                               </td>\r
+                               <td align="left">\r
+                                       <select name="pageType" id="pageType" size="1">\r
+                                               <!-- TMPL_IF name="A4" -->\r
+                                                       <option value="A4" selected>A4</option>\r
+                                       <!-- TMPL_ELSE -->\r
+                                                       <option value="A4">A4</option>\r
+                                               <!-- /TMPL_IF -->\r
+                                               <!-- TMPL_IF name="Letter" -->\r
+                                                       <option value="Letter" selected>Letter</option>\r
+                                       <!-- TMPL_ELSE -->\r
+                                                       <option value="Letter">Letter</option>\r
+                                               <!-- /TMPL_IF -->\r
+                                               <!-- TMPL_IF name="Legal" -->\r
+                                                       <option value="Legal" selected>Legal</option>\r
+                                       <!-- TMPL_ELSE -->\r
+                                                       <option value="Legal">Legal</option>\r
+                                               <!-- /TMPL_IF -->\r
+                           </select>\r
+                               </td>\r
+                           <td align="left">\r
+                                       <input id="columns" type="text" name="columns" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="COLUMNS" -->">\r
+                               </td>\r
+                           <td align="left">\r
+                                       <input id="rows" type="text" name="rows" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="ROWS" -->">\r
+                               </td>\r
+                           <td align="left">\r
+                                       <input id="marginBottom" type="text" name="marginBottom" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="MARGIN_TOP" -->">\r
+                               </td>\r
+                           <td align="left">\r
+                                       <input id="marginLeft" type="text" name="marginLeft" size="5"\r
+                                              value="<!-- TMPL_VAR NAME="MARGIN_LEFT" -->">\r
+                               </td>\r
+                       </tr>\r
+                       <tr valign="top">\r
+                           <td colspan="8" align="center">\r
+                                       <input type="submit" value="Save Settings">\r
+                               </td>\r
+                       </tr>\r
+               </table>                \r
+       </form>\r
+</div>\r
+<!-- TMPL_INCLUDE NAME="barcodes-bottom.inc" -->\r
diff --git a/koha-tmpl/intranet-tmpl/default/en/includes/countryCodes/countryCodes.dat b/koha-tmpl/intranet-tmpl/default/en/includes/countryCodes/countryCodes.dat
new file mode 100644 (file)
index 0000000..a67e05d
--- /dev/null
@@ -0,0 +1,14 @@
+00 = USA I
+93 = Australia
+94 = New Zealand
+779 = Argentina
+773 = Uruguay
+30 = France I
+84 = Spain
+45 = Japan
+777 = Bolivia
+80 = Italy I
+73 = Sweden
+40 = Germany
+31 = France II
+254 = Ucrania
diff --git a/koha-tmpl/intranet-tmpl/default/en/includes/labelConfig/itemsLabelConfig.conf b/koha-tmpl/intranet-tmpl/default/en/includes/labelConfig/itemsLabelConfig.conf
new file mode 100644 (file)
index 0000000..5283a51
--- /dev/null
@@ -0,0 +1,8 @@
+marginBottom = 12
+pageType = A4
+columns = 3
+systemDpi = 96
+labelHeigth = 20
+rows = 11
+marginLeft = 4
+labelWidth = 70