[Top][All Lists]
[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: |
Fri, 06 Oct 2006 01:51:47 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Mason James <sushi> 06/10/06 01:51:47
Modified files:
C4 : Labels.pm
Log message:
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.2&r2=1.3.4.3
Patches:
Index: Labels.pm
===================================================================
RCS file: /sources/koha/koha/C4/Labels.pm,v
retrieving revision 1.3.4.2
retrieving revision 1.3.4.3
diff -u -b -r1.3.4.2 -r1.3.4.3
--- Labels.pm 2 Oct 2006 22:04:30 -0000 1.3.4.2
+++ Labels.pm 6 Oct 2006 01:51:47 -0000 1.3.4.3
@@ -25,7 +25,6 @@
use PDF::Reuse;
use Text::Wrap;
-
$VERSION = 0.01;
=head1 NAME
@@ -47,8 +46,7 @@
&GetSingleLabelTemplate &SaveTemplate
&CreateTemplate &SetActiveTemplate
&SaveConf &DrawSpineText &GetTextWrapCols
- &GetUnitsValue
-
+ &GetUnitsValue &DrawBarcode
);
@@ -73,30 +71,31 @@
}
sub GetUnitsValue {
- my ($units) address@hidden;
+ my ($units) = @_;
my $unitvalue;
- $unitvalue = '1' if ($units eq 'POINT') ;
- $unitvalue = '2.83464567' if ($units eq 'MM') ;
- $unitvalue = '28.3464567' if ($units eq 'CM') ;
- $unitvalue = 72 if ($units eq 'INCH') ;
+ $unitvalue = '1' if ( $units eq 'POINT' );
+ $unitvalue = '2.83464567' if ( $units eq 'MM' );
+ $unitvalue = '28.3464567' if ( $units eq 'CM' );
+ $unitvalue = 72 if ( $units eq 'INCH' );
warn $units, $unitvalue;
return $unitvalue;
}
sub GetTextWrapCols {
- my ($fontsize, $label_width) = @_;
+ my ( $fontsize, $label_width ) = @_;
my $string = "0";
my $left_text_margin = 3;
- my ($strtmp, $strwidth);
- my $count = 0 ;
+ my ( $strtmp, $strwidth );
+ my $count = 0;
my $textlimit = $label_width - $left_text_margin;
- while ($strwidth < $textlimit ){
- $strwidth = prStrWidth($string,'C',$fontsize);
- $string = $string.'0';
+ while ( $strwidth < $textlimit ) {
+ $strwidth = prStrWidth( $string, 'C', $fontsize );
+ $string = $string . '0';
+
# warn "strwidth $strwidth, $textlimit, $string";
- $count++
+ $count++;
}
return $count;
}
@@ -124,9 +123,8 @@
sub SetActiveTemplate {
-
my ($tmpl_id) = @_;
-warn "TMPL_ID = $tmpl_id";
+ warn "TMPL_ID = $tmpl_id";
my $dbh = C4::Context->dbh;
my $query = " UPDATE labels_templates SET active = NULL";
my $sth = $dbh->prepare($query);
@@ -173,23 +171,20 @@
$tmpl_code, $tmpl_desc, $page_width, $page_height,
$label_width, $label_height, $topmargin, $leftmargin,
$cols, $rows, $colgap, $rowgap,
- $fontsize, $units,
- $tmpl_id
+ $fontsize, $units, $tmpl_id
);
$sth->finish;
- SetActiveTemplate($tmpl_id) if ($active eq '1');
+ SetActiveTemplate($tmpl_id) if ( $active eq '1' );
}
-
-
sub CreateTemplate {
my $tmpl_id;
my (
- $tmpl_code, $tmpl_desc, $page_width,
- $page_height, $label_width, $label_height, $topmargin,
- $leftmargin, $cols, $rows, $colgap,
- $rowgap, $active, $fontsize, $units
+ $tmpl_code, $tmpl_desc, $page_width, $page_height,
+ $label_width, $label_height, $topmargin, $leftmargin,
+ $cols, $rows, $colgap, $rowgap,
+ $active, $fontsize, $units
)
= @_;
@@ -208,11 +203,13 @@
$fontsize, $units
);
-warn "ACTIVE = $active";
+ warn "ACTIVE = $active";
+
+ if ( $active eq '1' ) {
- if ($active eq '1') {
# get the tmpl_id of the newly created template, then call
SetActiveTemplate()
- my $query = "SELECT tmpl_id from labels_templates order by tmpl_id desc
limit 1";
+ my $query =
+ "SELECT tmpl_id from labels_templates order by tmpl_id desc limit 1";
my $sth = $dbh->prepare($query);
$sth->execute();
@@ -225,8 +222,6 @@
return $tmpl_id;
}
-
-
sub GetAllLabelTemplates {
my $dbh = C4::Context->dbh;
@@ -245,13 +240,15 @@
return @resultsloop;
}
-
sub SaveConf {
- my ($barcodetype, $title, $isbn, $itemtype,
+ my (
+ $barcodetype, $title, $isbn, $itemtype,
$bcn, $dcn, $classif, $subclass,
$itemcallnumber, $author, $tmpl_id, $printingtype,
- $guidebox, $startlabel) = @_;
+ $guidebox, $startlabel
+ )
+ = @_;
my $dbh = C4::Context->dbh;
my $query2 = "DELETE FROM labels_conf";
@@ -266,8 +263,8 @@
$sth2->execute(
$barcodetype, $title, $isbn, $itemtype,
$bcn, $dcn, $classif, $subclass,
- $itemcallnumber, $author, $printingtype,
- $guidebox, $startlabel
+ $itemcallnumber, $author, $printingtype, $guidebox,
+ $startlabel
);
$sth2->finish;
@@ -275,8 +272,6 @@
return;
}
-
-
=item get_label_items;
$options = get_label_items()
@@ -319,23 +314,18 @@
return @resultsloop;
}
-
sub DrawSpineText {
- my (
- $y_pos, $label_height, $fontsize,
- $x_pos, $left_text_margin, $text_wrap_cols,
- $item, $conf_data
- )
+ my ( $y_pos, $label_height, $fontsize, $x_pos, $left_text_margin,
+ $text_wrap_cols, $item, $conf_data )
= @_;
-$Text::Wrap::columns = $text_wrap_cols;
-$Text::Wrap::separator = "\n";
-
+ $Text::Wrap::columns = $text_wrap_cols;
+ $Text::Wrap::separator = "\n";
my $str;
- my $top_text_margin = ($fontsize + 3);
+ my $top_text_margin = ( $fontsize + 3 );
my $line_spacer = ($fontsize); # number of pixels between
text rows.
# add your printable fields manually in here
@@ -343,16 +333,17 @@
qw (dewey isbn classification itemtype subclass itemcallnumber);
my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
my $hPos = ( $x_pos + $left_text_margin );
+
# warn Dumper $conf_data;
#warn Dumper $item;
-
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"} ) {
-# warn "CONF_TYPE = $field";
+ # warn "CONF_TYPE = $field";
# get the string
$str = $$item->{"$field"};
@@ -381,19 +372,77 @@
} #foreach feild
}
+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 $tot_bar_length;
+ my $bar_length;
+ my $guard_length =10;
+ my $xsize_ratio;
+
+ if ( $barcodetype eq 'Code39' ) {
+ $bar_length = '14.4333333333333';
+ $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,
+ );
+ };
+ if ($@) {
+ warn "$barcodetype, $barcode FAILED:$@";
+ }
+ }
+ elsif ( $barcodetype eq 'COOP2of5' ) {
+ $bar_length = '9.43333333333333';
+ $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length *
2 );
+ $xsize_ratio = ( $bar_width / $tot_bar_length )*.9;
+ eval {
+ PDF::Reuse::Barcode::COOP2of5(
+ x => ( $x_pos + ( $width / 10 ) ),
+ y => ( $y_pos + ( $height / 10 ) ),
+ value => $barcode,
+ ySize => ( .02 * $height ),
+ xSize => $xsize_ratio,
+ );
+ };
+ if ($@) {
+ warn "$barcodetype, $barcode FAILED:$@";
+ }
+ }
+ elsif( $barcodetype eq 'Industrial2of5' ) {
+ $bar_length = '13.1333333333333';
+ $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length *
2 );
+ $xsize_ratio = ( $bar_width / $tot_bar_length ) *.9;
+ eval {
+ PDF::Reuse::Barcode::Industrial2of5(
+ x => ( $x_pos + ( $width / 10 ) ),
+ y => ( $y_pos + ( $height / 10 ) ),
+ value => $barcode,
+ ySize => ( .02 * $height ),
+ xSize => $xsize_ratio,
+ );
+ };
+ if ($@) {
+ warn "$barcodetype, $barcode FAILED:$@";
+ }
+ }
+my $moo2 = $tot_bar_length * $xsize_ratio;
-
-
-
-
-
-
-
+ warn " $x_pos, $y_pos, $barcode, $barcodetype\n";
+ warn "BAR_WDTH = $bar_width, TOT.BAR.LGHT=$tot_bar_length R*TOT.BAR
=$moo2 \n";
+}
=item build_circ_barcode;
@@ -742,7 +791,7 @@
#'
sub drawbox {
my ( $llx, $lly, $urx, $ury ) = @_;
-warn "llx,y= $llx,$lly , urx,y=$urx,$ury \n";
+# warn "llx,y= $llx,$lly , urx,y=$urx,$ury \n";
my $str = "q\n"; # save the graphic state
$str .= "0.5 w\n"; # border color red