koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/intranet/cgi-bin/barcodes arial.ttf barcod... [rel_TG]


From: Tumer Garip
Subject: [Koha-cvs] koha/intranet/cgi-bin/barcodes arial.ttf barcod... [rel_TG]
Date: Sat, 10 Mar 2007 01:13:01 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_TG
Changes by:     Tumer Garip <tgarip1957>        07/03/10 01:13:01

Added files:
        intranet/cgi-bin/barcodes: arial.ttf barcodes.pl 
                                   barcodesGenerator.pl cardConfig.pl 
                                   cbarcodes.pl empty_card.jpg 
                                   mbarcodes.pl mprinterConfig.pl 
                                   pdfViewer.pl printerConfig.pl 

Log message:
        fresh files for rel_TG

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/arial.ttf?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/barcodes.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/barcodesGenerator.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/cardConfig.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/cbarcodes.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/empty_card.jpg?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/mbarcodes.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/mprinterConfig.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/pdfViewer.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/barcodes/printerConfig.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1

Patches:
Index: arial.ttf
===================================================================
RCS file: arial.ttf
diff -N arial.ttf
Binary files /dev/null and /tmp/cvs2bnfqk differ

Index: barcodes.pl
===================================================================
RCS file: barcodes.pl
diff -N barcodes.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ barcodes.pl 10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,379 @@
+#!/usr/bin/perl
+
+# script to generate items barcodes-complete rewrite
+# rewritten 24/08/05 by T.Garip
+# by Veleda Matias - address@hidden - Physics Library UNLP Argentina and
+#    Castañeda Sebastian - address@hidden - 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::Context;
+use C4::Barcodes::PrinterConfig;
+use CGI;
+
+use C4::Output;
+
+use PDF::API2;
+use PDF::API2::Page;
+use PDF::API2::PDF::Utils;
+
+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 $input = new CGI;
+my $labelsconfigs=$input->param('labelsconfig');
+
+# It creates a list of posible intervals to choose codes to generate
+my %list = ('continuous' => 'Varolan Seri', 'individuals' => 'Tek 
tek','continuous2' => 'Yeni Seri' );
+my @listValues = keys(%list);
+my $rangeType = CGI::scrolling_list(-name => 'rangeType',
+                                       -values => address@hidden,
+                                               -labels => \%list,
+                                               -size => 1,
+                                                                       
-default => ['continuous2'],
+                                               -multiple => 0,
+                                                                       -id => 
"rangeType",
+                                                                       
-onChange =>"changeRange(this)");
+
+my $op=$input->param('op');
+
+# Takes the country codes from a file and use them to set the country list.
+my $labelCodes = &getPath("intranet")."/includes/countryCodes/labelCodes.dat";
+my %list = &loadConfFromFile($labelCodes);
address@hidden = keys(%list);
+# my $labelsconfig = CGI::scrolling_list(-name => 'labelsconfig',
+#                                                  -values => address@hidden,
+#                                                  -labels   => \%list,
+#                                                  -size     => 1,
+#                                                      -id => "labelsconfig",
+#                                                      -default => 
['itemslabelconfig'],
+#                                                      -onChange => 
"javascript:document.forms1.submit()",
+#                                                  -multiple => 0);
+my $filenameConf;
+if ($labelsconfigs){
+ $filenameConf = 
C4::Context->config('includes')."labelConfig/".$labelsconfigs.".conf";
+}else{
+ $filenameConf = 
C4::Context->config('includes')."labelConfig/itemsLabelConfig.conf";
+$labelsconfigs="itemsLabelConfig";
+}
+
+my %labelConfig = &loadConfFromFile($filenameConf);
+# Defines type of page to use in the printer process
+my @labelTable = C4::Barcodes::PrinterConfig::labelsPage($labelConfig{'rows'}, 
$labelConfig{'columns'});
+
+# 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(PAGES => $labelConfig{'pageType'});
+$template->param(RANGE_TYPE => $rangeType);
+$template->param(LABEL_TABLE => address@hidden);
+$template->param(COL_SPAN => $labelConfig{'columns'});
+$template->param($labelsconfigs => $labelsconfigs);
+$template->param(labelsconfigs => $labelsconfigs);
+#warn "$labelsconfig";
+if ($input->param('error')) {
+       $template->param(ERROR => 1);
+} else {
+       $template->param(ERROR => 0);
+}
+
+my $cgi = new CGI;
+my $from = $cgi->param('from');
+my $to = $cgi->param('to');
+my $individualCodes = $cgi->param('individualCodes');
+my $rangeType = $cgi->param('rangeType');
+my $pageType = $cgi->param('pages');
+my $label = $cgi->param('label');
+my $labelsconfigs = $cgi->param('labelsconfigs');
+my $text_under_label = $cgi->param('text_under_label');
+if (($op =="Generate Barcodes")&&($op)){
+
+
+
+# Load the config file.
+my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/".$labelsconfigs.".conf";
+my %labelConfig = &loadConfFromFile($filenameConf);
+
+# Creates a CGI object and take its parameters
+
+
+
+# Takes inventary codes from database and if they are between
+# the interval specify by parameters, it generates the correspond barcodes
+
+
+barcodesGenerator($from, $to, $rangeType, $individualCodes,$text_under_label);
+}
+# Shows the template with the real values replaced
+output_html_with_http_headers $input, $cookie, $template->output;
+
+  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;
+  }
+# Generate the checksum from an inventary code
+sub checksum {
+
+
+
+  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.'-'.$min.'-'.$sec.'.pdf';
+       return $tmpFileName;
+}
+
+sub barcodesGenerator {
+       my ($from, $to, $rangeType, $individualCodes,$text_under_label) = @_;
+       # Returns a database handler
+       my $dbh = C4::Context->dbh;
+$dbh->do('SET NAMES latin5');
+       # Create the query to database
+       # Assigns a temporary filename for the pdf file
+       my $tmpFileName = &assingFilename($from, $to);
+#      my $tmpFileName2 ="/uploaded-files/tmp-pdf/".$tmpFileName;
+# Set the temp directory for pdf´s files
+       my $htdocs = C4::Context->config('intranetdir');
+ my $upload_dir = $htdocs."/htdocs/uploaded-files/tmp-pdf/";
+               $ENV{'TEMP'} = $upload_dir;
+my $tmpFileName2 = $ENV{'TEMP'}.$tmpFileName;
+               # Creates a PDF object
+               my $pdf = PDF::API2->new(-file => $tmpFileName2);
+       if ($rangeType eq 'continuous2') {
+               
+               
+               # 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',-encode=>"iso-8859-9");
+               # Barcode position
+               my ($page, $gfx, $text);
+               for (my $code=$from; $code<=$to; $code++) {
+               my $random2 = int(rand(10000000));
+               my 
$newcode=substr($code,0,3).substr($random2,0,4).substr($code,3,3);
+                       # Generetase checksum
+                       my $codeC = $newcode;
+                       # Generate the corresponde barcode to $code
+                       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)
+                                                                               
-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 - 50, $y - 24);
+                       if ($text_under_label) {
+                               $text->text($text_under_label);
+                       }
+               }
+               # 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
+$template->param(tmpFileName=>$tmpFileName);
+#$template->param(tmpFileName2=>$tmpFileName2);
+                       $op="";
+       } else {
+               my $rangeCondition;
+               if ($individualCodes ne "") {
+                       $rangeCondition = "AND (I.barcode IN " . 
$individualCodes . ")";
+               } else {
+                       $rangeCondition =  "AND (I.barcode >= " . $from . " AND 
I.barcode <="  . $to . " )";
+               }
+                       
+               my $query = "SELECT  I.barcode AS Codigo,B.* 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
+                               
+                       
+                       # 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',-encode=>"iso-8859-9");
+                       # Barcode position
+                       my ($page, $gfx, $text);
+                       while (my ($code,$title,$author) = 
$sth->fetchrow_array) {
+                               # Generetase checksum
+#                              $code = $code);
+                               # Generate the corresponde barcode to $code
+                               my $barcode = $pdf->barcode(-font => $tr,       
# The font object to use
+                                                                               
        -type => 'ean128',      # 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 - 50, $y - 24);
+                               if ($text_under_label) {
+                                       $text->text($text_under_label);
+                               } else {
+                                       $text->text(substr $title, 0, 30);
+                                       $text->translate($x - 50, $y - 24);
+                                       $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/barcode.pl?tmpFileName=$tmpFileName");
+                       $template->param(tmpFileName=>$tmpFileName);
+#                      $template->param(tmpFileName2=>$tmpFileName2);
+                       $op="";
+               } else {
+                       # Rollback and shows the error legend
+               $template->param(ERROR => 1);   
+               $op="";
+
+               }
+       $sth->finish;
+       }
+}
\ No newline at end of file

