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

Antoine Farnault antoine at koha-fr.org
Mon Nov 20 16:20:43 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/11/20 15:20:42

Modified files:
	barcodes       : barcodes.pl barcodesGenerator.pl label-home.pl 
	                 label-item-search.pl label-manager.pl 
	                 label-print-opus-pdf.pl label-print-pdf.pl 
	                 label-print.pl pdfViewer.pl printerConfig.pl 
	                 test.textblock.pl 

Log message:
	synch with dev_week.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/barcodes.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.5&r2=1.5.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/barcodesGenerator.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.5.2.1&r2=1.5.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-home.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.3.2.1&r2=1.3.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-item-search.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.2&r2=1.4.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.1&r2=1.4.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-opus-pdf.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.2.2.1&r2=1.2.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.14.2.1&r2=1.14.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.1&r2=1.4.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/pdfViewer.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.3&r2=1.3.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/printerConfig.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.3.2.1&r2=1.3.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/test.textblock.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1&r2=1.1.4.1

Patches:
Index: barcodes.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/barcodes.pl,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -b -r1.5 -r1.5.2.1
--- barcodes.pl	4 Jul 2006 14:36:51 -0000	1.5
+++ barcodes.pl	20 Nov 2006 15:20:41 -0000	1.5.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 => \@listValues,
 			                        -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 => \@listValues,
 			                            -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 => \@labelTable);
-$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   => \@labelTable );
+$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.5.2.1
retrieving revision 1.5.2.2
diff -u -b -r1.5.2.1 -r1.5.2.2
--- barcodesGenerator.pl	16 Nov 2006 10:51:52 -0000	1.5.2.1
+++ barcodesGenerator.pl	20 Nov 2006 15:20:41 -0000	1.5.2.2
@@ -28,22 +28,24 @@
 use C4::Context;
 use C4::Output;
 use HTML::Template;
+
+#FIXME : module deprecated ?
 use PDF::API2;
 use PDF::API2::Page;
 use PDF::API2::Util;
 use C4::Barcodes::PrinterConfig;
 use Time::localtime; 
 
