koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/barcodes label-item-search.pl label-manage... [rel_2_2]


From: Mason James
Subject: [Koha-cvs] koha/barcodes label-item-search.pl label-manage... [rel_2_2]
Date: Wed, 19 Jul 2006 01:37:23 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_2_2
Changes by:     Mason James <sushi>     06/07/19 01:37:23

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

Log message:
        tidyup by mason.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-item-search.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.2&r2=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-home.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-opus-pdf.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/test.textblock.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.2.1

Patches:
Index: label-item-search.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-item-search.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-item-search.pl        11 Apr 2006 05:52:09 -0000      1.1.2.1
+++ label-item-search.pl        19 Jul 2006 01:37:23 -0000      1.1.2.2
@@ -151,7 +151,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: label-manager.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-manager.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-manager.pl    11 Apr 2006 05:50:28 -0000      1.1.2.1
+++ label-manager.pl    19 Jul 2006 01:37:23 -0000      1.1.2.2
@@ -23,6 +23,10 @@
 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 +46,14 @@
     $sth2->finish;
     my $query2 = "INSERT INTO labels_conf 
                        ( barcodetype, title, isbn, itemtype, barcode,  
-                         dewey, class, author, papertype, startrow)
-                          values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+                         dewey, class, 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,  $author,
+        $papertype,   $printingtype, $guidebox, $startrow
     );
     $sth2->finish;
 
@@ -65,6 +71,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 +129,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             => address@hidden,
     startrow                => $startrow,
     sheets                  => $sheets_needed,
+    labels_remaining => $labels_remaining,
+
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),

Index: 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.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- label-print-pdf.pl  12 Apr 2006 08:17:29 -0000      1.1.2.2
+++ label-print-pdf.pl  19 Jul 2006 01:37:23 -0000      1.1.2.3
@@ -1,8 +1,24 @@
 #!/usr/bin/perl
 
+#----------------------------------------------------------------------
+# 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/hlt/intranet/modules';
+#use C4::Context("/etc/koha-hlt.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,6 +26,10 @@
 use PDF::Reuse;
 use PDF::Reuse::Barcode;
 use PDF::Report;
+use Data::Dumper;
+
+#use Acme::Comment;
+#use Data::Dumper;
 
 my $htdocs_path = C4::Context->config('intrahtdocs');
 my $cgi         = new CGI;
@@ -17,45 +37,27 @@
 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;
+my $conf_data   = get_label_options();
+my @resultsloop = get_label_items();
+
+warn Dumper $conf_data;
+
 
-# get barcode type from $conf_data
 my $barcodetype = $conf_data->{'barcodetype'};
+my $printingtype = $conf_data->{'printingtype'};
+my $guidebox  = $conf_data->{'guidebox'};
 my $startrow    = $conf_data->{'startrow'};
 
-$sth->finish;
+if (!$printingtype) {
+       $printingtype = 'both';
+}
 
-# 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();
+warn $printingtype;
+warn $guidebox;
 
-    push( @resultsloop, $data1 );
-    $sth1->finish;
 
-    $i1++;
-}
-$sth->finish;
+#warn Dumper @resultsloop;
 
 # dimensions of gaylord paper
 my $lowerLeftX  = 0;
@@ -63,10 +65,18 @@
 my $upperRightX = 612;
 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 ( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
 prMbox( 0, 0, 612, 792 );
+
 prFont('Times-Roman');    # Just setting a font
 prFontSize(10);
 
@@ -80,37 +90,68 @@
 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 = ( ( 792 - 36 ) - 90 );
 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;
 
+    $DB::single = 1;
+
+    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.
 #      mode => 'graphic',
@@ -121,6 +162,7 @@
     if ( $page_break_count == 8 ) {
         prPage();
 
+        #warn "############# PAGEBREAK ###########";
         $page_break_count = 0;
         $i2               = 0;
         $y_pos            = $y_pos_initial;
@@ -128,342 +170,120 @@
     $page_break_count++;
     $i2++;
 }
+############## end of loop
+
 
 prEnd();
 
-$file = "$htdocs_path/barcodes/new.pdf";
+#----------------------------------------------------------------------------
+# 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
 
-my $pdf = new PDF::Report( File => $file );
+if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
 
-my $pagenumber = 1;
-$pdf->openpage($pagenumber);
+    $file = "$htdocs_path/barcodes/new.pdf";
 
-( $pagewidth, $pageheight ) = $pdf->getPageDimensions();
-my $y_pos = ( $y_pos_initial_startrow + 90 );
-$pdf->setAlign('left');
-$pdf->setSize(9);
+    my $pdf = new PDF::Report( File => $file );
 
-my $page_break_count = $startrow;
+    # my $pdf = new PDF::Report(PageSize => "letter",
+    #                                  PageOrientation => "Landscape");
 
-foreach $item (@resultsloop) {
+    #$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( 36, ( $y_pos - 15 ) );    # INIT START POS
+        $pdf->setAddTextPos( $start_text_pos, ( $y_pos - 20 ) )
+          ;                    # INIT START POS
     ( $hPos, $vPos )  = $pdf->getAddTextPos();
-    ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
 
+        my $hPosEnd = ( $hPos + $spine_label_text_with );    # 72
     if ( $conf_data->{'dewey'} && $item->{'dewey'} ) {
-
         ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-        $pdf->addText( $item->{'dewey'}, 10, 72, 90 );
-        ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-        $firstrow = 1;
+            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'dewey'} );
+            $vPos = $vPos - $vPosSpacer;
     }
 
     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;