Index: barcodesGenerator.pl
===================================================================
RCS file: barcodesGenerator.pl
diff -N barcodesGenerator.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ barcodesGenerator.pl        10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,288 @@
+#!/usr/bin/perl
+
+# script to generate items barcodes
+# written 07/04
+# by Veleda Matias - address@hidden - Physics Library UNLP Argentina and
+#    Castañeda Sebastian - address@hidden - 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 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 $rangeType = $cgi->param('rangeType');
+my $pageType = $cgi->param('pages');
+my $label = $cgi->param('label');
+my $numbersystem = $cgi->param('numbersystem');
+my $text_under_label = $cgi->param('text_under_label');
+
+# 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.'-'.$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, $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);
+# Set the temp directory for pdf´s files
+       my $htdocs = C4::Context->config('intranetdir');
+ my $upload_dir = $htdocs."/htdocs/uploaded-files/tmp-pdf/";
+               $ENV{'TEMP'} = $upload_dir;
+       if ($rangeType eq 'continuous2') {
+               
+               $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);
+               for (my $code=$from; $code<=$to; $code++) {
+               my $random2 = int(rand(10000000));
+               my 
$newcode=substr($code,0,3).substr($random2,0,4).substr($code,3,3);
+                       # Generetase checksum
+                       my $codeC = &checksum($newcode);
+                       # Generate the corresponde barcode to $code
+                       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)
+                                                                               
-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);
+                       if ($text_under_label) {
+                               $text->text($text_under_label);
+                       }
+               }
+               # 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 {
+               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',((10 - 
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 => 'ean128',      # 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);
+                               if ($text_under_label) {
+                                       $text->text($text_under_label);
+                               } else {
+                                       $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, $rangeType, $individualCodes,$text_under_label);
\ No newline at end of file

