koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/barcodes barcodes.pl barcodesGenerator.pl ... [dev_week]


From: Mason James
Subject: [Koha-cvs] koha/barcodes barcodes.pl barcodesGenerator.pl ... [dev_week]
Date: Fri, 06 Oct 2006 01:58:47 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Mason James <sushi>     06/10/06 01:58:47

Modified files:
        barcodes       : barcodes.pl barcodesGenerator.pl 
                         label-create-template.pl label-edit-template.pl 
                         label-home.pl label-item-search.pl 
                         label-manager.pl label-print-pdf.pl 
                         label-print.pl label-save-template.pl 
                         label-select-pdf.pl label-templates.pl 
                         pdfViewer.pl printerConfig.pl 

Log message:
        

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/barcodes.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.3.2.4&r2=1.3.2.4.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/barcodesGenerator.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.4&r2=1.4.4.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-create-template.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-edit-template.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-home.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.1&r2=1.3.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-item-search.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1.2.3&r2=1.1.2.1.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1.2.2&r2=1.1.2.1.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.2.2.3&r2=1.1.2.2.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1.2.1&r2=1.1.2.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-save-template.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-select-pdf.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-templates.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/pdfViewer.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.2.2.1&r2=1.2.2.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/printerConfig.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.2.2.3&r2=1.2.2.3.2.1

Patches:
Index: barcodes.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/barcodes.pl,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.4.2.1
diff -u -b -r1.3.2.4 -r1.3.2.4.2.1
--- barcodes.pl 5 Feb 2006 21:59:21 -0000       1.3.2.4
+++ barcodes.pl 6 Oct 2006 01:58:47 -0000       1.3.2.4.2.1
@@ -30,17 +30,16 @@
 use C4::Context;
 use C4::Barcodes::PrinterConfig;
 
-
-
 # This function returns the path to deal with the correct files, considering
 # templates set and language.
 sub getPath {
        my $type = shift @_;
        my $templatesSet = C4::Context->preference('template');
        my $lang = C4::Context->preference('opaclanguages');
-       if ($type eq "intranet") {
+    if ( $type eq "intranet" ) {
                return 
"$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
-       } else {
+    }
+    else {
                return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
        }
 }
@@ -63,85 +62,104 @@
 # Save settings to a configuration file. It delete previous configuration 
settings.
 sub saveConfToFile {
        my $fileName = shift @_;
-       my %keyValues = %{shift @_};
+    my %keyValues = %{ shift @_ };
        my $i;
        open FILE, ">$fileName";                        
        my $i;
-       foreach $i (keys(%keyValues)) {
-    print FILE $i." = ".$keyValues{$i}."\n";
+    foreach $i ( keys(%keyValues) ) {
+        print FILE $i . " = " . $keyValues{$i} . "\n";
        }
        close FILE;
 }
 
 # Load the config file.
-my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+  &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
 my %labelConfig = &loadConfFromFile($filenameConf);
 
 my $input = new CGI;
+
 # Defines type of page to use in the printer process
-my @labelTable = C4::Barcodes::PrinterConfig::labelsPage($labelConfig{'rows'}, 
$labelConfig{'columns'});
+my @labelTable =
+  C4::Barcodes::PrinterConfig::labelsPage( $labelConfig{'rows'},
+    $labelConfig{'columns'} );
 
 # It creates a list of posible intervals to choose codes to generate
-my %list = ('continuous' => 'Continuous Range of items', 'individuals' => 
'Individual Codes');
+my %list = (
+    'continuous'  => 'Continuous Range of items',
+    'individuals' => 'Individual Codes'
+);
 my @listValues = keys(%list);
-my $rangeType = CGI::scrolling_list(-name => 'rangeType',
+my $rangeType  = CGI::scrolling_list(
+    -name     => 'rangeType',
                                        -values => address@hidden,
                                                -labels => \%list,
                                                -size => 1,
                                                                        
-default => ['continuous'],
                                                -multiple => 0,
                                                                        -id => 
"rangeType",
-                                                                       
-onChange => "changeRange(this)");
+    -onChange => "changeRange(this)"
+);
+
 # It creates a list of posible standard codifications. First checks if the 
user has just added a new code.
-if ($input->param('addCode')) {
+if ( $input->param('addCode') ) {
        my $newCountryName = $input->param('countryName');
        my $newCountryCode = $input->param('countryCode'); 
 
-       my $countryCodesFilename = 
&getPath("intranet")."/includes/countryCodes/countryCodes.dat";
+    my $countryCodesFilename =
+      &getPath("intranet") . "/includes/countryCodes/countryCodes.dat";
        open COUNTRY_CODES, ">>$countryCodesFilename";                  
-    print COUNTRY_CODES $newCountryCode." = ".$newCountryName."\n";
+    print COUNTRY_CODES $newCountryCode . " = " . $newCountryName . "\n";
        close COUNTRY_CODES;
 }
 
 # Takes the country codes from a file and use them to set the country list.
-my $countryCodes = 
&getPath("intranet")."/includes/countryCodes/countryCodes.dat";
+my $countryCodes =
+  &getPath("intranet") . "/includes/countryCodes/countryCodes.dat";
 my %list = &loadConfFromFile($countryCodes);
 @listValues = keys(%list);
-my $number_system = CGI::scrolling_list(-name => 'numbersystem',
+my $number_system = CGI::scrolling_list(
+    -name     => 'numbersystem',
                                            -values => address@hidden,
                                                    -labels   => \%list,
                                                    -size     => 1,
-                                                   -multiple => 0);
+    -multiple => 0
+);
 
 # Set the script name
 my $script_name = "/cgi-bin/koha/barcodes/barcodesGenerator.pl";
 
-
 # Get the template to use
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "barcodes/barcodes.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "barcodes/barcodes.tmpl",
                                         type => "intranet",
                                         query => $input,
                                         authnotrequired => 0,
-                                        flagsrequired => {parameters => 1},
+        flagsrequired   => { parameters => 1 },
                                                 debug => 1,
-                                      });
+    }
+);
 
 # Replace the template values with the real ones
