koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/C4 Labels.pm [dev_week]


From: Mason James
Subject: [Koha-cvs] koha/C4 Labels.pm [dev_week]
Date: Thu, 22 Mar 2007 03:33:16 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Mason James <sushi>     07/03/22 03:33:16

Modified files:
        C4             : Labels.pm 

Log message:
        new code to calc modulo43 checksum for code39 barcodes too. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.7&r2=1.3.4.8

Patches:
Index: Labels.pm
===================================================================
RCS file: /sources/koha/koha/C4/Labels.pm,v
retrieving revision 1.3.4.7
retrieving revision 1.3.4.8
diff -u -b -r1.3.4.7 -r1.3.4.8
--- Labels.pm   4 Dec 2006 03:10:58 -0000       1.3.4.7
+++ Labels.pm   22 Mar 2007 03:33:16 -0000      1.3.4.8
@@ -21,9 +21,11 @@
 require Exporter;
 
 use vars qw($VERSION @ISA @EXPORT);
-use Data::Dumper;
+
+#use Data::Dumper;
 use PDF::Reuse;
 use Text::Wrap;
+use Algorithm::CheckDigits;
 
 $VERSION = 0.01;
 
@@ -156,7 +158,8 @@
       = @_;
 
     warn "FONTSIZE =$fontsize";
-    warn Dumper @_;
+
+    #    warn Dumper @_;
 
     my $dbh   = C4::Context->dbh;
     my $query =
@@ -375,16 +378,40 @@
 sub DrawBarcode {
 
     my ( $x_pos, $y_pos, $height, $width, $barcode, $barcodetype ) = @_;
-    $barcode = '123456789';
     my $num_of_bars = length($barcode);
-    my $bar_width = ( ( $width / 10 ) * 8 );    # %80 of lenght of label width
+    my $bar_width   = $width * .8;        # %80 of length of label width
     my $tot_bar_length;
     my $bar_length;
     my $guard_length = 10;
     my $xsize_ratio;
 
     if ( $barcodetype eq 'Code39' ) {
-        $bar_length     = '14.4333333333333';
+        $bar_length     = '17.5';
+        $tot_bar_length =
+          ( $bar_length * $num_of_bars ) + ( $guard_length * 2 );
+        $xsize_ratio = ( $bar_width / $tot_bar_length );
+        eval {
+            PDF::Reuse::Barcode::Code39(
+                x => ( $x_pos + ( $width / 10 ) ),
+                y => ( $y_pos + ( $height / 10 ) ),
+                value         => "*$barcode*",
+                ySize         => ( .02 * $height ),
+                xSize         => $xsize_ratio,
+                hide_asterisk => 1,
+            );
+        };
+        if ($@) {
+            warn "$barcodetype, $barcode FAILED:$@";
+        }
+    }
+
+    elsif ( $barcodetype eq 'Code39sum' ) {
+
+        # get modulo43 checksum
+        my $c39 = CheckDigits('code_39');
+        $barcode = $c39->complete($barcode);
+
+        $bar_length     = '19';
         $tot_bar_length =
           ( $bar_length * $num_of_bars ) + ( $guard_length * 2 );
         $xsize_ratio = ( $bar_width / $tot_bar_length );
@@ -395,9 +422,10 @@
                 value => "*$barcode*",
                 ySize => ( .02 * $height ),
                 xSize => $xsize_ratio,
-                hide_asterisk => $xsize_ratio,
+                hide_asterisk => 1,
             );
         };
+
         if ($@) {
             warn "$barcodetype, $barcode FAILED:$@";
         }
@@ -440,6 +468,7 @@
             warn "$barcodetype, $barcode FAILED:$@";
         }
     }
+
     my $moo2 = $tot_bar_length * $xsize_ratio;
 
     warn " $x_pos, $y_pos, $barcode, $barcodetype\n";
@@ -505,11 +534,12 @@
             PDF::Reuse::Barcode::Code39(
                 x     => ( $x_pos_circ + 9 ),
                 y     => ( $y_pos + 15 ),
+                value => $value,
+
                 #           prolong => 2.96,
                 xSize => .85,
+
                 ySize => 1.3,
-                               value => "*$value*",
-                               hide_asterisk => $xsize_ratio,
             );
         };
         if ($@) {




reply via email to

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