Index: cardConfig.pl
===================================================================
RCS file: cardConfig.pl
diff -N cardConfig.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cardConfig.pl       10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+
+# script to set the labels configuration for the printer process.
+# written 07/04
+# by Veleda Matias - address@hidden - 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::Context;
+use C4::Output;
+use C4::Auth;
+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/cardsConfig.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/cbarcodes.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 => {editcatalogue => 1},
+                                                debug => 1,
+                                      });
+
+my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/cardsConfig.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/cardConfig.pl');
+$template->param("$labelConfig{'pageType'}" => $labelConfig{'pageType'});
+output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file

Index: cbarcodes.pl
===================================================================
RCS file: cbarcodes.pl
diff -N cbarcodes.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cbarcodes.pl        10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,373 @@
+#!/usr/bin/perl
+
+# script to generate members barcodes-complete rewrite
+# rewritten 24/08/05 by T.Garip
+# by Veleda Matias - address@hidden - Physics Library UNLP Argentina and
+#    Castañeda Sebastian - address@hidden - 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::Interface::CGI::Output;
+
+use C4::Context;
+use C4::Barcodes::PrinterConfig;
+use CGI;
+use C4::Date;
+use C4::Output;
+use C4::Accounts2;
+use PDF::API2;
+use PDF::API2::Page;
+use PDF::API2::PDF::Utils;
+use PDF::API2::UniMap;
+
+use C4::Members;
+use Time::localtime; 
+use Data::Dumper;
+
+# 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") {
+       my $rootdir=C4::Context->config('intrahtdocs');
+               return "$rootdir/$templatesSet/$lang";
+       } else {
+       my $rootdir=C4::Context->config('opachtdocs');
+               return "$rootdir/$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 =  
C4::Context->config('includes')."labelConfig/cardsConfig.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' => 'Continuos', 'individuals' => 'Single');
+my @listValues = keys(%list);
+my $rangeType = CGI::scrolling_list(-name => 'rangeType',
+                                       -values => address@hidden,
+                                               -labels => \%list,
+                                               -size => 1,
+                                                                       
-default => ['individuals'],
+                                               -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.
+
+my $op=$input->param('op');
+
+# Takes the country codes from a file and use them to set the country list.
+
+
+
+# Get the template to use
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "barcodes/cbarcodes.tmpl",
+                                        type => "intranet",
+                                        query => $input,
+                                        authnotrequired => 0,
+                                        flagsrequired => {circulate => 1},
+                                                debug => 1,
+                                      });
+
+# Replace the template values with the real ones
+#$template->param(SCRIPT_NAME =>"/cgi-bin/koha/barcodes/cbarcode.pl");
+$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);
+}
+
+my $cgi = new CGI;
+my $from = $cgi->param('from');
+my $to = $cgi->param('to');
+my $individualCodes = $cgi->param('individualCodes');
+my $rangeType = $cgi->param('rangeType');
+my $pageType = $cgi->param('pages');
+my $label = $cgi->param('label');
+my $text_under_label = $cgi->param('text_under_label');
+if (($op =="Generate Barcodes")&&($op)){
+
+
+
+# Load the config file.
+my $filenameConf = 
C4::Context->config('includes')."labelConfig/cardsConfig.conf";
+my %labelConfig = &loadConfFromFile($filenameConf);
+
+# Creates a CGI object and take its parameters
+
+
+
+# Takes inventary codes from database and if they are between
+# the interval specify by parameters, it generates the correspond barcodes
+
+
+barcodesGenerator($from, $to, $rangeType, $individualCodes,$text_under_label);
+}
+# Shows the template with the real values replaced
+output_html_with_http_headers $input, $cookie, $template->output;
+
+  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;
+  }
+# Generate the checksum from an inventary code
+sub checksum {
+
+
+
+  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.'-'.$min.'-'.$sec.'.pdf';
+       return $tmpFileName;
+}
+
+sub barcodesGenerator {
+       my ($from, $to, $rangeType, $individualCodes,$text_under_label) = @_;
+       # Returns a database handler
+       my $dbh = C4::Context->dbh;
+       $dbh->do('SET NAMES latin5');
+       # Create the query to database
+       # Assigns a temporary filename for the pdf file
+       my $tmpFileName = &assingFilename($from, $to);
+#      my $tmpFileName2 ="/uploaded-files/tmp-pdf/".$tmpFileName;
+# Set the temp directory for pdf´s files
+       my $htdocs = C4::Context->config('intranetdir');
+ my $upload_dir = $htdocs."/htdocs/uploaded-files/tmp-pdf/";
+               $ENV{'TEMP'} = $upload_dir;
+my $tmpFileName2 = $ENV{'TEMP'}.$tmpFileName;
+               # Creates a PDF object
+
+               my $pdf = PDF::API2->new(-file => $tmpFileName2);
+       
+       
+               my $rangeCondition;
+               if ($individualCodes ne "") {
+                       $rangeCondition = " (I.cardnumber IN " . 
$individualCodes . ")";
+               } else {
+                       $rangeCondition =  " (I.cardnumber >= " . $from . " AND 
I.cardnumber <="  . $to . " )";
+               }
+                       
+               my $query = "SELECT  I.cardnumber , 
I.surname,I.firstname,I.streetaddress,I.city,I.expiry,C.description,I.borrowernumber,I.categorycode
 FROM borrowers I ,categories C WHERE I.categorycode=C.categorycode AND " 