-$template->param(SCRIPT_NAME => $script_name);
-$template->param(NUMBER_SYSTEM => $number_system);
-$template->param(PAGES => $labelConfig{'pageType'});
-$template->param(RANGE_TYPE => $rangeType);
-$template->param(LABEL_TABLE => address@hidden);
-$template->param(COL_SPAN => $labelConfig{'columns'});
-if ($input->param('error')) {
-       $template->param(ERROR => 1);
-} else {
-       $template->param(ERROR => 0);
+$template->param( SCRIPT_NAME   => $script_name );
+$template->param( NUMBER_SYSTEM => $number_system );
+$template->param( PAGES         => $labelConfig{'pageType'} );
+$template->param( RANGE_TYPE    => $rangeType );
+$template->param( LABEL_TABLE   => address@hidden );
+$template->param( COL_SPAN      => $labelConfig{'columns'} );
+if ( $input->param('error') ) {
+    $template->param( ERROR => 1 );
 }
-$template->param(intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
+else {
+    $template->param( ERROR => 0 );
+}
+$template->param(
+    intranetcolorstylesheet =>
+      C4::Context->preference("intranetcolorstylesheet"),
                intranetstylesheet => 
C4::Context->preference("intranetstylesheet"),
                IntranetNav => C4::Context->preference("IntranetNav"),
-               );
+);
+
 # Shows the template with the real values replaced
 output_html_with_http_headers $input, $cookie, $template->output;

Index: barcodesGenerator.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/barcodesGenerator.pl,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -b -r1.4 -r1.4.4.1
--- barcodesGenerator.pl        8 Nov 2004 19:47:16 -0000       1.4
+++ barcodesGenerator.pl        6 Oct 2006 01:58:47 -0000       1.4.4.1
@@ -34,16 +34,16 @@
 use C4::Barcodes::PrinterConfig;
 use Time::localtime; 
 
-
 # This function returns the path to deal with the correct files, considering
 # templates set and language.
 sub getPath {
        my $type = shift @_;
        my $templatesSet = C4::Context->preference('template');
        my $lang = C4::Context->preference('opaclanguages');
-       if ($type eq "intranet") {
+    if ( $type eq "intranet" ) {
                return 
"$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
-       } else {
+    }
+    else {
                return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
        }
 }
@@ -66,18 +66,19 @@
 # Save settings to a configuration file. It delete previous configuration 
settings.
 sub saveConfToFile {
        my $fileName = shift @_;
-       my %keyValues = %{shift @_};
+    my %keyValues = %{ shift @_ };
        my $i;
        open FILE, ">$fileName";                        
        my $i;
-       foreach $i (keys(%keyValues)) {
-    print FILE $i." = ".$keyValues{$i}."\n";
+    foreach $i ( keys(%keyValues) ) {
+        print FILE $i . " = " . $keyValues{$i} . "\n";
        }
        close FILE;
 }
 
 # Load the config file.
-my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+  &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
 my %labelConfig = &loadConfFromFile($filenameConf);
 
 # Creates a CGI object and take its parameters
@@ -99,18 +100,20 @@
     my $sum = 0;
          my $odd_parity = 1;
     my $i;
-    for ($i = length($code) - 1; $i >= 0; $i--){
-          if ( $odd_parity ) {
-                 $sum = $sum + ( 3 * substr($code, $i, 1) );
-     } else {
-                       $sum = $sum + substr($code, $i, 1); }
+        for ( $i = length($code) - 1 ; $i >= 0 ; $i-- ) {
+            if ($odd_parity) {
+                $sum = $sum + ( 3 * substr( $code, $i, 1 ) );
+            }
+            else {
+                $sum = $sum + substr( $code, $i, 1 );
+            }
                  $odd_parity = !$odd_parity;
           }
-    my $check_digit = 10 - ($sum%10);
-       if ($check_digit==10) {
-               $check_digit=0;
+        my $check_digit = 10 - ( $sum % 10 );
+        if ( $check_digit == 10 ) {
+            $check_digit = 0;
        }
-         return $code.$check_digit;
+        return $code . $check_digit;
   }
 
   my $currentCode = shift @_;
@@ -120,49 +123,75 @@
 
 # Assigns a temporary name to the PDF file
 sub assingFilename {
-       my ($from, $to) = @_;
+    my ( $from, $to ) = @_;
        my $ip = $cgi->remote_addr();
-       my $random = int(rand(1000000));
+    my $random  = int( rand(1000000) );
     my $timeObj = localtime();
-       my ($day, $month, $year, $hour, $min, $sec) = ($timeObj->mday,
+    my ( $day, $month, $year, $hour, $min, $sec ) = (
+        $timeObj->mday,
                                                                                
                   $timeObj->mon + 1,
                                                                                
                   $timeObj->year + 1900,
-                                                                               
                   $timeObj->hour,
-                                                                               
                   $timeObj->min,
-                                                                               
                   $timeObj->sec);
-       my $tmpFileName = $random.'-'.$ip.'-(From '.$from.' to 
'.$to.')-['.$day.'.'.$month.'.'.$year.']-['.$hour.':'.$min.':'.$sec.'].pdf';
+        $timeObj->hour, $timeObj->min, $timeObj->sec
+    );
+    my $tmpFileName =
+        $random . '-' . $ip
+      . '-(From '
+      . $from . ' to '
+      . $to . ')-['
+      . $day . '.'
+      . $month . '.'
+      . $year . ']-['
+      . $hour . ':'
+      . $min . ':'
+      . $sec . '].pdf';
        return $tmpFileName;
 }
 
 # Takes inventary codes from database and if they are between
 # the interval specify by parameters, it generates the correspond barcodes
 sub barcodesGenerator {
-       my ($from, $to, $rangeType, $individualCodes,$text_under_label) = @_;
+    my ( $from, $to, $rangeType, $individualCodes, $text_under_label ) = @_;
+
        # Returns a database handler
        my $dbh = C4::Context->dbh;
+
        # Create the query to database
        # Assigns a temporary filename for the pdf file
-       my $tmpFileName = &assingFilename($from, $to);
-       if ($rangeType eq 'continuous2') {
+    my $tmpFileName = &assingFilename( $from, $to );
+    if ( $rangeType eq 'continuous2' ) {
+
                # Set the temp directory for pdf´s files
-               if (!defined($ENV{'TEMP'})) {
+        if ( !defined( $ENV{'TEMP'} ) ) {
                        $ENV{'TEMP'} = '/tmp/';
                }       
-               $tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+        $tmpFileName = $ENV{'TEMP'} . $tmpFileName;
+
                # Creates a PDF object
-               my $pdf = PDF::API2->new(-file => $tmpFileName);
+        my $pdf = PDF::API2->new( -file => $tmpFileName );
+
                # Set the positions where barcodes are going to be placed
-               
C4::Barcodes::PrinterConfig::setPositionsForX($labelConfig{'marginLeft'}, 
$labelConfig{'labelWidth'}, $labelConfig{'columns'}, $labelConfig{'pageType'});
-               
C4::Barcodes::PrinterConfig::setPositionsForY($labelConfig{'marginBottom'}, 
$labelConfig{'labelHeigth'}, $labelConfig{'rows'}, $labelConfig{'pageType'});
+        C4::Barcodes::PrinterConfig::setPositionsForX(
+            $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'},
+            $labelConfig{'columns'},    $labelConfig{'pageType'}
+        );
+        C4::Barcodes::PrinterConfig::setPositionsForY(
+            $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'},
+            $labelConfig{'rows'},         $labelConfig{'pageType'}
+        );
+
                # Creates a font object
                my $tr = $pdf->corefont('Helvetica-Bold');
+
                # Barcode position
-               my ($page, $gfx, $text);
-               for (my $code=$from; $code<=$to; $code++) {
+        my ( $page, $gfx, $text );
+        for ( my $code = $from ; $code <= $to ; $code++ ) {
+
                        # Generetase checksum
                        my $codeC = &checksum($code);
+
                        # Generate the corresponde barcode to $code
-                       my $barcode = $pdf->barcode(-font => $tr,       # The 
font object to use
+            my $barcode = $pdf->barcode(
+                -font => $tr,         # The font object to use
                                                                                
-type => 'ean128',      # Standard of codification
                                                                                
-code => $codeC, # Text to codify
                                                                                
-extn   => '012345',    # Barcode extension (if it is aplicable)
@@ -175,66 +204,90 @@
                                                                                
-text => ''
                                                                                
);
                        
-                       (my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label) = 
C4::Barcodes::PrinterConfig::getLabelPosition(
-                                                                               
                                                                                
                $label, 
-                                                                               
                                                                                
                $pdf, 
-                                                                               
                                                                                
                $page,
-                                                                               
                                                                                
                $gfx,
-                                                                               
                                                                                
                $text,
-                                                                               
                                                                                
                $tr,
-                                                                               
                                                                                
                $pageType);     
+            ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) =
+              C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf,
+                $page, $gfx, $text, $tr, $pageType );
+
                        # Assigns a barcodes to $gfx
-                       $gfx->barcode($barcode, $x, $y , 
(72/$labelConfig{'systemDpi'}));
+            $gfx->barcode( $barcode, $x, $y,
+                ( 72 / $labelConfig{'systemDpi'} ) );
+
                        # Assigns the additional information to the barcode 
(Legend)
-                       $text->translate($x - 48, $y - 22);
+            $text->translate( $x - 48, $y - 22 );
                        if ($text_under_label) {
                                $text->text($text_under_label);
                        }
                }
+
                # Writes the objects added in $gfx to $page
-               $pdf->finishobjects($page,$gfx, $text);
+        $pdf->finishobjects( $page, $gfx, $text );
+
                # Save changes to the PDF
                $pdf->saveas;
+
                # Close the conection with the PDF file
                $pdf->end;
+
                # Show the PDF file
-               print 
$cgi->redirect("/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
-       } else {
+        print $cgi->redirect(
+            "/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
+    }
+    else {
                my $rangeCondition;
-               if ($individualCodes ne "") {
+        if ( $individualCodes ne "" ) {
                        $rangeCondition = "AND (I.barcode IN " . 
$individualCodes . ")";
-               } else {
-                       $rangeCondition =  "AND (I.barcode >= " . $from . " AND 
I.barcode <="  . $to . " )";
+        }
+        else {
+            $rangeCondition =
+              "AND (I.barcode >= " . $from . " AND I.barcode <=" . $to . " )";
                }
                        
-               my $query = "SELECT CONCAT('$numbersystem',REPEAT('0',((12 - 
LENGTH('$numbersystem')) - LENGTH(I.barcode))), I.barcode) AS Codigo, B.title, 
B.author FROM biblio B, items I WHERE (I.biblionumber = B.biblioNumber ) " 
.$rangeCondition. " AND (I.barcode <> 'FALTA') ORDER BY Codigo";
+        my $query =
+"SELECT CONCAT('$numbersystem',REPEAT('0',((12 - LENGTH('$numbersystem')) - 
LENGTH(I.barcode))), I.barcode) AS Codigo, B.title, B.author FROM biblio B, 
items I WHERE (I.biblionumber = B.biblioNumber ) "
+          . $rangeCondition
+          . " AND (I.barcode <> 'FALTA') ORDER BY Codigo";
                
                # Prepare the query
                my $sth = $dbh->prepare($query);
+
                # Executes the query
                $sth->execute;
-               if ($sth->rows) { # There are inventary codes
+        if ( $sth->rows ) {    # There are inventary codes
                        # Set the temp directory for pdf´s files
-                       if (!defined($ENV{'TEMP'})) {
+            if ( !defined( $ENV{'TEMP'} ) ) {
                                $ENV{'TEMP'} = '/tmp/';
                        }       
+
                        # Assigns a temporary filename for the pdf file
-                       my $tmpFileName = &assingFilename($from, $to);
-                       $tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+            my $tmpFileName = &assingFilename( $from, $to );
+            $tmpFileName = $ENV{'TEMP'} . $tmpFileName;
+
                        # Creates a PDF object
-                       my $pdf = PDF::API2->new(-file => $tmpFileName);
+            my $pdf = PDF::API2->new( -file => $tmpFileName );
+
                        # Set the positions where barcodes are going to be 
placed
-                       
C4::Barcodes::PrinterConfig::setPositionsForX($labelConfig{'marginLeft'}, 
$labelConfig{'labelWidth'}, $labelConfig{'columns'}, $labelConfig{'pageType'});
-                       
C4::Barcodes::PrinterConfig::setPositionsForY($labelConfig{'marginBottom'}, 
$labelConfig{'labelHeigth'}, $labelConfig{'rows'}, $labelConfig{'pageType'});
+            C4::Barcodes::PrinterConfig::setPositionsForX(
+                $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'},
+                $labelConfig{'columns'},    $labelConfig{'pageType'}
+            );
+            C4::Barcodes::PrinterConfig::setPositionsForY(
+                $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'},
+                $labelConfig{'rows'},         $labelConfig{'pageType'}
+            );
+
                        # Creates a font object
                        my $tr = $pdf->corefont('Helvetica-Bold');
+
                        # Barcode position
-                       my ($page, $gfx, $text);
-                       while (my ($code,$title,$author) = 
$sth->fetchrow_array) {
+            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
+                my $barcode = $pdf->barcode(
+                    -font => $tr,       # The font object to use
                                                                                
        -type => 'ean13',       # Standard of codification
                                                                                
        -code => $code, # Text to codify
                                                                                
        -extn   => '012345',    # Barcode extension (if it is aplicable)
@@ -247,35 +300,41 @@
                                                                                
        -text => ''
                                                                                
        );
                                
-                               (my $x, my $y, $pdf, $page, $gfx, $text, $tr, 
$label) = C4::Barcodes::PrinterConfig::getLabelPosition(
-                                                                               
                                                                                
                        $label, 
-                                                                               
                                                                                
                        $pdf, 
-                                                                               
                                                                                
                        $page,
-                                                                               
                                                                                
                        $gfx,
-                                                                               
                                                                                
                        $text,
-                                                                               
                                                                                
                        $tr,
-                                                                               
                                                                                
                        $pageType);     
+                ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) =
+                  C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf,
+                    $page, $gfx, $text, $tr, $pageType );
+
                                # Assigns a barcodes to $gfx
-                               $gfx->barcode($barcode, $x, $y , 
(72/$labelConfig{'systemDpi'}));
+                $gfx->barcode( $barcode, $x, $y,
+                    ( 72 / $labelConfig{'systemDpi'} ) );
+
                                # Assigns the additional information to the 
barcode (Legend)
-                               $text->translate($x - 48, $y - 22);
+                $text->translate( $x - 48, $y - 22 );
                                if ($text_under_label) {
                                        $text->text($text_under_label);
-                               } else {
-                                       $text->text(substr $title, 0, 30);
-                                       $text->translate($x - 48, $y - 29);
-                                       $text->text(substr $author, 0, 30);
                                }
+                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);
+            $pdf->finishobjects( $page, $gfx, $text );
+
                        # Save changes to the PDF
                        $pdf->saveas;
+
                        # Close the conection with the PDF file
                        $pdf->end;
+
                        # Show the PDF file
-                       print 
$cgi->redirect("/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
-               } else {
+            print $cgi->redirect(
+                
"/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
+        }
+        else {
+
                        # Rollback and shows the error legend
                        print 
$cgi->redirect("/cgi-bin/koha/barcodes/barcodes.pl?error=1");
                }
@@ -283,4 +342,5 @@
        }
 }
 
-barcodesGenerator($from, $to, $rangeType, $individualCodes,$text_under_label);
\ No newline at end of file
+barcodesGenerator( $from, $to, $rangeType, $individualCodes,
+    $text_under_label );

Index: label-create-template.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/Attic/label-create-template.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-create-template.pl    2 Oct 2006 22:01:39 -0000       1.1.2.1
+++ label-create-template.pl    6 Oct 2006 01:58:47 -0000       1.1.2.2
@@ -31,24 +31,23 @@
 my $units     = $query->param('units');
 my $fontsize    = $query->param('fontsize');
 
-$active = 1 if ($active eq 'on');
+$active = 1 if ( $active eq 'on' );
 
 my $op     = $query->param('op');
 my @resultsloop;
 
 my ( $template, $loggedinuser, $cookie );
 
-if ($op eq 'blank') {
-
-my @units = (
-       {unit => 'INCH', desc => 'Inches' },
-       {unit => 'CM',  desc => 'Centimeters' },
-       {unit => 'MM',  desc => 'Millimeters' },
-       {unit => 'POINT', desc => 'Postscript Points' },
-);
+if ( $op eq 'blank' ) {
 
+    my @units = (
+        { unit => 'INCH',  desc => 'Inches' },
+        { unit => 'CM',    desc => 'Centimeters' },
+        { unit => 'MM',    desc => 'Millimeters' },
+        { unit => 'POINT', desc => 'Postscript Points' },
+    );
 
-( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
         template_name   => "barcodes/label-create-template.tmpl",
         query           => $query,
@@ -65,16 +64,13 @@
       C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
     IntranetNav        => C4::Context->preference("IntranetNav"),
-);
+    );
 
 }
 
+elsif ( $op eq 'create' ) {
 
-
-elsif ($op eq 'create') {
-
-
-( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
         template_name   => "barcodes/label-templates.tmpl",
         query           => $query,
@@ -85,7 +81,6 @@
     }
    );
 
-
     CreateTemplate(
 
                $tmpl_code,  $tmpl_desc,    $page_width,
@@ -95,18 +90,16 @@
 
                );
 
+    @resultsloop = GetAllLabelTemplates();
 
-       @resultsloop=GetAllLabelTemplates();
-
-$template->param(
+    $template->param(
     resultsloop => address@hidden,
 
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
     IntranetNav        => C4::Context->preference("IntranetNav"),
-);
-
+    );
 
 }
 output_html_with_http_headers $query, $cookie, $template->output;

Index: label-edit-template.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/Attic/label-edit-template.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-edit-template.pl      2 Oct 2006 22:01:39 -0000       1.1.2.1
+++ label-edit-template.pl      6 Oct 2006 01:58:47 -0000       1.1.2.2
@@ -40,10 +40,10 @@
 warn Dumper $tmpl;
 
 my @units = (
-       {unit => 'INCH', desc => 'Inches' },
-       {unit => 'CM',  desc => 'Centimeters' },
-       {unit => 'MM',  desc => 'Millimeters' },
-       {unit => 'POINT', desc => 'Postscript Points' },
+    { unit => 'INCH',  desc => 'Inches' },
+    { unit => 'CM',    desc => 'Centimeters' },
+    { unit => 'MM',    desc => 'Millimeters' },
+    { unit => 'POINT', desc => 'Postscript Points' },
 );
 
 foreach my $unit (@units) {

Index: label-home.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-home.pl,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -u -b -r1.3.4.1 -r1.3.4.2
--- label-home.pl       2 Oct 2006 22:01:39 -0000       1.3.4.1
+++ label-home.pl       6 Oct 2006 01:58:47 -0000       1.3.4.2
@@ -25,12 +25,11 @@
 
 my $data  = get_label_options();
 
-my $active_template =GetActiveLabelTemplate();
+my $active_template = GetActiveLabelTemplate();
 my @label_templates = GetAllLabelTemplates();
 
 warn Dumper @label_templates;
 
-
 $template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
 
 $data->{'printingtype'} = 'both' if ( !$data->{'printingtype'} );
@@ -59,13 +58,10 @@
     startlabel  => $data->{'startlabel'},
     fontsize    => $active_template->{'fontsize'},
 
-
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
     IntranetNav        => C4::Context->preference("IntranetNav"),
 );
 
-
-
 output_html_with_http_headers $query, $cookie, $template->output;

Index: label-item-search.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-item-search.pl,v
retrieving revision 1.1.2.1.2.3
retrieving revision 1.1.2.1.2.4
diff -u -b -r1.1.2.1.2.3 -r1.1.2.1.2.4
--- label-item-search.pl        2 Oct 2006 22:01:39 -0000       1.1.2.1.2.3
+++ label-item-search.pl        6 Oct 2006 01:58:47 -0000       1.1.2.1.2.4
@@ -151,7 +151,8 @@
             #warn $i;
             #warn Dumper $results->[$i]{'bibid'};
         my $type         = 'intra';
-        my @item_results = &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type 
);
+        my @item_results =
+          &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type );
 
         foreach my $item (@item_results) {
 

Index: label-manager.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-manager.pl,v
retrieving revision 1.1.2.1.2.2
retrieving revision 1.1.2.1.2.3
diff -u -b -r1.1.2.1.2.2 -r1.1.2.1.2.3
--- label-manager.pl    2 Oct 2006 22:01:39 -0000       1.1.2.1.2.2
+++ label-manager.pl    6 Oct 2006 01:58:47 -0000       1.1.2.1.2.3
@@ -47,7 +47,7 @@
        SaveConf(
         $barcodetype, $title,        $isbn,     $itemtype,
         $bcn,         $dcn,          $classif,  $subclass,
-               $itemcallnumber,    $author, $tmpl_id ,$printingtype,
+        $itemcallnumber, $author, $tmpl_id, $printingtype,
                $guidebox, $startlabel
     );
 
@@ -110,13 +110,13 @@
 # this script can be run from the side nav, and is not passed a value for 
$startrow
 # so lets get it from the DB
 
-    my $dbh    = C4::Context->dbh;
-    my $query2 = "SELECT * FROM labels_conf LIMIT 1";
-    my $sth    = $dbh->prepare($query2);
-    $sth->execute();
+my $dbh    = C4::Context->dbh;
+my $query2 = "SELECT * FROM labels_conf LIMIT 1";
+my $sth    = $dbh->prepare($query2);
+$sth->execute();
 
-    my $data = $sth->fetchrow_hashref;
-    $sth->finish;
+my $data = $sth->fetchrow_hashref;
+$sth->finish;
 
 #calc-ing number of sheets
 #my $number_of_results = scalar @resultsloop;
@@ -129,6 +129,7 @@
 
 $template->param(
     resultsloop      => address@hidden,
+
   #  startrow         => $startrow,
   #  sheets           => $sheets_needed,
   #  labels_remaining => $labels_remaining,

Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.1.2.2.2.3
retrieving revision 1.1.2.2.2.4
diff -u -b -r1.1.2.2.2.3 -r1.1.2.2.2.4
--- label-print-pdf.pl  6 Oct 2006 01:50:18 -0000       1.1.2.2.2.3
+++ label-print-pdf.pl  6 Oct 2006 01:58:47 -0000       1.1.2.2.2.4
@@ -161,7 +161,8 @@
             drawbox( $x_pos, $y_pos, $label_width, $label_height );
         }
 
-        DrawBarcode( $x_pos, $y_pos,  $label_height, $label_width, 
$item->{'barcode'}, $barcodetype );
+        DrawBarcode( $x_pos, $y_pos, $label_height, $label_width,
+            $item->{'barcode'}, $barcodetype );
         CalcNextLabelPos();
     }
 
