[Koha-cvs] koha label-home.pl barcodes/label-item-search.p... [dev_week]
Joshua Ferraro
jmf at kados.org
Thu Jul 27 20:13:04 CEST 2006
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Joshua Ferraro <kados> 06/07/27 18:13:03
Modified files:
. : label-home.pl
barcodes : label-item-search.pl label-manager.pl
label-print-pdf.pl label-print.pl
koha-tmpl/intranet-tmpl/npl/en/barcodes: label-home.tmpl
label-manager.tmpl
label-print.tmpl
Added files:
C4 : Labels.pm
Log message:
Merging with rel_2_2 barcodes stuff
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/label-home.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.1.2.1
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.1&r2=1.1.2.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.2&r2=1.1.2.2.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&rev=1.3.4.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/npl/en/barcodes/label-home.tmpl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.2&r2=1.1.2.2.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/npl/en/barcodes/label-manager.tmpl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.3&r2=1.1.2.3.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/npl/en/barcodes/label-print.tmpl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.1.2.1
Patches:
Index: label-home.pl
===================================================================
RCS file: /sources/koha/koha/Attic/label-home.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -b -r1.1.2.1 -r1.1.2.1.2.1
--- label-home.pl 13 Apr 2006 19:34:17 -0000 1.1.2.1
+++ label-home.pl 27 Jul 2006 18:13:03 -0000 1.1.2.1.2.1
@@ -8,6 +8,8 @@
use C4::Context;
use HTML::Template;
+#use Data::Dumper;
+
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -28,8 +30,10 @@
my $data = $sth->fetchrow_hashref;
$sth->finish;
-# next line passes a var like 'EAN13_cheched' to the tmpl ,
-# which makes the barcodetype sticky in the dropbox
+$template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
+
+$data->{'printingtype'} = 'both' if ( !$data->{'printingtype'} );
+$template->param( "printingtype_$data->{'printingtype'}" => 1 );
$template->param( "$data->{'barcodetype'}_checked" => 1 );
$template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 );
@@ -44,10 +48,14 @@
isbn => $data->{'isbn'},
dewey => $data->{'dewey'},
class => $data->{'class'},
+ subclass => $data->{'subclass'},
+ itemcallnumber => $data->{'itemcallnumber'},
startrow => $data->{'startrow'},
+
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
);
+warn "ITEMCALLNO".$data->{'itemcallnumber'};
output_html_with_http_headers $query, $cookie, $template->output;
Index: barcodes/label-item-search.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-item-search.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
--- barcodes/label-item-search.pl 21 Jul 2006 17:46:48 -0000 1.1.2.1.2.1
+++ barcodes/label-item-search.pl 27 Jul 2006 18:13:03 -0000 1.1.2.1.2.2
@@ -150,7 +150,7 @@
#warn $i;
#warn Dumper $results->[$i]{'bibid'};
my $type = 'intra';
- my @item_results = &ItemInfo( 0, $results->[$i]{'bibid'}, $type );
+ my @item_results = &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type );
foreach my $item (@item_results) {
Index: barcodes/label-manager.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-manager.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -b -r1.1.2.1 -r1.1.2.1.2.1
--- barcodes/label-manager.pl 11 Apr 2006 05:50:28 -0000 1.1.2.1
+++ barcodes/label-manager.pl 27 Jul 2006 18:13:03 -0000 1.1.2.1.2.1
@@ -18,11 +18,17 @@
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 $itemnumber = $query->param('itemnumber');
my $summary = $query->param('summary');
my $startrow = $query->param('startrow');
+my $printingtype = $query->param('printingtype');
+my $guidebox = $query->param('guidebox');
+
+warn $printingtype;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -42,12 +48,15 @@
$sth2->finish;
my $query2 = "INSERT INTO labels_conf
( barcodetype, title, isbn, itemtype, barcode,
- dewey, class, author, papertype, startrow)
- values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+ dewey, class, subclass, itemcallnumber, author, papertype, printingtype,
+ guidebox, startrow)
+ values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
my $sth2 = $dbh->prepare($query2);
$sth2->execute(
- $barcodetype, $title, $isbn, $itemtype, $bcn,
- $dcn, $classif, $author, $papertype, $startrow
+ $barcodetype, $title, $isbn, $itemtype,
+ $bcn, $dcn, $classif, $subclass,
+ $itemcallnumber, $author, $papertype,$printingtype,
+ $guidebox, $startrow
);
$sth2->finish;
@@ -65,6 +74,7 @@
$sth2->finish;
}
elsif ( $op eq 'delete' ) {
+ warn "MASON, deleting label..";
my $query2 = "DELETE FROM labels where itemnumber = ?";
my $sth2 = $dbh->prepare($query2);
$sth2->execute($itemnumber);
@@ -122,13 +132,19 @@
#calc-ing number of sheets
my $number_of_results = scalar @resultsloop;
-my $sheets_needed = ( ( $number_of_results + $startrow ) / 8 );
+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 );
+
$template->param(
resultsloop => \@resultsloop,
startrow => $startrow,
sheets => $sheets_needed,
+ labels_remaining => $labels_remaining,
+
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
Index: barcodes/label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.2.2.1
diff -u -b -r1.1.2.2 -r1.1.2.2.2.1
--- barcodes/label-print-pdf.pl 12 Apr 2006 08:17:29 -0000 1.1.2.2
+++ barcodes/label-print-pdf.pl 27 Jul 2006 18:13:03 -0000 1.1.2.2.2.1
@@ -1,8 +1,24 @@
#!/usr/bin/perl
-#use strict;
+#----------------------------------------------------------------------
+# this script is really divided into 2 differenvt section,
+
+# the first section creates, and defines the new PDF file the barcodes
+# using PDF::Reuse::Barcode, then saves the file to disk.
+
+# the second section then opens the pdf file off disk, and places the spline label
+# text in the left-most column of the page. then save the file again.
+
+# the reason for this goofyness, it that i couldnt find a single perl package that handled both barcodes and decent text placement.
+
+#use lib '/usr/local/opus-import/intranet/modules';
+#use C4::Context("/etc/koha-opus-import.conf");
+
+use strict;
use CGI;
+use C4::Labels;
use C4::Auth;
+use C4::Bull;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
@@ -10,52 +26,27 @@
use PDF::Reuse;
use PDF::Reuse::Barcode;
use PDF::Report;
+use POSIX;
+
+#use Data::Dumper;
+#use Acme::Comment;
my $htdocs_path = C4::Context->config('intrahtdocs');
my $cgi = new CGI;
-
my $spine_text = "";
# get the printing settings
-my $dbh = C4::Context->dbh;
-my $query2 = " SELECT * FROM labels_conf LIMIT 1 ";
-my $sth = $dbh->prepare($query2);
-$sth->execute();
-
-my $conf_data = $sth->fetchrow_hashref;
-
-# get barcode type from $conf_data
+my $conf_data = get_label_options();
+my @resultsloop = get_label_items();
my $barcodetype = $conf_data->{'barcodetype'};
+my $printingtype = $conf_data->{'printingtype'};
+my $guidebox = $conf_data->{'guidebox'};
my $startrow = $conf_data->{'startrow'};
-$sth->finish;
-
-# get the actual items to be printed.
-my @data;
-my $query3 = " Select * from labels ";
-my $sth = $dbh->prepare($query3);
-$sth->execute();
-my @resultsloop;
-my $cnt = $sth->rows;
-my $i1 = 1;
-while ( my $data = $sth->fetchrow_hashref ) {
-
- # lets get some summary info from each item
- my $query1 =
- " select *from biblio, biblioitems, items where itemnumber = ? and
- items.biblioitemnumber=biblioitems.biblioitemnumber and
- biblioitems.biblionumber=biblio.biblionumber";
-
- my $sth1 = $dbh->prepare($query1);
- $sth1->execute( $data->{'itemnumber'} );
- my $data1 = $sth1->fetchrow_hashref();
-
- push( @resultsloop, $data1 );
- $sth1->finish;
-
- $i1++;
+# if none selected, then choose 'both'
+if ( !$printingtype ) {
+ $printingtype = 'both';
}
-$sth->finish;
# dimensions of gaylord paper
my $lowerLeftX = 0;
@@ -64,52 +55,78 @@
my $upperRightY = 792;
# setting up the pdf doc
+#remove the file before write, for testing
+unlink "$htdocs_path/barcodes/new.pdf";
prFile("$htdocs_path/barcodes/new.pdf");
prLogDir("$htdocs_path/barcodes");
-prMbox( 0, 0, 612, 792 );
+prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
prFont('Times-Roman'); # Just setting a font
prFontSize(10);
my $margin = 36;
-
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 $pageheight = 792;
+
+#warn "STARTROW = $startrow\n";
+
my $y_pos_initial = ( ( $pageheight - $margin ) - $label_height );
my $y_pos_initial_startrow =
( ( $pageheight - $margin ) - ( $label_height * $startrow ) );
-
-my $y_pos_initial = ( ( 792 - 36 ) - 90 );
my $y_pos = $y_pos_initial_startrow;
+
+#warn "Y POS INITAL : $y_pos_initial";
+#warn "Y POS : $y_pos";
+#warn "Y START ROW = $y_pos_initial_startrow";
+
my $rowspace = 36;
my $page_break_count = $startrow;
my $codetype = 'Code39';
+# do border---------------
+my $str = "q\n"; # save the graphic state
+$str .= "4 w\n"; # border color red
+$str .= "0.0 0.0 0.0 RG\n"; # border color red
+$str .= "1 1 1 rg\n"; # fill color blue
+$str .= "0 0 612 792 re\n"; # a rectangle
+$str .= "B\n"; # fill (and a little more)
+$str .= "Q\n"; # save the graphic state
+
+# do border---------------
+
prAdd($str);
my $item;
+# for loop
my $i2 = 1;
foreach $item (@resultsloop) {
- if ( $i2 == 1 ) {
-
- # uncomment this for guide boxes around barcode labels, good for testing.
- #draw_boxes();
+ 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";
+
#building up spine text
my $line = 75;
my $line_spacer = 16;
+ #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'} );
+ $conf_data->{'barcodetype'}, \$item );
build_circ_barcode( $x_pos_circ2, $y_pos, $item->{'barcode'},
- $conf_data->{'barcodetype'} );
+ $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.
@@ -120,7 +137,6 @@
# the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
if ( $page_break_count == 8 ) {
prPage();
-
$page_break_count = 0;
$i2 = 0;
$y_pos = $y_pos_initial;
@@ -128,342 +144,88 @@
$page_break_count++;
$i2++;
}
-
+############## end of loop
prEnd();
-$file = "$htdocs_path/barcodes/new.pdf";
-
-my $pdf = new PDF::Report( File => $file );
-
-my $pagenumber = 1;
-$pdf->openpage($pagenumber);
-
-( $pagewidth, $pageheight ) = $pdf->getPageDimensions();
-my $y_pos = ( $y_pos_initial_startrow + 90 );
-$pdf->setAlign('left');
-$pdf->setSize(9);
-
-my $page_break_count = $startrow;
-
-foreach $item (@resultsloop) {
-
- my $firstrow = 0;
-
- $pdf->setAddTextPos( 36, ( $y_pos - 15 ) ); # INIT START POS
- ( $hPos, $vPos ) = $pdf->getAddTextPos();
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-
- if ( $conf_data->{'dewey'} && $item->{'dewey'} ) {
-
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $pdf->addText( $item->{'dewey'}, 10, 72, 90 );
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $firstrow = 1;
- }
-
- if ( $conf_data->{'isbn'} && $item->{'isbn'} ) {
- if ( $vPos1 == $vPos && $firstrow != 0 ) {
- $pdf->setAddTextPos( 36, ( $vPos - 15 ) );
- }
- else {
- $pdf->setAddTextPos( 36, $vPos1 - 5 ); #add a space
- }
-
- ( $hPos, $vPos ) = $pdf->getAddTextPos();
- $pdf->addText( $item->{'isbn'}, 10, 72, 90 );
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $firstrow = 1;
- }
-
- if ( $conf_data->{'class'} && $item->{'classification'} ) {
+#----------------------------------------------------------------------------
+# 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' ) {
+ my $font = 'Courier';
+ my $text_height = 90;
+ my $file = "$htdocs_path/barcodes/new.pdf";
+ my $pdf = new PDF::Report( File => $file );
- if ( $vPos1 == $vPos && $firstrow != 0 ) {
- $pdf->setAddTextPos( 36, ( $vPos - 15 ) );
- }
- else {
- $pdf->setAddTextPos( 36, $vPos1 - 5 ); #add a space
- }
-
- ( $hPos, $vPos ) = $pdf->getAddTextPos();
- $pdf->addText( $item->{'classification'}, 10, 72, 90 );
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $firstrow = 1;
- }
-
- if ( $conf_data->{'itemtype'} && $item->{'itemtype'} ) {
+ #$pdf->newpage($nopage);
+ my $pagenumber = 1;
+ $pdf->openpage($pagenumber);
+ my ( $pagewidth, $pageheight ) = $pdf->getPageDimensions();
- if ( $vPos1 == $vPos && $firstrow != 0 ) {
- $pdf->setAddTextPos( 36, ( $vPos - 15 ) );
- }
- else {
- $pdf->setAddTextPos( 36, $vPos1 - 5 ); #add a space
- }
+ #warn "PAGE DIM = $pagewidth, $pageheight";
+ #warn "Y START ROW = $y_pos_initial_startrow";
+ $pdf->setAlign('left');
+ $pdf->setFont($font);
+ $pdf->setSize(9);
+ my $fontname = $pdf->getFont();
+ my $fontsize = $pdf->getSize();
+ my $page_break_count = $startrow;
+
+ #warn "INIT PAGEBREAK COUNT = $page_break_count";
+ #warn "INIT VPOS = $vPos, hPos = $hPos";
+ my $vPosSpacer = 10;
+ my $start_text_pos = 39; # ( 36 - 5 = 31 ) 5 is an inside border for text.
+ my $spine_label_text_with = 67;
+ my $y_pos = ( $y_pos_initial_startrow + 90 );
+
+ #warn "Y POS = $y_pos";
+ foreach $item (@resultsloop) {
+
+ # add your printable fields manually in here
+ my @fields =
+ qw (dewey isbn classification itemtype subclass itemcallnumber);
+ my $vPos = $y_pos;
+ my $hPos = 36;
+ foreach my $field (@fields) {
+
+ # if the display option for this field is selected in the DB,
+ # and the item record has some values for this field, display it.
+ if ( $conf_data->{"$field"} && $item->{"$field"} ) {
+
+ # chop the string up into 12 char's per line
+ $str = $item->{"$field"};
+ my $strlen = length($str);
+ my $num_lines = ceil( $strlen / 12 );
+ my $start_pos = 0;
+ my $len = 12;
+
+ # then loop for each string line
+ for ( 1 .. $num_lines ) {
+ $pdf->setAddTextPos( $hPos, $vPos - 10 );
+ my $chop_str = substr( $str, $start_pos, $len );
+ my ( $h, $v ) = $pdf->getAddTextPos();
+
+ # using '1000' width, so that addText wont use it's
+ # own internal wordwrap, (as it doesnt work so well)
+ $pdf->addText( $chop_str, 10, 1000, 90 );
- ( $hPos, $vPos ) = $pdf->getAddTextPos();
- $pdf->addText( $item->{'itemtype'}, 10, 72, 90 );
- ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
- $firstrow = 1;
+ $start_pos = $start_pos + $len;
+ $vPos = $vPos - 10;
}
-
-# uncomment this for guide boxes around spine labels, good for testing.
-#$pdf->drawRect( $x_pos_spine, $y_pos, ( $x_pos_spine + $spine_width ), ( $y_pos - $label_height ));
-
+ } # if field is valid
+ } #foreach feild
$y_pos = ( $y_pos - $label_height );
+
if ( $page_break_count == 8 ) {
$pagenumber++;
$pdf->openpage($pagenumber);
-
$page_break_count = 0;
$i2 = 0;
$y_pos = ( $y_pos_initial + 90 );
- }
+ } # end if
$page_break_count++;
$i2++;
+ } # end of foreach result loop
+ $pdf->saveAs($file);
}
-$pdf->saveAs($file);
-
print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
-
-sub draw_boxes {
- my $y_pos_initial = ( ( 792 - 36 ) - 90 );
- my $y_pos = $y_pos_initial;
- my $i = 1;
-
- for ( $i = 1 ; $i <= 8 ; $i++ ) {
- &drawbox( $x_pos_spine, $y_pos, ($spine_width), ($label_height) );
- &drawbox( $x_pos_circ1, $y_pos, ($circ_width), ($label_height) );
- &drawbox( $x_pos_circ2, $y_pos, ($circ_width), ($label_height) );
- $y_pos = ( $y_pos - $label_height );
- }
-}
-
-sub build_circ_barcode {
- my ( $x_pos_circ, $y_pos, $value, $barcodetype ) = @_;
- if ( $barcodetype eq 'EAN13' ) {
-
- #testing EAN13 barcodes hack
- $value = $value . '000000000';
- $value =~ s/-//;
- $value = substr( $value, 0, 12 );
- eval {
- PDF::Reuse::Barcode::EAN13(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
-
- # prolong => 2.96,
- # xSize => 1.5,
-
- # ySize => 1.2,
-
-# 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',
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
- elsif ( $barcodetype eq 'Code39' ) {
-
- eval {
- PDF::Reuse::Barcode::Code39(
- x => ( $x_pos_circ + 9 ),
- y => ( $y_pos + 15 ),
- value => $value,
-
- # prolong => 2.96,
- xSize => .85,
-
- ySize => 1.3,
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
-
- elsif ( $barcodetype eq 'Matrix2of5' ) {
-
- #testing MATRIX25 barcodes hack
- # $value = $value.'000000000';
- $value =~ s/-//;
-
- # $value = substr( $value, 0, 12 );
-
- eval {
- PDF::Reuse::Barcode::Matrix2of5(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
-
- # prolong => 2.96,
- # xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
-
- elsif ( $barcodetype eq 'EAN8' ) {
-
- #testing ean8 barcodes hack
- $value = $value . '000000000';
- $value =~ s/-//;
- $value = substr( $value, 0, 8 );
-
- eval {
- PDF::Reuse::Barcode::EAN8(
- x => ( $x_pos_circ + 42 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
-
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
-
- }
-
- elsif ( $barcodetype eq 'UPC-E' ) {
- eval {
- PDF::Reuse::Barcode::UPCE(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
-
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
- elsif ( $barcodetype eq 'NW7' ) {
- eval {
- PDF::Reuse::Barcode::NW7(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
-
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
- elsif ( $barcodetype eq 'ITF' ) {
- eval {
- PDF::Reuse::Barcode::ITF(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
-
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
- elsif ( $barcodetype eq 'Industrial2of5' ) {
- eval {
- PDF::Reuse::Barcode::Industrial2of5(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
- elsif ( $barcodetype eq 'IATA2of5' ) {
- eval {
- PDF::Reuse::Barcode::IATA2of5(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
-
- }
-
- elsif ( $barcodetype eq 'COOP2of5' ) {
- eval {
- PDF::Reuse::Barcode::COOP2of5(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
- elsif ( $barcodetype eq 'UPC-A' ) {
-
- eval {
- PDF::Reuse::Barcode::UPCA(
- x => ( $x_pos_circ + 27 ),
- y => ( $y_pos + 15 ),
- value => $value,
- prolong => 2.96,
- xSize => 1.5,
-
- # ySize => 1.2,
- );
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
- }
-}
-
-sub drawbox {
- my ( $llx, $lly, $urx, $ury ) = @_;
-
- my $str = "q\n"; # save the graphic state
- $str .= "1.0 0.0 0.0 RG\n"; # border color red
- $str .= "1 1 1 rg\n"; # fill color blue
- $str .= "$llx $lly $urx $ury re\n"; # a rectangle
- $str .= "B\n"; # fill (and a little more)
- $str .= "Q\n"; # save the graphic state
-
- prAdd($str);
-}
-
Index: barcodes/label-print.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -b -r1.1.2.1 -r1.1.2.1.2.1
--- barcodes/label-print.pl 11 Apr 2006 05:50:28 -0000 1.1.2.1
+++ barcodes/label-print.pl 27 Jul 2006 18:13:03 -0000 1.1.2.1.2.1
@@ -3,14 +3,20 @@
use strict;
use CGI;
use C4::Auth;
+use C4::Bull;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
use HTML::Template;
use GD::Barcode::UPCE;
+use Data::Random qw(:all);
my $htdocs_path = C4::Context->config('intrahtdocs');
+
+use Data::Dumper;
+
my $query = new CGI;
+
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "barcodes/label-print.tmpl",
@@ -26,10 +32,11 @@
my $query2 = "SELECT * FROM labels_conf LIMIT 1";
my $sth = $dbh->prepare($query2);
$sth->execute();
+
my $conf_data = $sth->fetchrow_hashref;
-# get barcode type from $conf_data
-my $barcodetype = $conf_data->{'barcodetype'};
+#warn Dumper $conf_data;
+
$sth->finish;
my @data;
@@ -42,14 +49,16 @@
while ( my $data = $sth->fetchrow_hashref ) {
# lets get some summary info from each item
+
my $query1 = "
- SELECT * FROM biblio,biblioitems,items WHERE itemnumber=? AND
- items.biblioitemnumber=biblioitems.biblioitemnumber AND
+ select * from biblio,biblioitems,items where itemnumber=? and
+ items.biblioitemnumber=biblioitems.biblioitemnumber and
biblioitems.biblionumber=biblio.biblionumber";
my $sth1 = $dbh->prepare($query1);
$sth1->execute( $data->{'itemnumber'} );
my $data1 = $sth1->fetchrow_hashref();
+
push( @resultsloop, $data1 );
$sth1->finish;
@@ -57,36 +66,71 @@
}
$sth->finish;
+#warn Dumper @resultsloop;
+
+
+
+
+#------------------------------------------------------
+
#lets write barcode files to tmp dir for every item in @resultsloop
+
+
binmode(FILE);
-foreach my $item (@resultsloop) {
- my $filename = "$htdocs_path/barcodes/$barcodetype-$item->{'barcode'}.png";
- open( FILE, ">$filename" );
- eval {
- print FILE GD::Barcode->new( $barcodetype, $item->{'barcode'} )
- ->plot->png;
- };
- if ($@) {
- $item->{'barcodeerror'} = 1;
- }
+foreach my $item (@resultsloop){
+
+
+my $random = int( rand(100000000000)) + 999999999999;
+#warn "$random\n";
+
+ $item->{'barcode'} = $random;
+
+# my $itembarcode = $item->{'barcode'};
+# warn $item->{'barcode'};
+
+
+ my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
+ #warn $filename;
+ open(FILE, ">$filename");
+
+ print FILE GD::Barcode->new('EAN13', $item->{'barcode'})->plot->png;
+# warn $GD::Barcode::errStr;
+
close(FILE);
+
+#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'},
+ barcode_opt => $conf_data->{'barcode'},
id_opt => $conf_data->{'id'},
- barcodetype_opt => $conf_data->{'barcodetype'},
+ type_opt => $conf_data->{'type'},
title_opt => $conf_data->{'title'},
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"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
);
output_html_with_http_headers $query, $cookie, $template->output;
+
+
Index: koha-tmpl/intranet-tmpl/npl/en/barcodes/label-home.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/npl/en/barcodes/Attic/label-home.tmpl,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.2.2.1
diff -u -b -r1.1.2.2 -r1.1.2.2.2.1
--- koha-tmpl/intranet-tmpl/npl/en/barcodes/label-home.tmpl 13 Apr 2006 21:41:30 -0000 1.1.2.2
+++ koha-tmpl/intranet-tmpl/npl/en/barcodes/label-home.tmpl 27 Jul 2006 18:13:03 -0000 1.1.2.2.2.1
@@ -1,181 +1,213 @@
-<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Barcodes and Labels<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Labels<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE name="masthead.inc" -->
<!-- TMPL_INCLUDE NAME="label-topmenu.inc" -->
<!-- TMPL_INCLUDE name="intranet-nav.inc" -->
<div id="main">
-<form name="input" action="barcodes/label-manager.pl" method="get">
+<form name="input" action="/cgi-bin/koha/barcodes/label-manager.pl" method="get">
-<h3>Choose Fields to Print</h3>
-<table summary="Fields to Print">
+<h3>
+ Choose Fields to Print
+</h3>
+<table summary="fields to print">
<tr>
<td>
+ <input type="checkbox" name="itemtype" value=1
<!-- TMPL_IF NAME="itemtype"-->
- <input type="checkbox" id="itemtype" name="itemtype" value="1" checked="checked" />
- <!-- TMPL_ELSE -->
- <input type="checkbox" id="itemtype" name="itemtype" value="1" />
- <!-- /TMPL_IF -->
+ checked
+ <!-- /TMPL_IF --> >
<label for="itemtype">Item Type</label>
</td>
<td>
+ <input type="checkbox" name="isbn" value=1
<!-- TMPL_IF NAME="isbn" -->
- <input type="checkbox" id="isbn" name="isbn" value="1" checked="checked" />
- <!-- TMPL_ELSE -->
- <input type="checkbox" id="isbn" name="isbn" value="1" />
- <!-- /TMPL_IF -->
+ checked
+ <!-- /TMPL_IF -->>
<label for="isbn">ISBN</label>
</td>
</tr>
<tr>
<td>
+ <input type="checkbox" name="dcn" value=1
<!-- TMPL_IF NAME="dewey" -->
- <input type="checkbox" id="dcn" name="dcn" value="1" checked="checked" />
- <!-- TMPL_ELSE -->
- <input type="checkbox" id="dcn" name="dcn" value="1" />
- <!-- /TMPL_IF -->
+ checked
+ <!-- /TMPL_IF -->>
<label for="dcn">Dewey / Call Number</label>
</td>
<td>
+ <input type="checkbox" name="classif" value=1
<!-- TMPL_IF NAME="class" -->
- <input type="checkbox" id="classif" name="classif" value="1" checked="checked" />
- <!-- TMPL_ELSE -->
- <input type="checkbox" id="classif" name="classif" value="1" />
- <!-- /TMPL_IF -->
+ checked
+ <!-- /TMPL_IF -->>
<label for="classif">Classification</label>
</td>
</tr>
+<tr>
+ <td>
+ <input type="checkbox" name="itemcallnumber" value=1
+ <!-- TMPL_IF NAME="itemcallnumber" -->
+ checked
+ <!-- /TMPL_IF -->>
+ <label for="itemcallnumber">Item Call Number</label>
+ </td>
+ <td>
+ <input type="checkbox" name="subclass" value=1
+ <!-- TMPL_IF NAME="subclass" -->
+ checked
+ <!-- /TMPL_IF -->>
+ <label for="subclass">Sub-Class</label>
+ </td>
+</tr>
</table>
+<p>
-<p><label for="papertype">Confirm Label Type</label>
- <select id="papertype" name="papertype">
- <option value="Gaylord8511">Gaylord-8511</option>
- </select></p>
+<h3>Confirm Label Type</h3>
+<select name="papertype">
+ <option value="gaylord-8511"
+ <!-- TMPL_IF NAME="papertype_gaylord-8511" -->
+ selected
+ <!--/TMPL_IF -->
+ >Gaylord-8511</option>
+ <option value="opus-dot-matrix"
+ <!-- TMPL_IF NAME="papertype_opus-dot-matrix" -->
+ selected
+ <!--/TMPL_IF -->
+ >OPUS Dot-Matrix</option>
+ </select>
-<p><label for="barcodetype">Confirm Barcode Type</label>
- <select id="barcodetype" name="barcodetype">
+<h3>Confirm Barcode Type</h3>
+ <select name="barcodetype">
+ <option value="COOP2of5"
<!-- TMPL_IF NAME="COOP2of5_checked" -->
- <option value="COOP2of5" selected="selected">COOP2of5</option>
- <!-- TMPL_ELSE -->
- <option value="COOP2of5">COOP2of5</option>
- <!-- /TMPL_IF -->
+ selected
+ <!--/TMPL_IF -->
+ >COOP2of5</option>
+ <option value="Code39"
<!-- TMPL_IF NAME="Code39_checked" -->
- <option value="Code39" selected="selected">Code39</option>
- <!-- TMPL_ELSE -->
- <option value="Code39">Code39</option>
+ selected
<!-- /TMPL_IF -->
+ >Code39</option>
+ <option value="EAN13"
<!-- TMPL_IF NAME="EAN13_checked" -->
- <option value="EAN13" selected="selected">EAN13(JAN13)</option>
- <!-- TMPL_ELSE -->
- <option value="EAN13">EAN13(JAN13)</option>
+ selected
<!-- /TMPL_IF -->
+ >EAN13(JAN13)</option>
+ <option value="EAN8"
<!-- TMPL_IF NAME="EAN8_checked" -->
- <option value="EAN8" selected="selected">EAN8(JAN8)</option>
- <!-- TMPL_ELSE -->
- <option value="EAN8">EAN8(JAN8)</option>
- <!-- /TMPL_IF -->
+ selected<!-- /TMPL_IF -->
+ >EAN8(JAN8)</option>
+ <option value="ITF"
<!-- TMPL_IF NAME="ITF_checked" -->
- <option value="ITF" selected="selected">ITF(Interleaved2of5)</option>
- <!-- TMPL_ELSE -->
- <option value="ITF">ITF(Interleaved2of5)</option>
+ selected
<!-- /TMPL_IF -->
+ >ITF(Interleaved2of5)</option>
+ <option value="Industrial2of5"
<!-- TMPL_IF NAME="Industrial2of5_checked" -->
- <option value="Industrial2of5" selected="selected">Industrial2of5</option>
- <!-- TMPL_ELSE -->
- <option value="Industrial2of5">Industrial2of5</option>
+ selected
<!-- /TMPL_IF -->
+ >Industrial2of5</option>
+ <option value="Matrix2of5"
<!-- TMPL_IF NAME="Matrix2of5_checked" -->
- <option value="Matrix2of5" selected="selected">Matrix2of5</option>
- <!-- TMPL_ELSE -->
- <option value="Matrix2of5">Matrix2of5</option>
+ selected
<!-- /TMPL_IF -->
+ >Matrix2of5</option>
+ <option value="NW7"
<!-- TMPL_IF NAME="NW7_checked" -->
- <option value="NW7" selected="selected">NW7</option>
- <!-- TMPL_ELSE -->
- <option value="NW7">NW7</option>
+ selected
<!-- /TMPL_IF -->
+ >NW7</option>
+ <option value="QRcode"
<!-- TMPL_IF NAME="QRcode_checked" -->
- <option value="QRcode" selected="selected">QRcode</option>
- <!-- TMPL_ELSE -->
- <option value="QRcode">QRcode</option>
+ selected
<!-- /TMPL_IF -->
+ >QRcode</option>
+ <option value="UPC-A"
<!-- TMPL_IF NAME="UPC-A_checked" -->
- <option value="UPC-A" selected="selected">UPC-A</option>
- <!-- TMPL_ELSE -->
- <option value="UPC-A">UPC-A</option>
+ selected
<!-- /TMPL_IF -->
+ >UPC-A</option>
+ <option value="UPC-E"
<!-- TMPL_IF NAME="UPC-E_checked" -->
- <option value="UPC-E" selected="selected">UPC-E</option>
- <!-- TMPL_ELSE -->
- <option value="UPC-E">UPC-E</option>
+ selected
<!-- /TMPL_IF -->
-
+ >UPC-E</option>
</select>
-</p>
+</h3>
-<p>
-<label for="startrow">Start printing from Row number:</label>
- <select id="startrow" name="startrow">
- <!-- TMPL_IF NAME="startrow1_checked" -->
- <option value="1" selected="selected">1</option>
- <!-- TMPL_ELSE -->
- <option value="1">1</option>
- <!-- /TMPL_IF -->
+<h3>Confirm Printing Type</h3>
+<input type="radio" name="printingtype" value="spine"
+ <!-- TMPL_IF NAME="printingtype_spine" -->
+ checked
+ <!--/TMPL_IF -->
+ >Spine Labels
+<input type="radio" name="printingtype" value="barcode"
+ <!-- TMPL_IF NAME="printingtype_barcode" -->
+ checked
+ <!--/TMPL_IF -->
+ >Barcode Labels
+<input type="radio" name="printingtype" value="both"
+ <!-- TMPL_IF NAME="printingtype_both" -->
+ checked
+ <!--/TMPL_IF -->
+ >Both Labels
+
+
+<h3>
+ Start printing from Row number:<select name="startrow">
+ <option value="1"
+ <!-- TMPL_IF NAME="startrow1_checked" -->
+ selected
+ <!-- /TMPL_IF -->>1</option>
+ <option value="2"
<!-- TMPL_IF NAME="startrow2_checked" -->
- <option value="2" selected="selected">2</option>
- <!-- TMPL_ELSE -->
- <option value="2">2</option>
- <!-- /TMPL_IF -->
-
+ selected
+ <!-- /TMPL_IF -->>2</option>
+ <option value="3"
<!-- TMPL_IF NAME="startrow3_checked" -->
- <option value="3" selected="selected">3</option>
- <!-- TMPL_ELSE -->
- <option value="3">3</option>
- <!-- /TMPL_IF -->
-
+ selected
+ <!-- /TMPL_IF -->>3</option>
+ <option value="4"
<!-- TMPL_IF NAME="startrow4_checked" -->
- <option value="4" selected="selected">4</option>
- <!-- TMPL_ELSE -->
- <option value="4">4</option>
- <!-- /TMPL_IF -->
-
+ selected
+ <!-- /TMPL_IF -->>4</option>
+ <option value="5"
<!-- TMPL_IF NAME="startrow5_checked" -->
- <option value="5" selected="selected">5</option>
- <!-- TMPL_ELSE -->
- <option value="5">5</option>
- <!-- /TMPL_IF -->
-
+ selected
+ <!-- /TMPL_IF -->>5</option>
+ <option value="6"
<!-- TMPL_IF NAME="startrow6_checked" -->
- <option value="6" selected="selected">6</option>
- <!-- TMPL_ELSE -->
- <option value="6">6</option>
- <!-- /TMPL_IF -->
-
+ selected
+ <!-- /TMPL_IF -->>6</option>
+ <option value="7"
<!-- TMPL_IF NAME="startrow7_checked" -->
- <option value="7" selected="selected">7</option>
- <!-- TMPL_ELSE -->
- <option value="7">7</option>
- <!-- /TMPL_IF -->
-
+ selected
+ <!-- /TMPL_IF -->>7</option>
+ <option value="8"
<!-- TMPL_IF NAME="startrow8_checked" -->
- <option value="8" selected="selected">8</option>
- <!-- TMPL_ELSE -->
- <option value="8">8</option>
- <!-- /TMPL_IF -->
+ selected
+ <!-- /TMPL_IF -->>8</option>
</select>
-</p>
-<p>
- <input type="submit" value="Submit" class="submit" />
- <input type="hidden" name=op value="save_conf" />
+</h3>
+<p>
+<p>
+ <input type="checkbox" name="guidebox" value=1
+ <!-- TMPL_IF NAME="guidebox"-->
+ checked
+ <!-- /TMPL_IF -->>
+ <label for="guidebox">Draw Guide Boxes</label>
+<p>
+<p>
+<p>
+ <input type="submit" value="Submit">
+ <input type="reset" value="Reset">
+ <input type="hidden" name=op value="save_conf">
</p>
</form>
-
-
-
</div>
- <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
Index: koha-tmpl/intranet-tmpl/npl/en/barcodes/label-manager.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/npl/en/barcodes/Attic/label-manager.tmpl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.3.2.1
diff -u -b -r1.1.2.3 -r1.1.2.3.2.1
--- koha-tmpl/intranet-tmpl/npl/en/barcodes/label-manager.tmpl 19 Apr 2006 05:16:03 -0000 1.1.2.3
+++ koha-tmpl/intranet-tmpl/npl/en/barcodes/label-manager.tmpl 27 Jul 2006 18:13:03 -0000 1.1.2.3.2.1
@@ -25,7 +25,7 @@
<!-- TMPL_VAR NAME="labelno" -->
</td>
<td>
- <b><!-- TMPL_VAR NAME="title" -->:</b> <!-- TMPL_VAR NAME="author" -->:
+ <b> <a href="/cgi-bin/koha/detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->"> <!-- TMPL_VAR NAME="title" -->:</a></b> <!-- TMPL_VAR NAME="author" -->:
<!-- TMPL_VAR NAME="isbn" -->: <!-- TMPL_VAR NAME="barcode" -->
</td>
<td>
Index: koha-tmpl/intranet-tmpl/npl/en/barcodes/label-print.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/npl/en/barcodes/Attic/label-print.tmpl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -b -r1.1.2.1 -r1.1.2.1.2.1
--- koha-tmpl/intranet-tmpl/npl/en/barcodes/label-print.tmpl 11 Apr 2006 05:29:06 -0000 1.1.2.1
+++ koha-tmpl/intranet-tmpl/npl/en/barcodes/label-print.tmpl 27 Jul 2006 18:13:03 -0000 1.1.2.1.2.1
@@ -128,6 +128,9 @@
<!-- TMPL_IF NAME="isbn_opt" -->isbn <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="dewey_opt" -->dewey <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="class_opt" -->class<!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="subclass_opt" -->subclass<!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="itemcallnumber_opt" -->itemcallnumber<!-- /TMPL_IF -->
+
</h3>
</div>
@@ -144,6 +147,8 @@
<!-- TMPL_IF NAME="isbn_opt" --><!-- TMPL_VAR NAME="isbn" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="dewey_opt" --><!-- TMPL_VAR NAME="dewey" --><br /><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="class_opt" --><!-- TMPL_VAR NAME="class" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="subclass_opt" --><!-- TMPL_VAR NAME="subclass" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="itemcallnumber_opt" --><!-- TMPL_VAR NAME="itemcallnumber" --><!-- /TMPL_IF -->
</td>
<td class="space-8511"> </td>
<td class="circ-label-8511">
Index: C4/Labels.pm
===================================================================
RCS file: C4/Labels.pm
diff -N C4/Labels.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ C4/Labels.pm 27 Jul 2006 18:13:03 -0000 1.3.4.1
@@ -0,0 +1,458 @@
+package C4::Labels;
+
+# Copyright 2006 Katipo Communications.
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+require Exporter;
+
+use vars qw($VERSION @ISA @EXPORT);
+#use Data::Dumper;
+use PDF::Reuse;
+
+
+$VERSION = 0.01;
+
+=head1 NAME
+
+C4::Labels - Functions for printing spine labels and barcodes in Koha
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+ at ISA = qw(Exporter);
+ at EXPORT = qw(
+ &get_label_options &get_label_items
+ &build_circ_barcode &draw_boundaries
+ &draw_box
+);
+
+=item get_label_options;
+
+ $options = get_label_options()
+
+
+Return a pointer on a hash list containing info from labels_conf table in Koha DB.
+
+=cut
+#'
+sub get_label_options {
+ my $dbh = C4::Context->dbh;
+ my $query2 = " SELECT * FROM labels_conf LIMIT 1 ";
+ my $sth = $dbh->prepare($query2);
+ $sth->execute();
+ my $conf_data = $sth->fetchrow_hashref;
+ $sth->finish;
+ return $conf_data;
+}
+
+=item get_label_items;
+
+ $options = get_label_items()
+
+
+Returns an array of references-to-hash, whos keys are the field from the biblio, biblioitems, items and labels tables in the Koha database.
+
+=cut
+#'
+sub get_label_items {
+ my $dbh = C4::Context->dbh;
+
+ # get the actual items to be printed.
+ my @data;
+ my $query3 = " Select * from labels ";
+ my $sth = $dbh->prepare($query3);
+ $sth->execute();
+ my @resultsloop;
+ my $cnt = $sth->rows;
+ my $i1 = 1;
+ while ( my $data = $sth->fetchrow_hashref ) {
+
+ # lets get some summary info from each item
+ my $query1 =
+ " select * from biblio, biblioitems, items where itemnumber = ? and
+ items.biblioitemnumber=biblioitems.biblioitemnumber and
+ biblioitems.biblionumber=biblio.biblionumber";
+
+ my $sth1 = $dbh->prepare($query1);
+ $sth1->execute( $data->{'itemnumber'} );
+ my $data1 = $sth1->fetchrow_hashref();
+
+ push( @resultsloop, $data1 );
+ $sth1->finish;
+
+ $i1++;
+ }
+ $sth->finish;
+ return @resultsloop;
+}
+
+=item build_circ_barcode;
+
+ build_circ_barcode( $x_pos, $y_pos, $barcode,
+ $barcodetype, \$item);
+
+$item is the result of a previous call to get_label_items();
+
+=cut
+#'
+sub build_circ_barcode {
+ my ( $x_pos_circ, $y_pos, $value, $barcodetype, $item ) = @_;
+
+#warn Dumper \$item;
+
+ #warn "value = $value\n";
+
+ #$DB::single = 1;
+
+ if ( $barcodetype eq 'EAN13' ) {
+
+ #testing EAN13 barcodes hack
+ $value = $value . '000000000';
+ $value =~ s/-//;
+ $value = substr( $value, 0, 12 );
+
+ #warn $value;
+ eval {
+ PDF::Reuse::Barcode::EAN13(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+
+ # prolong => 2.96,
+ # xSize => 1.5,
+
+ # ySize => 1.2,
+
+# 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',
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "EAN13BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+ elsif ( $barcodetype eq 'Code39' ) {
+
+ eval {
+ PDF::Reuse::Barcode::Code39(
+ x => ( $x_pos_circ + 9 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+
+ # prolong => 2.96,
+ xSize => .85,
+
+ ySize => 1.3,
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "CODE39BARCODE $value FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+
+ elsif ( $barcodetype eq 'Matrix2of5' ) {
+
+ #warn "MATRIX ELSE:";
+
+ #testing MATRIX25 barcodes hack
+ # $value = $value.'000000000';
+ $value =~ s/-//;
+
+ # $value = substr( $value, 0, 12 );
+ #warn $value;
+
+ eval {
+ PDF::Reuse::Barcode::Matrix2of5(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+
+ # prolong => 2.96,
+ # xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+
+ elsif ( $barcodetype eq 'EAN8' ) {
+
+ #testing ean8 barcodes hack
+ $value = $value . '000000000';
+ $value =~ s/-//;
+ $value = substr( $value, 0, 8 );
+
+ #warn $value;
+
+ #warn "EAN8 ELSEIF";
+ eval {
+ PDF::Reuse::Barcode::EAN8(
+ x => ( $x_pos_circ + 42 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+
+ elsif ( $barcodetype eq 'UPC-E' ) {
+ eval {
+ PDF::Reuse::Barcode::UPCE(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+ elsif ( $barcodetype eq 'NW7' ) {
+ eval {
+ PDF::Reuse::Barcode::NW7(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+ elsif ( $barcodetype eq 'ITF' ) {
+ eval {
+ PDF::Reuse::Barcode::ITF(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+ elsif ( $barcodetype eq 'Industrial2of5' ) {
+ eval {
+ PDF::Reuse::Barcode::Industrial2of5(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+ elsif ( $barcodetype eq 'IATA2of5' ) {
+ eval {
+ PDF::Reuse::Barcode::IATA2of5(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+
+ elsif ( $barcodetype eq 'COOP2of5' ) {
+ eval {
+ PDF::Reuse::Barcode::COOP2of5(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+ elsif ( $barcodetype eq 'UPC-A' ) {
+
+ eval {
+ PDF::Reuse::Barcode::UPCA(
+ x => ( $x_pos_circ + 27 ),
+ y => ( $y_pos + 15 ),
+ value => $value,
+ prolong => 2.96,
+ xSize => 1.5,
+
+ # ySize => 1.2,
+ );
+ };
+ if ($@) {
+ $item->{'barcodeerror'} = 1;
+ #warn "BARCODE FAILED:$@";
+ }
+
+ #warn $barcodetype;
+
+ }
+
+}
+
+=item draw_boundaries
+
+ sub draw_boundaries ($x_pos_spine, $x_pos_circ1, $x_pos_circ2,
+ $y_pos, $spine_width, $label_height, $circ_width)
+
+This sub draws boundary lines where the label outlines are, to aid in printer testing, and debugging.
+
+=cut
+
+#'
+sub draw_boundaries {
+
+ my ($x_pos_spine, $x_pos_circ1, $x_pos_circ2,
+ $y_pos, $spine_width, $label_height, $circ_width) = @_;
+
+ my $y_pos_initial = ( ( 792 - 36 ) - 90 );
+ my $y_pos = $y_pos_initial;
+ my $i = 1;
+
+ for ( $i = 1 ; $i <= 8 ; $i++ ) {
+
+ &drawbox( $x_pos_spine, $y_pos, ($spine_width), ($label_height) );
+
+ #warn "OLD BOXES x=$x_pos_spine, y=$y_pos, w=$spine_width, h=$label_height";
+ &drawbox( $x_pos_circ1, $y_pos, ($circ_width), ($label_height) );
+ &drawbox( $x_pos_circ2, $y_pos, ($circ_width), ($label_height) );
+
+ $y_pos = ( $y_pos - $label_height );
+
+ }
+}
+
+=item drawbox
+
+ sub drawbox { $lower_left_x, $lower_left_y,
+ $upper_right_x, $upper_right_y )
+
+this is a low level sub, that draws a pdf box, it is called by draw_boxes
+
+=cut
+
+#'
+sub drawbox {
+ my ( $llx, $lly, $urx, $ury ) = @_;
+
+ my $str = "q\n"; # save the graphic state
+ $str .= "1.0 0.0 0.0 RG\n"; # border color red
+ $str .= "1 1 1 rg\n"; # fill color blue
+ $str .= "$llx $lly $urx $ury re\n"; # a rectangle
+ $str .= "B\n"; # fill (and a little more)
+ $str .= "Q\n"; # save the graphic state
+
+ prAdd($str);
+
+}
+
+END { } # module clean-up code here (global destructor)
+
+1;
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Mason James <mason at katipo.co.nz>
+=cut
+
More information about the Koha-cvs
mailing list