.$rangeCondition. "  ORDER BY I.cardnumber";
+               # 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
+                               
+                       
+                       # 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', 
-encode=>"iso-8859-9");
+               #               my  $tr = $pdf->ttfont('arial.ttf', -utf8);
+                       # Barcode position
+                       my ($page, $gfx, $text);
+                       while (my 
($code,$sname,$fname,$address,$city,$expiry,$desc,$borrnum,$cat) = 
$sth->fetchrow_array) {
+$sname=~s/\xfe/þ/g;
+$fname=~s/\xfe/þ/g;
+#get picture
+my $picture;
+ my $htdocs = C4::Context->config('opacdir');
+$picture =$htdocs. "/htdocs/uploaded-files/users-photo/".$code.".jpg";
+ if (-e $picture)
+{ 
+
+#   $picture= 
"http://library.neu.edu.tr/uploaded-files/users-photo/".$code.".jpg";;
+ }else{
+$picture = $htdocs. "/htdocs/uploaded-files/users-photo/nophoto.jpg";
+ 
+}
+
+my $fee=C4::Context->preference('cardfee');
+if (($fee > 0)&& $cat eq "A") {
+
+    my $nextacctno = C4::Accounts2::getnextacctno("",$borrnum,$dbh);
+    my $usth = $dbh->prepare("insert into accountlines
+    
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
+                                                         values
+    (?,?,now(),?,?,'N',?)");
+    $usth->execute($borrnum,$nextacctno,$fee,'Card Charge -'. $code,$fee);
+    $usth->finish;
+  }
+my $img2=$pdf->image_jpeg($htdocs. 
"/htdocs/uploaded-files/users-photo/emptycard2.JPG");
+
+my $img=$pdf->image_jpeg($picture);
+
+
+                               # Generetase checksum
+#                              $code = $code;
+                               # Generate the corresponde barcode to $code
+                               my $barcode = $pdf->barcode(-font => $tr,       
# The font object to use
+                                                                               
        -type => 'ean128',      # Standard of codification
+                                                                               
        -code => $code, # Text to codify
+                                                                               
        -extn   => '012345',    # Barcode extension (if it is aplicable)
+                                                                               
        -umzn => 8,             # Top limit of the finished bar
+                                                                               
        -lmzn => 8,             # Bottom limit of the finished bar
+                                                                               
        -zone => 7,             # Bars size
+                                                                               
        -quzn => 1,             # Space destinated for legend
+                                                                               
        -ofwt => 0.01,  # Bars width
+                                                                               
        -fnsz => 7,             # Font size
+                                                                               
        -text => ''
+                                                                               
        );
+
+                       
+                               (my $x, my $y, $pdf, $page, $gfx, $text, $tr, 
$label) = 
C4::Barcodes::PrinterConfig::getLabelPosition($label,$pdf,$page,$gfx,$text,$tr,$pageType);
      
+
+my $top    = $y  + ((($labelConfig{'labelHeigth'} * 72)/25.4) / 2);
+my $bottom = $y  - ((($labelConfig{'labelHeigth'} * 72)/25.4) / 2);
+
+my $left   = $x  - ((($labelConfig{'labelWidth'} * 72)/25.4) / 2);
+my $right  = $x  + ((($labelConfig{'labelWidth'} * 72)/25.4) / 2);
+#Draws the barcode and the logo.
+my $barcode_height = $barcode->height();
+my $barcode_width = $barcode->width();
+my $back_width=$img2->width();
+my $back_height=$img2->height();
+$gfx->image($img2, $left, $bottom,244,153);
+$gfx->barcode($barcode, $left+($barcode_width/2)+4, $bottom + 
($barcode_height)+2, (72/72));
+my $img_width = 50;
+my $img_height=65;
+$gfx->image($img, 
+            $right-($img_width)-20, 
+                       $bottom+($barcode_height)+20,
+                        $img_width,$img_height
+                       );
+   
+#Draws the legend.
+
+$text->font($tr, 8);
+$text->translate($left+($barcode_width)+8, $bottom + ($barcode_height)+2);
+my $date=format_date($expiry);
+$text->text("Expires: ".$date);
+$text->font($tr, 10);
+$text->translate($x-54 , $bottom+($barcode_height)+18);
+$text->text($code);
+
+#Parses the three lines and put them into the PDF.
+my $yoffset = ($barcode_height/2);
+
+
+#$text->font($tr, 10);
+       
+  $text->translate($left+10, ($y + ($barcode_height)) - $yoffset);
+$text->text($fname.' '.$sname);
+
+  $yoffset = $yoffset + 10;
+$text->translate($left+10, ($y + ($barcode_height)) - $yoffset);
+  $yoffset = $yoffset + 10;
+        $text->text($desc);
+  $text->translate($left+10, ($y + ($barcode_height)) - $yoffset);
+  $text->text($address);
+  $yoffset = $yoffset + 10;
+
+       
+  $text->translate($left+10, ($y + ($barcode_height)) - $yoffset);
+   $text->text($city); 
+                       }
+                       # 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/mbarcode.pl?tmpFileName=$tmpFileName");
+                       $template->param(tmpFileName=>$tmpFileName);
+#                      $template->param(tmpFileName2=>$tmpFileName2);
+                       $op="";
+               } else {
+                       # Rollback and shows the error legend
+               $template->param(ERROR => 1);   
+               $op="";
+
+               }
+       $sth->finish;
+       }

