koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/barcodes label-print-pdf-demco-142-1685c.pl [dev_week]


From: Mason James
Subject: [Koha-cvs] koha/barcodes label-print-pdf-demco-142-1685c.pl [dev_week]
Date: Tue, 28 Aug 2007 23:04:24 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Mason James <sushi>     07/08/28 23:04:24

Added files:
        barcodes       : label-print-pdf-demco-142-1685c.pl 

Log message:
        hardcoded pdf template for demco_142-1685_C label sheet.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf-demco-142-1685c.pl?cvsroot=koha&only_with_tag=dev_week&rev=1.1.2.1

Patches:
Index: label-print-pdf-demco-142-1685c.pl
===================================================================
RCS file: label-print-pdf-demco-142-1685c.pl
diff -N label-print-pdf-demco-142-1685c.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ label-print-pdf-demco-142-1685c.pl  28 Aug 2007 23:04:24 -0000      1.1.2.1
@@ -0,0 +1,260 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Labels;
+use C4::Auth;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use HTML::Template;
+use PDF::Reuse;
+use PDF::Reuse::Barcode;
+use POSIX;
+
+use Smart::Comments;
+
+my $htdocs_path = C4::Context->config('intrahtdocs');
+my $cgi         = new CGI;
+print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' );
+
+my $spine_text = "";
+
+# get the printing settings
+my $template  = GetActiveLabelTemplate();
+my $conf_data = get_label_options();
+
+my $batch_id    = $cgi->param('batch_id');
+my @resultsloop = get_label_items($batch_id);
+
+my $barcodetype  = $conf_data->{'barcodetype'};
+my $printingtype = $conf_data->{'printingtype'};
+my $guidebox     = $conf_data->{'guidebox'};
+my $start_label  = $conf_data->{'startlabel'};
+
+my $fontsize = $template->{'fontsize'};
+my $units    = $template->{'units'};
+
+my $unitvalue = GetUnitsValue($units);
+
+my $tmpl_code = $template->{'tmpl_code'};
+my $tmpl_desc = $template->{'tmpl_desc'};
+
+my $page_height = 792;
+my $page_width  = 612;
+
+my $block_height = 144;
+my $block_width  = 272;
+
+my $label_height = 72;
+my $label_width  = 196;
+
+my $spine_width  = 65;
+my $spine_height = 108;
+
+my $top_margin  = 41;
+my $left_margin = 27;
+my $colspace    = 12;
+my $rowspace    = 0;
+
+my $block_cols = 2;
+my $block_rows = 5;
+
+#warn $label_cols, $label_rows;
+
+# set the paper size
+my $lowerLeftX  = 0;
+my $lowerLeftY  = 0;
+my $upperRightX = $page_width;
+my $upperRightY = $page_height;
+
+prInitVars();
+$| = 1;
+prFile();
+
+prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
+
+# later feature, change the font-type and size?
+prFont('C');    # Just setting a font
+prFontSize($fontsize);
+
+my $margin           = $top_margin;
+my $left_text_margin = 3;
+my $str;
+
+my $item;
+my ( $i, $i2 );    # loop counters
+
+# big row loop
+
+#warn " $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY";
+#warn "$label_rows, $label_cols\n";
+#warn "$label_height, $label_width\n";
+#warn "$page_height, $page_width\n";
+
+my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp );
+
+$start_label = 1;    ## debug...................................
+
+if ( $start_label eq 1 ) {
+    $rowcount = 1;
+    $colcount = 1;
+    $x_pos    = $left_margin;
+    $y_pos    = ( $page_height - $top_margin - $block_height );
+}
+
+else {
+
+    #eval {
+    $rowcount = ceil( $start_label / $block_cols );
+
+    #} ;
+    #$rowcount = 1 if $@;
+
+    $colcount = ( $start_label - ( ( $rowcount - 1 ) * $block_cols ) );
+
+    $x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) +
+      ( $colspace * ( $colcount - 1 ) );
+
+    $y_pos = $page_height - $top_margin - ( $block_height * $rowcount ) -
+      ( $rowspace * ( $rowcount - 1 ) );
+
+}
+
+#
+#    main foreach loop
+#
+
+# $barcodetype = "CODE39MOD10";
+
+my $gutter = 2;
+
+foreach $item (@resultsloop) {
+    my $barcode = $item->{'barcode'};
+    $item->{'callnumber'} = 'BT 380.2 W54';
+    my @callnumber = split( / /, $item->{'callnumber'} );
+
+    my @spine_fields = (
+        $item->{'ccode'}, $callnumber[0], $callnumber[1], $callnumber[2],
+        $item->{'copyrightdate'}
+    );
+
+    my @circ_fields = (
+        $item->{'ccode'}, $callnumber[0], $callnumber[1], $callnumber[2],
+        $item->{'copyrightdate'}
+    );
+
+    my @circ2_fields = ( $item->{'author'}, $item->{'title'} );
+
+    my @circ_barcode = ( $item->{'barcode'} );
+
+    my $fontsize = 10;
+
+    #    warn "$x_pos, $y_pos, $label_width, $label_height";
+    my $barcode = $item->{'barcode'};
+
+#    drawbox( $x_pos, $y_pos, $block_width, $block_height, ) if $guidebox;
+
+    #-- spine
+    drawbox( $x_pos, $y_pos + ( $block_height - $spine_height ),
+        $spine_width, $spine_height, )
+      if $guidebox;
+
+    draw_text_block_manual2(    # spine
+        $x_pos, $y_pos + ( $block_height - $spine_height ), $spine_width,
+        $spine_height, $fontsize, '', $gutter, 'l',
+        @spine_fields
+    );
+
+    #-- spine
+
+    #-- top barc
+    drawbox(
+        ( $x_pos + $spine_width + $colspace ),
+        $y_pos + $label_height,
+        $label_width, $label_height,
+    ) if $guidebox;
+    draw_text_block_manual2(
+        ( $x_pos + $spine_width + $colspace ),
+        ( $y_pos + $label_height ),
+        $label_width, $label_height, $fontsize, '', $gutter, 'r', @circ_barcode
+    );
+
+    draw_text_block_manual2(
+        ( $x_pos + $spine_width + $colspace ),
+        ( $y_pos + $label_height ),
+        $label_width, $label_height, $fontsize, '', $gutter,, '', @circ_fields
+    );
+
+    draw_text_block_manual2(
+        ( $x_pos + $spine_width + $colspace + $spine_width ),
+        ( $y_pos + $label_height ),
+        ($label_width - $spine_width),
+        $label_height,
+        $fontsize,
+        2,
+        $gutter,
+        'l',
+        @circ2_fields
+    );
+
+    #-- top barc
+
+    #-- bottom barc
+    drawbox( ( $x_pos + $spine_width + $colspace ),
+        $y_pos, $label_width, $label_height, )
+      if $guidebox;
+    draw_text_block_manual2( ( $x_pos + $spine_width + $colspace ),
+        $y_pos, $label_width, $label_height, $fontsize, '', $gutter, 'r',
+        @circ_barcode );
+
+    draw_text_block_manual2( ( $x_pos + $spine_width + $colspace ),
+        $y_pos, $label_width, $label_height, $fontsize, '', $gutter,, '',
+        @circ_fields );
+
+    draw_text_block_manual2(
+        ( $x_pos + $spine_width + $colspace + $spine_width ),
+        $y_pos,   ($label_width - $spine_width),  $label_height, $fontsize, 2, 
$gutter, 'l',
+        @circ2_fields );
+
+    #-- bottom barc
+
+    #calc_next_block_position();
+    CalcNextLabelPos();
+
+    #    last;
+}    # end for item loop
+prEnd();
+
+#
+#
+#
+#
+#
+sub CalcNextLabelPos {
+    if ( $colcount lt $block_cols ) {
+
+        #        warn "new col";
+        $x_pos = ( $x_pos + $block_width + $colspace );
+        $colcount++;
+    }
+
+    else {
+        $x_pos = $left_margin;
+        if ( $rowcount eq $block_rows ) {
+
+            #            warn "new page";
+            prPage();
+            $y_pos    = ( $page_height - $top_margin - $block_height );
+            $rowcount = 1;
+        }
+        else {
+
+            #            warn "new row";
+            $y_pos = ( $y_pos - $rowspace - $block_height );
+            $rowcount++;
+        }
+        $colcount = 1;
+    }
+}
+




reply via email to

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