-
 # This function returns the path to deal with the correct files, considering
 # templates set and language.
 sub getPath {
 	my $type = shift @_;
 	my $templatesSet = C4::Context->preference('template');
 	my $lang = C4::Context->preference('opaclanguages');
-	if ($type eq "intranet") {
+    if ( $type eq "intranet" ) {
 		return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
-	} else {
+    }
+    else {
 		return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
 	}
 }
@@ -66,18 +68,18 @@
 # Save settings to a configuration file. It delete previous configuration settings.
 sub saveConfToFile {
 	my $fileName = shift @_;
-	my %keyValues = %{shift @_};
+    my %keyValues = %{ shift @_ };
 	my $i;
 	open FILE, ">$fileName";			
-	my $i;
-	foreach $i (keys(%keyValues)) {
-    print FILE $i." = ".$keyValues{$i}."\n";
+    foreach $i ( keys(%keyValues) ) {
+        print FILE $i . " = " . $keyValues{$i} . "\n";
 	}
 	close FILE;
 }
 
 # Load the config file.
-my $filenameConf = &getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
+my $filenameConf =
+  &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
 my %labelConfig = &loadConfFromFile($filenameConf);
 
 # Creates a CGI object and take its parameters
@@ -99,18 +101,20 @@
     my $sum = 0;
 	  my $odd_parity = 1;
     my $i;
-    for ($i = length($code) - 1; $i >= 0; $i--){
-	   if ( $odd_parity ) {
-		  $sum = $sum + ( 3 * substr($code, $i, 1) );
-     } else {
-			$sum = $sum + substr($code, $i, 1); }
+        for ( $i = length($code) - 1 ; $i >= 0 ; $i-- ) {
+            if ($odd_parity) {
+                $sum = $sum + ( 3 * substr( $code, $i, 1 ) );
+            }
+            else {
+                $sum = $sum + substr( $code, $i, 1 );
+            }
 		  $odd_parity = !$odd_parity;
 	   }
-    my $check_digit = 10 - ($sum%10);
-	if ($check_digit==10) {
-		$check_digit=0;
+        my $check_digit = 10 - ( $sum % 10 );
+        if ( $check_digit == 10 ) {
+            $check_digit = 0;
 	}
-	  return $code.$check_digit;
+        return $code . $check_digit;
   }
 
   my $currentCode = shift @_;
@@ -120,61 +124,92 @@
 
 # Assigns a temporary name to the PDF file
 sub assingFilename {
-	my ($from, $to) = @_;
+    my ( $from, $to ) = @_;
 	my $ip = $cgi->remote_addr();
-	my $random = int(rand(1000000));
+    my $random  = int( rand(1000000) );
     my $timeObj = localtime();
-	my ($day, $month, $year, $hour, $min, $sec) = ($timeObj->mday,
+    my ( $day, $month, $year, $hour, $min, $sec ) = (
+        $timeObj->mday,
 												   $timeObj->mon + 1,
 												   $timeObj->year + 1900,
-  												   $timeObj->hour,
-												   $timeObj->min,
-												   $timeObj->sec);
-	my $tmpFileName = $random.'-'.$ip.'-(From '.$from.' to '.$to.')-['.$day.'.'.$month.'.'.$year.']-['.$hour.':'.$min.':'.$sec.'].pdf';
+        $timeObj->hour, $timeObj->min, $timeObj->sec
+    );
+    my $tmpFileName =
+        $random . '-' . $ip
+      . '-(From '
+      . $from . ' to '
+      . $to . ')-['
+      . $day . '.'
+      . $month . '.'
+      . $year . ']-['
+      . $hour . ':'
+      . $min . ':'
+      . $sec . '].pdf';
 	return $tmpFileName;
 }
+
 sub getCallnum {
-#grabs a callnumber for the specified barcode
-my ($barcode) = @_;
-my $query = "select dewey from items,biblioitems where items.biblionumber=biblioitems.biblionumber and items.barcode=?";
-my $dbh = C4::Context->dbh;
-my $sth = $dbh->prepare($query);
-$sth->execute($barcode);
-my ($callnum) = $sth->fetchrow_array();
-warn "Call number is:".$barcode;
-return $callnum;
+
+    #grabs a callnumber for the specified barcode
+    my ($barcode) = @_;
+    my $query =
+"select dewey from items,biblioitems where items.biblionumber=biblioitems.biblionumber and items.barcode=?";
+    my $dbh = C4::Context->dbh;
+    my $sth = $dbh->prepare($query);
+    $sth->execute($barcode);
+    my ($callnum) = $sth->fetchrow_array();
+    warn "Call number is:" . $barcode;
+    return $callnum;
 }
+
 # Takes inventary codes from database and if they are between
 # the interval specify by parameters, it generates the correspond barcodes
 sub barcodesGenerator {
-	my ($from, $to, $rangeType, $individualCodes,$text_under_label) = @_;
+    my ( $from, $to, $rangeType, $individualCodes, $text_under_label ) = @_;
+
 	# Returns a database handler
 	my $dbh = C4::Context->dbh;
+
 	# Create the query to database
 	# Assigns a temporary filename for the pdf file
-	my $tmpFileName = &assingFilename($from, $to);
+    my $tmpFileName = &assingFilename( $from, $to );
+
 	# warn "range type: ".$rangeType;
-	if ($rangeType eq 'continuous') {
+    if ( $rangeType eq 'continuous' ) {
+
 		# Set the temp directory for pdf´s files
-		if (!defined($ENV{'TEMP'})) {
+        if ( !defined( $ENV{'TEMP'} ) ) {
 			$ENV{'TEMP'} = '/tmp/';
 		}	
-		$tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+        $tmpFileName = $ENV{'TEMP'} . $tmpFileName;
+
 		# Creates a PDF object
-		my $pdf = PDF::API2->new(-file => $tmpFileName);
+        my $pdf = PDF::API2->new( -file => $tmpFileName );
+
 		# Set the positions where barcodes are going to be placed
-		C4::Barcodes::PrinterConfig::setPositionsForX($labelConfig{'marginLeft'}, $labelConfig{'labelWidth'}, $labelConfig{'columns'}, $labelConfig{'pageType'});
-		C4::Barcodes::PrinterConfig::setPositionsForY($labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'}, $labelConfig{'rows'}, $labelConfig{'pageType'});
+        C4::Barcodes::PrinterConfig::setPositionsForX(
+            $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'},
+            $labelConfig{'columns'},    $labelConfig{'pageType'}
+        );
+        C4::Barcodes::PrinterConfig::setPositionsForY(
+            $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'},
+            $labelConfig{'rows'},         $labelConfig{'pageType'}
+        );
+
 		# Creates a font object
 		my $tr = $pdf->corefont('Helvetica-Bold');
+
 		# Barcode position
-		my ($page, $gfx, $text);
-		for (my $code=$from; $code<=$to; $code++) {
+        my ( $page, $gfx, $text );
+        for ( my $code = $from ; $code <= $to ; $code++ ) {
+
 			# Generetase checksum
 			my $codeC = &checksum($code);
+
 			# Generate the corresponde barcode to $code
 			# warn "Code is :-->".$codeC."<--";
-			my $barcode = $pdf->barcode(-font => $tr,	# The font object to use
+            my $barcode = $pdf->barcode(
+                -font => $tr,         # The font object to use
 										-type => 'ean128',	# Standard of codification
 										-code => $codeC, # Text to codify
 										-extn	=> '012345',	# Barcode extension (if it is aplicable)
@@ -187,69 +222,97 @@
 										-text => ''
 										);
 			
-			(my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label) = C4::Barcodes::PrinterConfig::getLabelPosition(
-																						$label, 
-																						$pdf, 
-																						$page,
-																						$gfx,
-																						$text,
-																						$tr,
-																						$pageType);	
+            ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) =
+              C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf,
+                $page, $gfx, $text, $tr, $pageType );
+
 			# Assigns a barcodes to $gfx
-			$gfx->barcode($barcode, $x, $y , (72/$labelConfig{'systemDpi'}));
+            $gfx->barcode( $barcode, $x, $y,
+                ( 72 / $labelConfig{'systemDpi'} ) );
+
 			# Assigns the additional information to the barcode (Legend)
-			$text->translate($x - 48, $y - 22);
-			warn "code is ".$codeC;
+            $text->translate( $x - 48, $y - 22 );
+
+            #warn "code is ".$codeC;
 			if ($text_under_label) {
 				$text->text($text_under_label);
-			} else {
-			$text->text(getCallnum($code));
+            }
+            else {
+                $text->text( getCallnum($code) );
 			}
 		}
+
 		# Writes the objects added in $gfx to $page
-		$pdf->finishobjects($page,$gfx, $text);
+        $pdf->finishobjects( $page, $gfx, $text );
+
 		# Save changes to the PDF
 		$pdf->saveas;
+
 		# Close the conection with the PDF file
 		$pdf->end;
+
 		# Show the PDF file
-		print $cgi->redirect("/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
-	} else {
+        print $cgi->redirect(
+            "/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
+    }
+    else {
 		my $rangeCondition;
-		if ($individualCodes ne "") {
+        if ( $individualCodes ne "" ) {
 			$rangeCondition = "AND (I.barcode IN " . $individualCodes . ")";
-		} else {
-			$rangeCondition =  "AND (I.barcode >= " . $from . " AND I.barcode <="  . $to . " )";
 		}
-		warn "above the query";	
-		my $query = "SELECT CONCAT('$numbersystem',REPEAT('0',((12 - LENGTH('$numbersystem')) - LENGTH(I.barcode))), I.barcode) AS Codigo, I.dewey as dewey B.title, B.author FROM biblio B, items I WHERE (I.biblionumber = B.biblioNumber ) " .$rangeCondition. " AND (I.barcode <> 'FALTA') ORDER BY Codigo";
+        else {
+            $rangeCondition =
+              "AND (I.barcode >= " . $from . " AND I.barcode <=" . $to . " )";
+        }
+
+        my $query =
+"SELECT CONCAT('$numbersystem',REPEAT('0',((12 - LENGTH('$numbersystem')) - LENGTH(I.barcode))), I.barcode) AS Codigo, B.title, B.author FROM biblio B, items I WHERE (I.biblionumber = B.biblioNumber ) "
+          . $rangeCondition
+          . " AND (I.barcode <> 'FALTA') ORDER BY Codigo";
 		
 		# Prepare the query
 		my $sth = $dbh->prepare($query);
+
 		# Executes the query
 		$sth->execute;
-		if ($sth->rows) { # There are inventary codes
+        if ( $sth->rows ) {    # There are inventary codes
 			# Set the temp directory for pdf´s files
-			if (!defined($ENV{'TEMP'})) {
+            if ( !defined( $ENV{'TEMP'} ) ) {
 				$ENV{'TEMP'} = '/tmp/';
 			}	
+
 			# Assigns a temporary filename for the pdf file
-			my $tmpFileName = &assingFilename($from, $to);
-			$tmpFileName = $ENV{'TEMP'}.$tmpFileName;
+            my $tmpFileName = &assingFilename( $from, $to );
+            $tmpFileName = $ENV{'TEMP'} . $tmpFileName;
+
 			# Creates a PDF object
-			my $pdf = PDF::API2->new(-file => $tmpFileName);
+            my $pdf = PDF::API2->new( -file => $tmpFileName );
+
 			# Set the positions where barcodes are going to be placed
-			C4::Barcodes::PrinterConfig::setPositionsForX($labelConfig{'marginLeft'}, $labelConfig{'labelWidth'}, $labelConfig{'columns'}, $labelConfig{'pageType'});
-			C4::Barcodes::PrinterConfig::setPositionsForY($labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'}, $labelConfig{'rows'}, $labelConfig{'pageType'});
+            C4::Barcodes::PrinterConfig::setPositionsForX(
+                $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'},
+                $labelConfig{'columns'},    $labelConfig{'pageType'}
+            );
+            C4::Barcodes::PrinterConfig::setPositionsForY(
+                $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'},
+                $labelConfig{'rows'},         $labelConfig{'pageType'}
+            );
+
 			# Creates a font object
 			my $tr = $pdf->corefont('Helvetica-Bold');
+
 			# Barcode position
-			my ($page, $gfx, $text);
-			while (my ($code,$dewey,$title,$author) = $sth->fetchrow_array) {
+            my ( $page, $gfx, $text );
+            while ( my ( $code, $dewey, $title, $author ) =
+                $sth->fetchrow_array )
+            {
+
 				# Generetase checksum
 				$code = &checksum($code);
+
 				# Generate the corresponde barcode to $code
-				my $barcode = $pdf->barcode(-font => $tr,	# The font object to use
+                my $barcode = $pdf->barcode(
+                    -font => $tr,       # The font object to use
 											-type => 'ean13',	# Standard of codification
 											-code => $code, # Text to codify
 											-extn	=> '012345',	# Barcode extension (if it is aplicable)
@@ -262,36 +325,43 @@
 											-text => ''
 											);
 				
-				(my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label) = C4::Barcodes::PrinterConfig::getLabelPosition(
-																							$label, 
-																							$pdf, 
-																							$page,
-																							$gfx,
-																							$text,
-																							$tr,
-																							$pageType);	
+                ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) =
+                  C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf,
+                    $page, $gfx, $text, $tr, $pageType );
+
 				# Assigns a barcodes to $gfx
-				$gfx->barcode($barcode, $x, $y , (72/$labelConfig{'systemDpi'}));
+                $gfx->barcode( $barcode, $x, $y,
+                    ( 72 / $labelConfig{'systemDpi'} ) );
+
 				# Assigns the additional information to the barcode (Legend)
-				$text->translate($x - 48, $y - 22);
+                $text->translate( $x - 48, $y - 22 );
 				if ($text_under_label) {
 					$text->text($text_under_label);
-				} else {
-					warn "here a dewey:".$dewey;
-					$text->text(substr $dewey, 0, 30);
-					$text->translate($x - 48, $y - 29);
+                }
+                else {
+                    $text->text( substr $title, 0, 30 );
+                    $text->translate( $x - 48, $y - 29 );
+
 					#$text->text(substr $author, 0, 30);
+                    $text->text( substr $author, 0, 30 );
 				}
 			}
+
 			# Writes the objects added in $gfx to $page
-			$pdf->finishobjects($page,$gfx, $text);
+            $pdf->finishobjects( $page, $gfx, $text );
+
 			# Save changes to the PDF
 			$pdf->saveas;
+
 			# Close the conection with the PDF file
 			$pdf->end;
+
 			# Show the PDF file
-			print $cgi->redirect("/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
-		} else {
+            print $cgi->redirect(
+                "/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName");
+        }
+        else {
+
 			# Rollback and shows the error legend
 			print $cgi->redirect("/cgi-bin/koha/barcodes/barcodes.pl?error=1");
 		}
@@ -299,4 +369,5 @@
 	}
 }
 
-barcodesGenerator($from, $to, $rangeType, $individualCodes,$text_under_label);
+barcodesGenerator( $from, $to, $rangeType, $individualCodes,
+    $text_under_label );

Index: label-home.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-home.pl,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -b -r1.3.2.1 -r1.3.2.2
--- label-home.pl	6 Oct 2006 14:04:10 -0000	1.3.2.1
+++ label-home.pl	20 Nov 2006 15:20:41 -0000	1.3.2.2
@@ -19,12 +19,11 @@
 use CGI;
 use C4::Auth;
 use C4::Output;
+use C4::Labels;
 use C4::Interface::CGI::Output;
 use C4::Context;
 use HTML::Template;
 
-#use Data::Dumper;
-
 my $query = new CGI;
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -37,23 +36,25 @@
     }
 );
 
-my $dbh    = C4::Context->dbh;
-my $query2 = "SELECT * FROM labels_conf LIMIT 1";
-my $sth    = $dbh->prepare($query2);
-$sth->execute();
+my $data = get_label_options();
 
-my $data = $sth->fetchrow_hashref;
-$sth->finish;
+my $active_template = GetActiveLabelTemplate();
+my @label_templates = GetAllLabelTemplates();
 
 $template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
 
 $data->{'printingtype'} = 'both' if ( !$data->{'printingtype'} );
 $template->param( "printingtype_$data->{'printingtype'}" => 1 );
+$template->param( "papertype_$data->{'papertype'}"       => 1 );
 
 $template->param( "$data->{'barcodetype'}_checked"              => 1 );
+
 $template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 );
 $template->param(
     itemtype    => $data->{'itemtype'},
+    active_template => $data->{'active_template'},
+    label_templates => \@label_templates,
+
     papertype   => $data->{'papertype'},
     author      => $data->{'author'},
     barcode     => $data->{'barcode'},
@@ -64,6 +65,10 @@
     dewey       => $data->{'dewey'},
     class       => $data->{'class'},
     startrow    => $data->{'startrow'},
+    subclass       => $data->{'subclass'},
+    itemcallnumber => $data->{'itemcallnumber'},
+    startlabel     => $data->{'startlabel'},
+    fontsize       => $active_template->{'fontsize'},
 
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),

Index: label-item-search.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-item-search.pl,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -u -b -r1.4.2.2 -r1.4.2.3
--- label-item-search.pl	17 Nov 2006 13:18:58 -0000	1.4.2.2
+++ label-item-search.pl	20 Nov 2006 15:20:41 -0000	1.4.2.3
@@ -31,7 +31,6 @@
 use C4::Interface::CGI::Output;
 use C4::Biblio;
 use C4::Acquisition;
-#use C4::SearchMarc;
 use C4::Koha;    # XXX subfield_is_koha_internal_p
 
 # Creates a scrolling list with the associated default value.
@@ -151,7 +150,8 @@
             #warn $i;
             #warn Dumper $results->[$i]{'biblionumber'};
         my $type         = 'intra';
-        my @item_results = &GetItemsInfo($results->[$i]{'biblionumber'}, $type );
+        my @item_results =
+          &GetItemsInfo( $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.4.2.1
retrieving revision 1.4.2.2
diff -u -b -r1.4.2.1 -r1.4.2.2
--- label-manager.pl	6 Oct 2006 14:04:10 -0000	1.4.2.1
+++ label-manager.pl	20 Nov 2006 15:20:41 -0000	1.4.2.2
@@ -18,6 +18,7 @@
 use strict;
 use CGI;
 use C4::Auth;
+use C4::Labels;
 use C4::Output;
 use C4::Interface::CGI::Output;
 use HTML::Template;
@@ -33,15 +34,18 @@
 my $bcn          = $query->param('bcn');
 my $dcn          = $query->param('dcn');
 my $classif      = $query->param('classif');
+my $itemcallnumber = $query->param('itemcallnumber');
+my $subclass       = $query->param('subclass');
 my $author       = $query->param('author');
-my $papertype    = $query->param('papertype');
+my $tmpl_id        = $query->param('tmpl_id');
 my $itemnumber   = $query->param('itemnumber');
 my $summary      = $query->param('summary');
-my $startrow     = $query->param('startrow');
+my $startlabel     = $query->param('startlabel');
 my $printingtype = $query->param('printingtype');
 my $guidebox     = $query->param('guidebox');
+my $fontsize       = $query->param('fontsize');
 
-warn $printingtype;
+#warn "ID =$tmpl_id";
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -55,22 +59,12 @@
 );
 
 if ( $op eq 'save_conf' ) {
-    my $query2 = "DELETE FROM labels_conf";
-    my $sth2   = $dbh->prepare($query2);
-    $sth2->execute();
-    $sth2->finish;
-    my $query2 = "INSERT INTO labels_conf 
-			( barcodetype, title, isbn, itemtype, barcode, 	
-			  dewey, class, author, papertype, printingtype, 
-				guidebox, startrow)
-			   values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
-    my $sth2 = $dbh->prepare($query2);
-    $sth2->execute(
+    SaveConf(
         $barcodetype, $title,        $isbn,     $itemtype,
-        $bcn,         $dcn,          $classif,  $author,
-        $papertype,   $printingtype, $guidebox, $startrow
+        $bcn,            $dcn,    $classif, $subclass,
+        $itemcallnumber, $author, $tmpl_id, $printingtype,
+        $guidebox,       $startlabel
     );
-    $sth2->finish;
 
 }
 elsif ( $op eq 'add' ) {
@@ -130,33 +124,29 @@
 
 # this script can be run from the side nav, and is not passed a value for $startrow
 # so lets get it from the DB
-if ( !$startrow ) {
 
-    my $dbh    = C4::Context->dbh;
-    my $query2 = "SELECT * FROM labels_conf LIMIT 1";
-    my $sth    = $dbh->prepare($query2);
-    $sth->execute();
-
-    my $data = $sth->fetchrow_hashref;
-    $startrow = $data->{'startrow'};
-    $sth->finish;
-}
+my $dbh    = C4::Context->dbh;
+my $query2 = "SELECT * FROM labels_conf LIMIT 1";
+my $sth    = $dbh->prepare($query2);
+$sth->execute();
+
+my $data = $sth->fetchrow_hashref;
+$sth->finish;
 
 #calc-ing number of sheets
-my $number_of_results = scalar @resultsloop;
-my $sheets_needed = ( ( --$number_of_results + $startrow ) / 8 );
-$sheets_needed = ceil($sheets_needed);    # rounding up int's
-
-my $tot_labels       = ( $sheets_needed * 8 );
-my $start_results    = ( $number_of_results + $startrow );
-my $labels_remaining = ( $tot_labels - $start_results );
+
+#$sheets_needed = ceil($sheets_needed);    # rounding up int's
+
+#my $tot_labels       = ( $sheets_needed * 8 );
+#my $start_results    = ( $number_of_results + $startrow );
+#my $labels_remaining = ( $tot_labels - $start_results );
 
 $template->param(
     resultsloop      => \@resultsloop,
-    startrow         => $startrow,
-    sheets           => $sheets_needed,
-    labels_remaining => $labels_remaining,
 
+    #  startrow         => $startrow,
+    #  sheets           => $sheets_needed,
+    #  labels_remaining => $labels_remaining,
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),

Index: label-print-opus-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-opus-pdf.pl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -b -r1.2.2.1 -r1.2.2.2
--- label-print-opus-pdf.pl	6 Oct 2006 14:04:10 -0000	1.2.2.1
+++ label-print-opus-pdf.pl	20 Nov 2006 15:20:41 -0000	1.2.2.2
@@ -29,8 +29,6 @@
 use PDF::Create;
 use PDF::Labels;
 use Acme::Comment;
-use Data::Dumper;
-warn "-------";
 
 my $htdocs_path = C4::Context->config('intrahtdocs');
 my $cgi         = new CGI;
@@ -60,7 +58,6 @@
         $result->{'barcode'} );
 
 }
-warn "HERE";
 $pdf->close();
 
 #--------------------------------------------------

Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -b -r1.14.2.1 -r1.14.2.2
--- label-print-pdf.pl	6 Oct 2006 14:04:10 -0000	1.14.2.1
+++ label-print-pdf.pl	20 Nov 2006 15:20:41 -0000	1.14.2.2
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# This file is part of koha
+# 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
@@ -15,291 +15,203 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+# $Id: label-print-pdf.pl,v 1.14.2.2 2006/11/20 15:20:41 toins Exp $
 
-#----------------------------------------------------------------------
-# this script is really divided into 2 differenvt section,
+=head1 label-print-pdf.pl
 
-# the first section creates, and defines the new PDF file the barcodes
-# using PDF::Reuse::Barcode, then saves the file to disk.
+ this script is really divided into 2 differenvt section,
 
-# the second section then opens the pdf file off disk, and places the spline label
-# text in the left-most column of the page. then save the file again.
+ the first section creates, and defines the new PDF file the barcodes
+ using PDF::Reuse::Barcode, then saves the file to disk.
 
-# the reason for this goofyness, it that i couldnt find a single perl package that handled both barcodes and decent text placement.
+ the second section then opens the pdf file off disk, and places the spline label
+ text in the left-most column of the page. then save the file again.
 
-#use lib '/usr/local/hlt/intranet/modules';
-#use C4::Context("/etc/koha-hlt.conf");
+ the reason for this goofyness, it that i couldnt find a single perl package that handled both barcodes and decent text placement.
 
-#use strict;
+=cut
+
+use strict;
 use CGI;
 use C4::Labels;
 use C4::Auth;
-use C4::Serials;
 use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Context;
 use HTML::Template;
 use PDF::Reuse;
 use PDF::Reuse::Barcode;
-use PDF::Report;
-use Data::Dumper;
+use POSIX;
+use C4::Labels;
+use Acme::Comment;
 
-#use Acme::Comment;
-#use Data::Dumper;
+use Data::Dumper;
 
 my $htdocs_path = C4::Context->config('intrahtdocs');
 my $cgi         = new CGI;
-
 my $spine_text = "";
 
 # get the printing settings
-
+my $template     = GetActiveLabelTemplate();
 my $conf_data   = get_label_options();
 my @resultsloop = get_label_items();
-
-warn Dumper $conf_data;
-
-
 my $barcodetype  = $conf_data->{'barcodetype'};
 my $printingtype = $conf_data->{'printingtype'};
 my $guidebox  = $conf_data->{'guidebox'};
-my $startrow     = $conf_data->{'startrow'};
-
-if (!$printingtype) {
-	$printingtype = 'both';
-}
+my $start_label  = $conf_data->{'startlabel'};
+my $fontsize     = $template->{'fontsize'};
+my $units        = $template->{'units'};
+
+warn "UNITS $units";
+warn "fontsize = $fontsize";
+warn Dumper $template;
+
+my $unitvalue = GetUnitsValue($units);
+warn $unitvalue;
+warn $units;
+
+my $tmpl_code = $template->{'tmpl_code'};
+my $tmpl_desc = $template->{'tmpl_desc'};
+
+my $page_height  = ( $template->{'page_height'} * $unitvalue );
+my $page_width   = ( $template->{'page_width'} * $unitvalue );
+my $label_height = ( $template->{'label_height'} * $unitvalue );
+my $label_width  = ( $template->{'label_width'} * $unitvalue );
+my $spine_width  = ( $template->{'label_width'} * $unitvalue );
+my $circ_width   = ( $template->{'label_width'} * $unitvalue );
+my $top_margin   = ( $template->{'topmargin'} * $unitvalue );
+my $left_margin  = ( $template->{'leftmargin'} * $unitvalue );
+my $colspace     = ( $template->{'colgap'} * $unitvalue );
+my $rowspace     = ( $template->{'rowgap'} * $unitvalue );
 
-warn $printingtype;
-warn $guidebox;
+my $label_cols = $template->{'cols'};
+my $label_rows = $template->{'rows'};
 
+my $text_wrap_cols = GetTextWrapCols( $fontsize, $label_width );
 
-#warn Dumper @resultsloop;
+warn $label_cols, $label_rows;
 
-# dimensions of gaylord paper
+# set the paper size
 my $lowerLeftX  = 0;
 my $lowerLeftY  = 0;
-my $upperRightX = 612;
-my $upperRightY = 792;
+my $upperRightX = $page_width;
+my $upperRightY = $page_height;
 
-#----------------------------------
-# setting up the pdf doc
+prInitVars();
+$| = 1;
+print STDOUT "Content-Type: application/pdf \r\n\r\n";
+prFile();
 
-#remove the file before write, for testing
-unlink "$htdocs_path/barcodes/new.pdf";
+prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
 
-prFile("$htdocs_path/barcodes/new.pdf");
-prLogDir("$htdocs_path/barcodes");
+# later feature, change the font-type and size?
+prFont('C');    # Just setting a font
+prFontSize($fontsize);
 
-#prMbox ( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
-prMbox( 0, 0, 612, 792 );
+my $margin           = $top_margin;
+my $left_text_margin = 3;
 
-prFont('Times-Roman');    # Just setting a font
-prFontSize(10);
+my $str;
 
-my $margin = 36;
+#warn "STARTROW = $startrow\n";
 
-my $label_height = 90;
-my $spine_width  = 72;
-my $circ_width   = 207;
-my $colspace     = 27;
-
-my $x_pos_spine = 36;
-my $x_pos_circ1 = 135;
-my $x_pos_circ2 = 369;
+#my $page_break_count = $startrow;
+my $codetype = 'Code39';
 
-my $pageheight = 792;
+#do page border
+#drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
 
-warn "STARTROW = $startrow\n";
+my $item;
+my ( $i, $i2 );    # loop counters
 
-#my $y_pos_initial = ( ( 792 - 36 ) - 90 );
-my $y_pos_initial = ( ( $pageheight - $margin ) - $label_height );
-my $y_pos_initial_startrow =
-  ( ( $pageheight - $margin ) - ( $label_height * $startrow ) );
+# big row loop
 
-my $y_pos = $y_pos_initial_startrow;
+warn " $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY";
+warn "$label_rows, $label_cols\n";
+warn "$label_height, $label_width\n";
+warn "$page_height, $page_width\n";
+
+my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp );
+
+if ( $start_label eq 1 ) {
+    $rowcount = 1;
+    $colcount = 1;
+    $x_pos    = $left_margin;
+    $y_pos    = ( $page_height - $top_margin - $label_height );
+}
 
-warn "Y POS INITAL : $y_pos_initial";
-warn "Y POS : $y_pos";
-warn "Y START ROW = $y_pos_initial_startrow";
+else {
+    $rowcount = ceil( $start_label / $label_cols );
+    $colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) );
 
-my $rowspace         = 36;
-my $page_break_count = $startrow;
-my $codetype         = 'Code39';
+    $x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) +
+      ( $colspace * ( $colcount - 1 ) );
 
-# do border---------------
-my $str = "q\n";    # save the graphic state
-$str .= "4 w\n";                # border color red
-$str .= "0.0 0.0 0.0  RG\n";    # border color red
-$str .= "1 1 1 rg\n";           # fill color blue
-$str .= "0 0 612 792 re\n";     # a rectangle
-$str .= "B\n";                  # fill (and a little more)
-$str .= "Q\n";                  # save the graphic state
+    $y_pos = $page_height - $top_margin - ( $label_height * $rowcount ) -
+      ( $rowspace * ( $rowcount - 1 ) );
 
-# do border---------------
+}
 
-prAdd($str);
-my $item;
+warn "ROW COL $rowcount, $colcount";
 
-# for loop
+#my $barcodetype = 'Code39';
 
-my $i2 = 1;
 foreach $item (@resultsloop) {
-    if ( $i2 == 1  && $guidebox  == 1) {
-        draw_boundaries(
-            $x_pos_spine, $x_pos_circ1,  $x_pos_circ2, $y_pos,
-            $spine_width, $label_height, $circ_width
-        );
-    }
 
-    #warn Dumper $item->{'itemtype'};
-    #warn "COUNT = $cnt1";
+    warn "-----------------";
+    if ($guidebox) {
+        drawbox( $x_pos, $y_pos, $label_width, $label_height );
+    }
 
-    #building up spine text
-    my $line        = 75;
-    my $line_spacer = 16;
+    if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
+        if ($guidebox) {
+            drawbox( $x_pos, $y_pos, $label_width, $label_height );
+        }
 
-    $DB::single = 1;
+        DrawSpineText( $y_pos, $label_height, $fontsize, $x_pos,
+            $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
+        CalcNextLabelPos();
+    }
 
-    warn
-"COUNT=$i2, PBREAKCNT=$page_break_count, X,Y POS x=$x_pos_circ1, y=$y_pos";
  if ( $printingtype eq 'barcode' || $printingtype eq 'both' ) {
-    build_circ_barcode( $x_pos_circ1, $y_pos, $item->{'barcode'},
-        $conf_data->{'barcodetype'}, \$item );
-    build_circ_barcode( $x_pos_circ2, $y_pos, $item->{'barcode'},
-        $conf_data->{'barcodetype'}, \$item );
-}
-# added for xpdf compat. doesnt use type3 fonts., but increases filesize from 20k to 200k
-# i think its embedding extra fonts in the pdf file.
-#	mode => 'graphic',
-
-    $y_pos = ( $y_pos - $label_height );
-
-    # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
-    if ( $page_break_count == 8 ) {
-        prPage();
-
-        #warn "############# PAGEBREAK ###########";
-        $page_break_count = 0;
-        $i2               = 0;
-        $y_pos            = $y_pos_initial;
+        if ($guidebox) {
+            drawbox( $x_pos, $y_pos, $label_width, $label_height );
     }
-    $page_break_count++;
-    $i2++;
-}
-############## end of loop
 
+        DrawBarcode( $x_pos, $y_pos, $label_height, $label_width,
+            $item->{'barcode'}, $barcodetype );
+        CalcNextLabelPos();
+    }
 
+}    # end for item loop
 prEnd();
 
-#----------------------------------------------------------------------------
-# this second section of the script uses a diff perl class than the previous section
-# it opens the 'new.pdf' file that the previous section has just saved
-
-if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
-
-    $file = "$htdocs_path/barcodes/new.pdf";
-
-    my $pdf = new PDF::Report( File => $file );
-
-    # my $pdf = new PDF::Report(PageSize => "letter",
-    #                                  PageOrientation => "Landscape");
-
-    #$pdf->newpage($nopage);
-    my $pagenumber = 1;
-    $pdf->openpage($pagenumber);
-
-    ( $pagewidth, $pageheight ) = $pdf->getPageDimensions();
-
-    #warn "PAGE DIM = $pagewidth, $pageheight";
-    #warn "Y START ROW = $y_pos_initial_startrow";
-    my $y_pos = ( $y_pos_initial_startrow + 90 );
-
-    #my $y_pos = ( $y_pos_initial_startrow  );
-    #warn "Y POS = $y_pos";
-
-    # now needed now we are using centerString().
-    #$pdf->setAlign('left');
-    
-    # SET THE FONT SIZE
-    $pdf->setSize(9);
-
-    my $page_break_count = $startrow;
-
-    #warn "INIT PAGEBREAK COUNT = $page_break_count";
-
-    #warn "#----------------------------------\n";
-    #warn "INIT VPOS = $vPos, hPos = $hPos";
-
-    my $vPosSpacer     = 15;
-    my $start_text_pos = 39;   # ( 36 - 5 = 31 ) 5 is an inside border for text.
-    my $spine_label_text_with = 67;
-
-    foreach $item (@resultsloop) {
-
-        #warn Dumper $item;
-        #warn "START Y_POS=$y_pos";
-        my $firstrow = 0;
-
-        $pdf->setAddTextPos( $start_text_pos, ( $y_pos - 20 ) )
-          ;                    # INIT START POS
-        ( $hPos, $vPos ) = $pdf->getAddTextPos();
+print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
 
-        my $hPosEnd = ( $hPos + $spine_label_text_with );    # 72
-        if ( $conf_data->{'dewey'} && $item->{'dewey'} ) {
-            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'dewey'} );
-            $vPos = $vPos - $vPosSpacer;
-        }
+sub CalcNextLabelPos {
+    if ( $colcount lt $label_cols ) {
 
-        if ( $conf_data->{'isbn'} && $item->{'isbn'} ) {
-            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'isbn'} );
-            $vPos = $vPos - $vPosSpacer;
+        #        warn "new col";
+        $x_pos = ( $x_pos + $label_width + $colspace );
+        $colcount++;
         }
 
-        if ( $conf_data->{'class'} && $item->{'classification'} ) {
-            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos,
-                $item->{'classification'} );
-            $vPos = $vPos - $vPosSpacer;
-        }
+    else {
+        $x_pos = $left_margin;
+        if ( $rowcount eq $label_rows ) {
 
-        if ( $conf_data->{'itemtype'} && $item->{'itemtype'} ) {
-            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'itemtype'} );
-            $vPos = $vPos - $vPosSpacer;
+            #            warn "new page";
+            prPage();
+            $y_pos    = ( $page_height - $top_margin - $label_height );
+            $rowcount = 1;
         }
+        else {
 
-        #$pdf->drawRect(
-        #    $x_pos_spine, $y_pos,
-        #    ( $x_pos_spine + $spine_width ),
-        #    ( $y_pos - $label_height )
-        #);
-
-        $y_pos = ( $y_pos - $label_height );
-
-        #warn "END LOOP Y_POS =$y_pos";
-        #    warn "PAGECOUNT END LOOP=$page_break_count";
-        if ( $page_break_count == 8 ) {
-            $pagenumber++;
-            $pdf->openpage($pagenumber);
-
-            #warn "############# PAGEBREAK ###########";
-            $page_break_count = 0;
-            $i2               = 0;
-            $y_pos            = ( $y_pos_initial + 90 );
+            #            warn "new row";
+            $y_pos = ( $y_pos - $rowspace - $label_height );
+            $rowcount++;
         }
-
-        $page_break_count++;
-        $i2++;
-
-        #warn "#----------------------------------\n";
-
+        $colcount = 1;
     }
-    $DB::single = 1;
-    $pdf->saveAs($file);
 }
 
-#------------------------------------------------
-
-print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");

Index: label-print.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print.pl,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -b -r1.4.2.1 -r1.4.2.2
--- label-print.pl	6 Oct 2006 14:04:10 -0000	1.4.2.1
+++ label-print.pl	20 Nov 2006 15:20:41 -0000	1.4.2.2
@@ -83,52 +83,43 @@
 
 #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(
 
     resultsloop             => \@resultsloop,
 
-
  	  itemtype_opt => $conf_data->{'itemtype'},
           papertype_opt => $conf_data->{'papertype'},
           author_opt => $conf_data->{'author'},
@@ -139,9 +130,8 @@
           isbn_opt => $conf_data->{'isbn'},
           dewey_opt => $conf_data->{'dewey'},
           class_opt => $conf_data->{'class'},
-
-
-
+    subclass_opt       => $conf_data->{'subclass'},
+    itemcallnumber_opt => $conf_data->{'itemcallnumber'},
 
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),
@@ -150,4 +140,3 @@
 );
 output_html_with_http_headers $query, $cookie, $template->output;
 