Index: empty_card.jpg
===================================================================
RCS file: empty_card.jpg
diff -N empty_card.jpg
Binary files /dev/null and /tmp/cvs7vyMAp differ

Index: mbarcodes.pl
===================================================================
RCS file: mbarcodes.pl
diff -N mbarcodes.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ mbarcodes.pl        10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,353 @@
+#!/usr/bin/perl
+
+# script to generate members barcodes-complete rewrite
+# rewritten 24/08/05 by T.Garip
+# by Veleda Matias - address@hidden - Physics Library UNLP Argentina and
+#    Castañeda Sebastian - address@hidden - 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::Context;
+use C4::Barcodes::PrinterConfig;
+use CGI;
+
+use C4::Output;
+
+use PDF::API2;
+use PDF::API2::Page;
+use PDF::API2::PDF::Utils;
+use PDF::API2::UniMap;
+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/membersConfig.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' => 'Varolan Seri', 'individuals' => 'Tek 
tek','continuous2'=>'Yeni Seri');
+my @listValues = keys(%list);
+my $rangeType = CGI::scrolling_list(-name => 'rangeType',
+                                       -values => address@hidden,
+                                               -labels => \%list,
+                                               -size => 1,
+                                                                       
-default => ['individuals'],
+                                               -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.
+
+my $op=$input->param('op');
+
+# Takes the country codes from a file and use them to set the country list.
+
+
+
+# Get the template to use
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "barcodes/mbarcodes.tmpl",
+                                        type => "intranet",
+                                        query => $input,
+                                        authnotrequired => 0,
+                                        flagsrequired => {circulate => 1},
+                                                debug => 1,
+                                      });
+
+# Replace the template values with the real ones
+#$template->param(SCRIPT_NAME =>"/cgi-bin/koha/barcodes/mbarcode.pl");
+$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);
+}
+
+my $cgi = new CGI;
+my $from = $cgi->param('from');
+my $to = $cgi->param('to');
+my $individualCodes = $cgi->param('individualCodes');
+my $rangeType = $cgi->param('rangeType');
+my $pageType = $cgi->param('pages');
+my $label = $cgi->param('label');
+my $text_under_label = $cgi->param('text_under_label');
+if (($op =="Generate Barcodes")&&($op)){
+
+
+
+# Load the config file.
+my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/membersConfig.conf";
+my %labelConfig = &loadConfFromFile($filenameConf);
+
+# Creates a CGI object and take its parameters
+
+
+
+# Takes inventary codes from database and if they are between
+# the interval specify by parameters, it generates the correspond barcodes
+
+
+barcodesGenerator($from, $to, $rangeType, $individualCodes,$text_under_label);
+}
+# Shows the template with the real values replaced
+output_html_with_http_headers $input, $cookie, $template->output;
+
+  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;
+  }
+# Generate the checksum from an inventary code
+sub checksum {
+
+
+
+  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.'-'.$min.'-'.$sec.'.pdf';
+       return $tmpFileName;
+}
+
+sub barcodesGenerator {
+       my ($from, $to, $rangeType, $individualCodes,$text_under_label) = @_;
+       # Returns a database handler
+       my $dbh = C4::Context->dbh;
+       $dbh->do('SET NAMES latin5');
+       # Create the query to database
+       # Assigns a temporary filename for the pdf file
+       my $tmpFileName = &assingFilename($from, $to);
+#      my $tmpFileName2 ="/uploaded-files/tmp-pdf/".$tmpFileName;
+# Set the temp directory for pdf´s files
+       my $htdocs = C4::Context->config('intranetdir');
+ my $upload_dir = $htdocs."/htdocs/uploaded-files/tmp-pdf/";
+               $ENV{'TEMP'} = $upload_dir;
+my $tmpFileName2 = $ENV{'TEMP'}.$tmpFileName;
+               # Creates a PDF object
+               my $pdf = PDF::API2->new(-file => $tmpFileName2);
+       if ($rangeType eq 'continuous2') {
+               
+               
+               # 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->ttfont('arial.ttf',-encode=>"iso-8859-9");
+               # Barcode position
+               my ($page, $gfx, $text);
+               for (my $code=$from; $code<=$to; $code++) {
+                       # Generetase checksum
+                       my $codeC = $code;
+                       # Generate the corresponde barcode to $code
+                       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)
+                                                                               
-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 - 50, $y - 24);
+                       if ($text_under_label) {
+                               $text->text($text_under_label);
+                       }
+               }
+               # 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
+$template->param(tmpFileName=>$tmpFileName);
+#$template->param(tmpFileName2=>$tmpFileName2);
+                       $op="";
+       } else {
+               my $rangeCondition;
+               if ($individualCodes ne "") {
+                       $rangeCondition = " (I.cardnumber IN " . 
$individualCodes . ")";
+               } else {
+                       $rangeCondition =  " (I.cardnumber >= " . $from . " AND 
I.cardnumber <="  . $to . " )";
+               }
+                       
+               my $query = "SELECT  I.cardnumber , I.surname FROM borrowers I 
WHERE " .$rangeCondition. "  ORDER BY I.cardnumber";
+               # 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
+                               
+                       
+                       # 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->ttfont('arial.ttf', 
-encode=>"iso-8859-9");
+                       # Barcode position
+                       my ($page, $gfx, $text);
+                       while (my ($code,$title) = $sth->fetchrow_array) {
+                               # Generetase checksum
+#                              $code = $code;
+                               # Generate the corresponde barcode to $code
+                               my $barcode = $pdf->barcode(-font => $tr,       
# The font object to use
+                                                                               
        -type => 'ean128',      # 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 - 50, $y - 24);
+                               if ($text_under_label) {
+                                       $text->text($text_under_label);
+                               } else {
+                                       $text->text($title);
+                                       
+                               }
+                       }
+                       # 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/mbarcode.pl?tmpFileName=$tmpFileName");
+                       $template->param(tmpFileName=>$tmpFileName);
+#                      $template->param(tmpFileName2=>$tmpFileName2);
+                       $op="";
+               } else {
+                       # Rollback and shows the error legend
+               $template->param(ERROR => 1);   
+               $op="";
+
+               }
+       $sth->finish;
+       }
+}
\ No newline at end of file