@@ -172,7 +173,8 @@
 
 sub CalcNextLabelPos {
     if ( $colcount lt $label_cols ) {
-#        warn "new col";
+
+        #        warn "new col";
         $x_pos = ( $x_pos + $label_width + $colspace );
         $colcount++;
     }
@@ -180,13 +182,15 @@
     else {
         $x_pos = $left_margin;
         if ( $rowcount eq $label_rows ) {
-#            warn "new page";
+
+            #            warn "new page";
             prPage();
             $y_pos    = ( $page_height - $top_margin - $label_height );
             $rowcount = 1;
         }
         else {
-#            warn "new row";
+
+            #            warn "new row";
             $y_pos = ( $y_pos - $rowspace - $label_height );
             $rowcount++;
         }

Index: label-print.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print.pl,v
retrieving revision 1.1.2.1.2.1
retrieving revision 1.1.2.1.2.2
diff -u -b -r1.1.2.1.2.1 -r1.1.2.1.2.2
--- label-print.pl      27 Jul 2006 18:13:03 -0000      1.1.2.1.2.1
+++ label-print.pl      6 Oct 2006 01:58:47 -0000       1.1.2.1.2.2
@@ -68,45 +68,37 @@
 
 #warn Dumper @resultsloop;
 
-
-
-
 #------------------------------------------------------
 
 #lets write barcode files to tmp dir for every item in @resultsloop
 
-
-
 binmode(FILE);
-foreach my $item (@resultsloop){
+foreach my $item (@resultsloop) {
 
+    my $random = int( rand(100000000000) ) + 999999999999;
 
-my $random = int( rand(100000000000)) + 999999999999;
-#warn  "$random\n";
+    #warn  "$random\n";
 
        $item->{'barcode'} = $random;
 
-#      my $itembarcode = $item->{'barcode'};
-#      warn $item->{'barcode'};
-
+    #  my $itembarcode = $item->{'barcode'};
+    #  warn $item->{'barcode'};
 
        my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
+
        #warn $filename;
-       open(FILE, ">$filename"); 
+    open( FILE, ">$filename" );
 
-       print FILE GD::Barcode->new('EAN13',  $item->{'barcode'})->plot->png;
-#      warn $GD::Barcode::errStr;
+    print FILE GD::Barcode->new( 'EAN13', $item->{'barcode'} )->plot->png;
+
+    #  warn $GD::Barcode::errStr;
 
        close(FILE);
 
-#warn Dumper  $item->{'barcode'};
+    #warn Dumper  $item->{'barcode'};
 
 }
 
-
-
-
-
 # lets pass the config setting
 
 $template->param(
@@ -133,4 +125,3 @@
 );
 output_html_with_http_headers $query, $cookie, $template->output;
 
-

Index: label-save-template.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/Attic/label-save-template.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-save-template.pl      2 Oct 2006 22:01:39 -0000       1.1.2.1
+++ label-save-template.pl      6 Oct 2006 01:58:47 -0000       1.1.2.2
@@ -33,7 +33,7 @@
 my $active       = $query->param('active');
 
 warn "ACTIVE = $active $fontsize";
-$active = 1 if ($active == 'on');
+$active = 1 if ( $active == 'on' );
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {

Index: label-select-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/Attic/label-select-pdf.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-select-pdf.pl 2 Oct 2006 22:01:39 -0000       1.1.2.1
+++ label-select-pdf.pl 6 Oct 2006 01:58:47 -0000       1.1.2.2
@@ -14,7 +14,6 @@
 
 use Data::Dumper;
 
-
 # get the printing settings
 my $conf_data   = get_label_options();
 my $cgi         = new CGI;
@@ -22,13 +21,12 @@
 my $papertype  = $conf_data->{'papertype'};
 warn  $papertype;
 
-
-if ($papertype eq "Gaylord8511") {
+if ( $papertype eq "Gaylord8511" ) {
        warn "GAY";
-       print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-pdf.pl")
+    print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-pdf.pl");
 }
-elsif ($papertype eq "OPUS-Dot Matrix") {
+elsif ( $papertype eq "OPUS-Dot Matrix" ) {
        warn "OPUS labes";
-       print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-opus-pdf.pl")
+    print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-opus-pdf.pl");
 }
 

Index: label-templates.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/Attic/label-templates.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-templates.pl  2 Oct 2006 22:01:39 -0000       1.1.2.1
+++ label-templates.pl  6 Oct 2006 01:58:47 -0000       1.1.2.2
@@ -17,11 +17,10 @@
 my $op             = $query->param('op');
 my $tmpl_code             = $query->param('tmpl_code');
 
-if (!$op) {
+if ( !$op ) {
        $op = 'display';
 }
 
-
 my $width      = $query->param('width');
 my $height     = $query->param('height');
 my $topmargin  = $query->param('topmargin');
@@ -44,22 +43,19 @@
 
 my @resultsloop;
 
-
-
 if ( $op eq 'display' ) {
-    @resultsloop=GetAllLabelTemplates();
+    @resultsloop = GetAllLabelTemplates();
 }
 
 elsif ( $op eq 'delete' ) {
        DeleteTemplate($tmpl_code);
-       @resultsloop=GetAllLabelTemplates();
+    @resultsloop = GetAllLabelTemplates();
 }
 
-
 elsif ( $op eq 'save' ) {
-warn "SSSSSSSSSSSSSSSSSSSSSSSSSAVING!!!!!!!!!!!!!!!!!!";
+    warn "SSSSSSSSSSSSSSSSSSSSSSSSSAVING!!!!!!!!!!!!!!!!!!";
     SaveTemplate($tmpl_code);
-       @resultsloop=GetAllLabelTemplates();
+    @resultsloop = GetAllLabelTemplates();
 }
 
 $template->param(

Index: pdfViewer.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/pdfViewer.pl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.1.2.1
diff -u -b -r1.2.2.1 -r1.2.2.1.2.1
--- pdfViewer.pl        5 Sep 2005 22:18:09 -0000       1.2.2.1
+++ pdfViewer.pl        6 Oct 2006 01:58:47 -0000       1.2.2.1.2.1
@@ -31,8 +31,8 @@
 my $filename = "barcodes.pdf";
 my $tmpFileName = $cgi->param('tmpFileName');
 print "Content-Disposition: attachment; filename = $filename\n\n";
-print $cgi->header(-type => 'application/pdf'),
-      $cgi->start_html(-title=>"Codify to PDF");
+print $cgi->header( -type => 'application/pdf' ),
+  $cgi->start_html( -title => "Codify to PDF" );
 open fh, "<$tmpFileName";
 while (<fh>) {
  print;

Index: printerConfig.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/printerConfig.pl,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.3.2.1
diff -u -b -r1.2.2.3 -r1.2.2.3.2.1
--- printerConfig.pl    5 Feb 2006 21:59:21 -0000       1.2.2.3
+++ printerConfig.pl    6 Oct 2006 01:58:47 -0000       1.2.2.3.2.1
@@ -39,9 +39,10 @@
        my $type = shift @_;
        my $templatesSet = C4::Context->preference('template');
        my $lang = C4::Context->preference('opaclanguages');
-       if ($type eq "intranet") {
+    if ( $type eq "intranet" ) {
                return 
"$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
-       } else {
+    }
+    else {
                return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
        }
 }
@@ -64,12 +65,12 @@
 # Save settings to a configuration file.
 sub saveConfToFile {
        my $fileName = shift @_;
-       my %keyValues = %{shift @_};
+    my %keyValues = %{ shift @_ };
        my $i;
        open FILE, ">$fileName";                        
        my $i;
-       foreach $i (keys(%keyValues)) {
-    print FILE $i." = ".$keyValues{$i}."\n";
+    foreach $i ( keys(%keyValues) ) {
+        print FILE $i . " = " . $keyValues{$i} . "\n";
        }
        close FILE;
 }
@@ -77,44 +78,52 @@
 # Creates a CGI object and take his parameters
 my $input = new CGI;
 
-if ($input->param('saveSettings')) {
-       my $labelConf = 
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
-       my %newConfiguration = (pageType => $input->param('pageType'),  
+if ( $input->param('saveSettings') ) {
+    my $labelConf =
+      &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
+    my %newConfiguration = (
+        pageType     => $input->param('pageType'),
                                                        columns => 
$input->param('columns'),            
                                                        rows => 
$input->param('rows'),  
                                                        systemDpi => 
$input->param('systemDpi'),        
                                                        labelWidth => 
$input->param('labelWidth'),      
                                                        labelHeigth => 
$input->param('labelHeigth'),    
                                                        marginBottom => 
$input->param('marginBottom'),  
-                                                       marginLeft => 
$input->param('marginLeft'));     
-       saveConfToFile($labelConf, \%newConfiguration);
-       print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl')
+        marginLeft   => $input->param('marginLeft')
+    );
+    saveConfToFile( $labelConf, \%newConfiguration );
+    print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl');
 }
 
 # Get the template to use
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "barcodes/printerConfig.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "barcodes/printerConfig.tmpl",
                                         type => "intranet",
                                         query => $input,
                                         authnotrequired => 0,
-                                        flagsrequired => {parameters => 1},
+        flagsrequired   => { parameters => 1 },
                                                 debug => 1,
-                                      });
+    }
+);
 
-my $filenameConf = 
&getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+  &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
 my %labelConfig = &loadConfFromFile($filenameConf);
 
-$template->param(COLUMNS => $labelConfig{'columns'});
-$template->param(ROWS => $labelConfig{'rows'});
-$template->param(SYSTEM_DPI => $labelConfig{'systemDpi'});
-$template->param(LABEL_WIDTH => $labelConfig{'labelWidth'});
-$template->param(LABEL_HEIGTH => $labelConfig{'labelHeigth'});
-$template->param(MARGIN_TOP => $labelConfig{'marginBottom'});
-$template->param(MARGIN_LEFT => $labelConfig{'marginLeft'});
-$template->param(SCRIPT_NAME => '/cgi-bin/koha/barcodes/printerConfig.pl');
-$template->param("$labelConfig{'pageType'}" => 1);
-$template->param(intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
+$template->param( COLUMNS      => $labelConfig{'columns'} );
+$template->param( ROWS         => $labelConfig{'rows'} );
+$template->param( SYSTEM_DPI   => $labelConfig{'systemDpi'} );
+$template->param( LABEL_WIDTH  => $labelConfig{'labelWidth'} );
+$template->param( LABEL_HEIGTH => $labelConfig{'labelHeigth'} );
+$template->param( MARGIN_TOP   => $labelConfig{'marginBottom'} );
+$template->param( MARGIN_LEFT  => $labelConfig{'marginLeft'} );
+$template->param( SCRIPT_NAME  => '/cgi-bin/koha/barcodes/printerConfig.pl' );
+$template->param( "$labelConfig{'pageType'}" => 1 );
+$template->param(
+    intranetcolorstylesheet =>
+      C4::Context->preference("intranetcolorstylesheet"),
                intranetstylesheet => 
C4::Context->preference("intranetstylesheet"),
                IntranetNav => C4::Context->preference("IntranetNav"),
-               );
+);
 output_html_with_http_headers $input, $cookie, $template->output;




reply via email to

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