-

Index: pdfViewer.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/pdfViewer.pl,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -b -r1.3 -r1.3.2.1
--- pdfViewer.pl	5 Sep 2005 22:25:11 -0000	1.3
+++ pdfViewer.pl	20 Nov 2006 15:20:41 -0000	1.3.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.3.2.1
retrieving revision 1.3.2.2
diff -u -b -r1.3.2.1 -r1.3.2.2
--- printerConfig.pl	16 Nov 2006 10:36:27 -0000	1.3.2.1
+++ printerConfig.pl	20 Nov 2006 15:20:41 -0000	1.3.2.2
@@ -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;

Index: test.textblock.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/test.textblock.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -b -r1.1 -r1.1.4.1
--- test.textblock.pl	19 Jul 2006 01:09:42 -0000	1.1
+++ test.textblock.pl	20 Nov 2006 15:20:41 -0000	1.1.4.1
@@ -11,10 +11,10 @@
 my $fnt = $pdf->corefont('Helvetica-Bold');
 my $page = $pdf->page;    # returns the last page
 my $txt  = $page->text;
-$txt->{' font'}=$fnt;
+$txt->{' font'} = $fnt;
 $text_to_place = "moo moo";
 
-($width_of_last_line, $ypos_of_last_line, $left_over_text) = 
+( $width_of_last_line, $ypos_of_last_line, $left_over_text ) =
   $pdftable->text_block(
     $txt,
     $text_to_place,
@@ -28,6 +28,6 @@
     # -parspace => 0,
     #   -align    => "left",
     #   -hang     => 1,
-);
+  );
 
 $pdf->saveas("$htdocs_path/barcodes/foo.pdf");





More information about the Koha-cvs mailing list