Index: mprinterConfig.pl
===================================================================
RCS file: mprinterConfig.pl
diff -N mprinterConfig.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ mprinterConfig.pl   10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,116 @@
+#!/usr/bin/perl
+
+# script to set the labels configuration for the printer process.
+# written 07/04
+# by Veleda Matias - address@hidden - 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 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/membersConfig.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/mbarcodes.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 => {editcatalogue => 1},
+                                                debug => 1,
+                                      });
+
+my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/membersConfig.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/mprinterConfig.pl');
+$template->param("$labelConfig{'pageType'}" => $labelConfig{'pageType'});
+output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file

Index: pdfViewer.pl
===================================================================
RCS file: pdfViewer.pl
diff -N pdfViewer.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pdfViewer.pl        10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+
+# script to show a PDF file.
+# written 07/04
+# by Veleda Matias - address@hidden - Physics Library UNLP Argentina and
+#    Castañeda Sebastian - address@hidden - 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 $opachtdocs=C4::Context->config('intrahtdocs');
+my $tmpFileName = $cgi->param('tmpFileName');
+print $cgi->header(-type => 'application/pdf'),
+      $cgi->start_html(-title=>"Codify to PDF");
+open fh, "<$opachtdocs.$tmpFileName" || die "no file";
+while (<fh>) {
+ print;
+}
+print $cgi->end_html();
\ No newline at end of file

Index: printerConfig.pl
===================================================================
RCS file: printerConfig.pl
diff -N printerConfig.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ printerConfig.pl    10 Mar 2007 01:13:01 -0000      1.1.2.1
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+
+# script to set the labels configuration for the printer process.
+# written 07/04
+# by Veleda Matias - address@hidden - 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 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 its parameters
+my $input = new CGI;
+my $labelsconfig=$input->param('labelsconfig');
+if ($input->param('saveSettings')) {
+       my $labelConf = 
&getPath("intranet")."/includes/labelConfig/".$labelsconfig.".conf";
+#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?labelsconfig='.$labelsconfig)
+}
+
+# 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/".$labelsconfig.".conf";
+my %labelConfig = &loadConfFromFile($filenameConf);
+$template->param(labelsconfig =>$labelsconfig);
+$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;
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]