koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/barcodes label-home.pl label-manager.pl la...


From: Mason James
Subject: [Koha-cvs] koha/barcodes label-home.pl label-manager.pl la...
Date: Wed, 19 Jul 2006 01:09:43 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Mason James <sushi>     06/07/19 01:09:43

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

Log message:
        tidy up by mason.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-home.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-opus-pdf.pl?cvsroot=koha&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/test.textblock.pl?cvsroot=koha&rev=1.1

Patches:
Index: label-home.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-home.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- label-home.pl       11 Apr 2006 20:56:14 -0000      1.2
+++ label-home.pl       19 Jul 2006 01:09:42 -0000      1.3
@@ -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 );
@@ -45,9 +49,11 @@
     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-manager.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-manager.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- label-manager.pl    19 Apr 2006 04:51:03 -0000      1.3
+++ label-manager.pl    19 Jul 2006 01:09:42 -0000      1.4
@@ -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);
@@ -123,11 +130,11 @@
 #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
+$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);
+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,

Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- label-print-pdf.pl  13 Jul 2006 23:14:13 -0000      1.12
+++ label-print-pdf.pl  19 Jul 2006 01:09:42 -0000      1.13
@@ -11,8 +11,8 @@
 
 # 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-dev/intranet/modules';
-use C4::Context("/etc/koha-opus-dev.conf");
+#use lib '/usr/local/hlt/intranet/modules';
+#use C4::Context("/etc/koha-hlt.conf");
 
 #use strict;
 use CGI;
@@ -26,6 +26,7 @@
 use PDF::Reuse;
 use PDF::Reuse::Barcode;
 use PDF::Report;
+use Data::Dumper;
 
 #use Acme::Comment;
 #use Data::Dumper;
@@ -40,9 +41,22 @@
 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';
+}
+
+warn $printingtype;
+warn $guidebox;
+
+
 #warn Dumper @resultsloop;
 
 # dimensions of gaylord paper
@@ -54,6 +68,9 @@
 #----------------------------------
 # 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");
 
@@ -76,18 +93,18 @@
 
 my $pageheight = 792;
 
-#warn "STARTROW = $startrow\n";
+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";
+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;
@@ -111,7 +128,7 @@
 
 my $i2 = 1;
 foreach $item (@resultsloop) {
-    if ( $i2 == 1 ) {
+    if ( $i2 == 1  && $guidebox  == 1) {
         draw_boundaries(
             $x_pos_spine, $x_pos_circ1,  $x_pos_circ2, $y_pos,
             $spine_width, $label_height, $circ_width
@@ -127,13 +144,14 @@
 
     $DB::single = 1;
 
-    #warn "COUNT=$i2, PBREAKCNT=$page_break_count, X,Y POS x=$x_pos_circ1, 
y=$y_pos";
-
+    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',
@@ -154,50 +172,60 @@
 }
 ############## end of 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
 
-$file = '/usr/local/opus-dev/intranet/htdocs/intranet-tmpl/barcodes/new.pdf';
+if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
 
-my $pdf = new PDF::Report( File => $file );
+    $file = "$htdocs_path/barcodes/new.pdf";
 
-# my $pdf = new PDF::Report(PageSize => "letter",
-#                                  PageOrientation => "Landscape");
+    my $pdf = new PDF::Report( File => $file );
 
-#$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";
-$pdf->setAlign('left');
-$pdf->setSize(11);
+    # my $pdf = new PDF::Report(PageSize => "letter",
+    #                                  PageOrientation => "Landscape");
 
-my $page_break_count = $startrow;
-#warn "INIT PAGEBREAK COUNT = $page_break_count";
+    #$pdf->newpage($nopage);
+    my $pagenumber = 1;
+    $pdf->openpage($pagenumber);
 
-#warn "#----------------------------------\n";
-#warn "INIT VPOS = $vPos, hPos = $hPos";
+    ( $pagewidth, $pageheight ) = $pdf->getPageDimensions();
 
-my $vPosSpacer     = 15;
-my $start_text_pos = 39;    # ( 36 - 5 = 31 ) 5 is an inside border for text.
-my $spine_label_text_with = 67;
+    #warn "PAGE DIM = $pagewidth, $pageheight";
+    #warn "Y START ROW = $y_pos_initial_startrow";
+    my $y_pos = ( $y_pos_initial_startrow + 90 );
 
-foreach $item (@resultsloop) {
+    #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
+        $pdf->setAddTextPos( $start_text_pos, ( $y_pos - 20 ) )
+          ;                    # INIT START POS
     ( $hPos, $vPos ) = $pdf->getAddTextPos();
 
     my $hPosEnd = ( $hPos + $spine_label_text_with );           # 72
@@ -215,7 +243,8 @@
 
     if ( $conf_data->{'class'} && $item->{'classification'} ) {
         ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-        $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'classification'} 
);
+            $pdf->centerString( $hPos, $hPosEnd, $vPos,
+                $item->{'classification'} );
         $vPos = $vPos - $vPosSpacer;
     }
 
@@ -247,13 +276,14 @@
 
     $page_break_count++;
     $i2++;
+
     #warn "#----------------------------------\n";
 
+    }
+    $DB::single = 1;
+    $pdf->saveAs($file);
 }
-$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.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- label-print.pl      11 Apr 2006 20:56:14 -0000      1.2
+++ label-print.pl      19 Jul 2006 01:09:42 -0000      1.3
@@ -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-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:09:42 -0000      1.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:09:42 -0000      1.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]