+            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'isbn'} );
+            $vPos = $vPos - $vPosSpacer;
     }
 
     if ( $conf_data->{'class'} && $item->{'classification'} ) {
-
-        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;
+            $pdf->centerString( $hPos, $hPosEnd, $vPos,
+                $item->{'classification'} );
+            $vPos = $vPos - $vPosSpacer;
     }
 
     if ( $conf_data->{'itemtype'} && $item->{'itemtype'} ) {
-
-        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->{'itemtype'}, 10, 72, 90 );
         ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-        $firstrow = 1;
+            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'itemtype'} );
+            $vPos = $vPos - $vPosSpacer;
     }
 
-# 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 ));
+        #$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 );
     }
+
     $page_break_count++;
     $i2++;
-}
-$pdf->saveAs($file);
 
-print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
+        #warn "#----------------------------------\n";
 
-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 );
     }
+    $DB::single = 1;
+    $pdf->saveAs($file);
 }
 
-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);
-}
+#------------------------------------------------
 
+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.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-print.pl      11 Apr 2006 05:50:28 -0000      1.1.2.1
+++ label-print.pl      19 Jul 2006 01:37:23 -0000      1.1.2.2
@@ -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,73 @@
 }
 $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             => address@hidden,
+
+
     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'},
+
+
+
+
     intranetcolorstylesheet =>
       C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
     IntranetNav        => C4::Context->preference("IntranetNav"),
 );
 output_html_with_http_headers $query, $cookie, $template->output;
+
+

Index: label-home.pl
===================================================================
RCS file: label-home.pl
diff -N label-home.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ label-home.pl       19 Jul 2006 01:37:23 -0000      1.1.2.3
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Output;
+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(
+    {
+        template_name   => "barcodes/label-home.tmpl",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { catalogue => 1 },
+        debug           => 1,
+    }
+);
+
+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;
+
+$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 );
+$template->param(
+    itemtype    => $data->{'itemtype'},
+    papertype   => $data->{'papertype'},
+    author      => $data->{'author'},
+    barcode     => $data->{'barcode'},
+    id          => $data->{'id'},
+    barcodetype => $data->{'barcodetype'},
+    title       => $data->{'title'},
+    isbn        => $data->{'isbn'},
+    dewey       => $data->{'dewey'},
+    class       => $data->{'class'},
+    startrow    => $data->{'startrow'},
+
+    intranetcolorstylesheet =>
+      C4::Context->preference("intranetcolorstylesheet"),
+    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+    IntranetNav        => C4::Context->preference("IntranetNav"),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: label-print-opus-pdf.pl
===================================================================
RCS file: label-print-opus-pdf.pl
diff -N label-print-opus-pdf.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ label-print-opus-pdf.pl     19 Jul 2006 01:37:23 -0000      1.1.2.1
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+
+#use lib '/usr/local/opus-dev/intranet/modules';
+#use C4::Context("/etc/koha-opus-dev.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;
+use PDF::Reuse;
+use PDF::Reuse::Barcode;
+use PDF::Report;
+use PDF::Create;
+use PDF::Labels;
+use Acme::Comment;
+use Data::Dumper;
+warn "-------";
+
+my $htdocs_path = C4::Context->config('intrahtdocs');
+my $cgi         = new CGI;
+
+my $pdf = new PDF::Labels(
+    $PDF::Labels::PageFormats[1],
+    filename   => "$htdocs_path/barcodes/opus.pdf",
+    Author     => 'PDF Labelmaker',
+    'PageMode' => 'UseOutlines',
+    Title      => 'My Labels'
+);
+
+warn "$htdocs_path/barcodes/opus.pdf";
+
+my @resultsloop = get_label_items();
+
+#warn Dumper @resultsloop;
+warn Dumper $pdf->{'filename'};
+
+$pdf->setlabel(0);    # Start with label 5 on first page
+
+foreach my $result (@resultsloop) {
+    warn Dumper $result;
+    $pdf->label( $result->{'itemtype'}, $result->{'number'}, 'LAK',
+        $result->{'barcode'} );
+    $pdf->label( $result->{'itemtype'}, $result->{'dewey'}, 'LAK',
+        $result->{'barcode'} );
+
+}
+warn "HERE";
+$pdf->close();
+
+#--------------------------------------------------
+
+use PDF::Reuse;
+prFile("$htdocs_path/barcodes/opus1.pdf");
+prDoc("$htdocs_path/barcodes/opus.pdf");
+prEnd();
+
+print $cgi->redirect("/intranet-tmpl/barcodes/opus1.pdf");
+

Index: test.textblock.pl
===================================================================
RCS file: test.textblock.pl
diff -N test.textblock.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test.textblock.pl   19 Jul 2006 01:37:23 -0000      1.1.2.1
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+use C4::Context;
+use PDF::API2;
+use PDF::Table;
+
+my $pdftable = new PDF::Table;
+my $pdf      = PDF::API2->new();
+
+#$pdf->mediabox(612,792);
+my $fnt = $pdf->corefont('Helvetica-Bold');
+my $page = $pdf->page;    # returns the last page
+my $txt  = $page->text;
+$txt->{' font'}=$fnt;
+$text_to_place = "moo moo";
+
+($width_of_last_line, $ypos_of_last_line, $left_over_text) = 
+  $pdftable->text_block(
+    $txt,
+    $text_to_place,
+    -x => 100,
+    -y => 300,
+    -w => 50,
+    -h => 40,
+      
+    #  -lead     => 13,
+    #  -font_size => 12,
+    # -parspace => 0,
+    #   -align    => "left",
+    #   -hang     => 1,
+);
+
+$pdf->saveas("$htdocs_path/barcodes/foo.pdf");




reply via email to

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