From szrj1m at yahoo.com Tue Jan 22 00:59:11 2008 From: szrj1m at yahoo.com (Mason James) Date: Mon, 21 Jan 2008 23:59:11 +0000 Subject: [Koha-cvs] koha/barcodes label-print-csv.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/21 23:59:11 Added files: barcodes : label-print-csv.pl Log message: script to generate csv output of barcodes, to be used with 3rd-party barcode apps. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-csv.pl?cvsroot=koha&only_with_tag=dev_week&rev=1.1.2.1 Patches: Index: label-print-csv.pl =================================================================== RCS file: label-print-csv.pl diff -N label-print-csv.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ label-print-csv.pl 21 Jan 2008 23:59:11 -0000 1.1.2.1 @@ -0,0 +1,84 @@ +#!/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 POSIX; + +use Text::CSV_XS; + +#use Smart::Comments '###'; + +my $htdocs_path = C4::Context->config('intrahtdocs'); +my $cgi = new CGI; + +print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.csv' ); + +# get the printing settings +my $template = GetActiveLabelTemplate(); +my $conf_data = get_label_options(); + +#my $batch_id = $cgi->param('batch_id'); +my $batch_id = 1; +##### $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 $fontsize = 6; + +my $units = $template->{'units'}; + +my $unitvalue = GetUnitsValue($units); + +my $tmpl_code = $template->{'tmpl_code'}; +my $tmpl_desc = $template->{'tmpl_desc'}; + +my $batch_count = get_batch_count($batch_id); + +my $margin = $top_margin; +my $str; +my $item; +my ( $i, $i2 ); # loop counters + +# +# main foreach loop +# + +my $csv = Text::CSV_XS->new( { eol => "\n", } ); + +my @fields = qw ( itemcallnumber replacementpricedate homebranch + callnum_author title barcode_homebranch media.number date_acquired library_name); + +my $status = $csv->print( $cgi, \@fields ); + +foreach $item (@resultsloop) { + + my $callnum_author = $item->{'itemcallnumber'} . ' ' . $item->{'author'}; + + my @fields = ( + $item->{'itemcallnumber'}, + $item->{'replacementpricedate'}, + $item->{'homebranch'}, + $callnum_author, + $item->{'title'}, + "$item->{'barcode'} $item->{'homebranch'}", + '530a', + '952b', + 'Athens County Public Library' + ); + + my $status = $csv->print( $cgi, \@fields ); + +} + From szrj1m at yahoo.com Tue Jan 22 01:17:02 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 22 Jan 2008 00:17:02 +0000 Subject: [Koha-cvs] koha/barcodes label-print-csv.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/22 00:17:02 Modified files: barcodes : label-print-csv.pl Log message: typo CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-csv.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2 Patches: Index: label-print-csv.pl =================================================================== RCS file: /sources/koha/koha/barcodes/Attic/label-print-csv.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-csv.pl 21 Jan 2008 23:59:11 -0000 1.1.2.1 +++ label-print-csv.pl 22 Jan 2008 00:17:01 -0000 1.1.2.2 @@ -46,7 +46,6 @@ my $batch_count = get_batch_count($batch_id); -my $margin = $top_margin; my $str; my $item; my ( $i, $i2 ); # loop counters @@ -57,8 +56,8 @@ my $csv = Text::CSV_XS->new( { eol => "\n", } ); -my @fields = qw ( itemcallnumber replacementpricedate homebranch - callnum_author title barcode_homebranch media.number date_acquired library_name); +my @fields = qw ( itemcallnumber author title replacementpricedate homebranch + location barcode date_acquired media_number library_name); my $status = $csv->print( $cgi, \@fields ); @@ -68,13 +67,16 @@ my @fields = ( $item->{'itemcallnumber'}, + $item->{'author'}, + $item->{'title'}, $item->{'replacementpricedate'}, + $item->{'homebranch'}, - $callnum_author, - $item->{'title'}, - "$item->{'barcode'} $item->{'homebranch'}", - '530a', - '952b', + $item->{'location'}, + + $item->{'barcode'}, + '2001-12-28', + '2 DISKS', 'Athens County Public Library' ); From szrj1m at yahoo.com Tue Jan 22 01:32:49 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 22 Jan 2008 00:32:49 +0000 Subject: [Koha-cvs] koha/barcodes label-print-csv.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/22 00:32:49 Modified files: barcodes : label-print-csv.pl Log message: uncommenting $batch_id CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-csv.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.2&r2=1.1.2.3 Patches: Index: label-print-csv.pl =================================================================== RCS file: /sources/koha/koha/barcodes/Attic/label-print-csv.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-csv.pl 22 Jan 2008 00:17:01 -0000 1.1.2.2 +++ label-print-csv.pl 22 Jan 2008 00:32:49 -0000 1.1.2.3 @@ -12,7 +12,7 @@ use Text::CSV_XS; -#use Smart::Comments '###'; +use Smart::Comments '###'; my $htdocs_path = C4::Context->config('intrahtdocs'); my $cgi = new CGI; @@ -23,9 +23,8 @@ my $template = GetActiveLabelTemplate(); my $conf_data = get_label_options(); -#my $batch_id = $cgi->param('batch_id'); -my $batch_id = 1; -##### $batch_id; +my $batch_id = $cgi->param('batch_id'); +### $batch_id; my @resultsloop = get_label_items($batch_id); From szrj1m at yahoo.com Tue Jan 22 01:33:53 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 22 Jan 2008 00:33:53 +0000 Subject: [Koha-cvs] koha/barcodes label-print-select-pdf.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/22 00:33:53 Modified files: barcodes : label-print-select-pdf.pl Log message: adding block for output_to_csv CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-select-pdf.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.5&r2=1.1.2.6 Patches: Index: label-print-select-pdf.pl =================================================================== RCS file: /sources/koha/koha/barcodes/Attic/label-print-select-pdf.pl,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -b -r1.1.2.5 -r1.1.2.6 --- label-print-select-pdf.pl 19 Oct 2007 07:43:18 -0000 1.1.2.5 +++ label-print-select-pdf.pl 22 Jan 2008 00:33:53 -0000 1.1.2.6 @@ -26,12 +26,11 @@ "/cgi-bin/koha/barcodes/label-print-pdf-demco-142-1685c.pl?batch_id=$batch_id"); } -elsif ( $template->{'tmpl_code'} eq 'ZEBRA_2844' ) { -#### ZEB - print $cgi->redirect( - "/cgi-bin/koha/barcodes/label-print-pdf-zebra-2844.pl?batch_id=$batch_id"); +elsif ( $template->{'tmpl_code'} eq 'OUTPUT_TO_CSV' ) { + print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-csv.pl?batch_id=$batch_id"); } + else { print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-pdf.pl?batch_id=$batch_id"); } From szrj1m at yahoo.com Tue Jan 29 05:31:47 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 29 Jan 2008 04:31:47 +0000 Subject: [Koha-cvs] koha/barcodes label-print-pdf-demco-142-1685c.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/29 04:31:47 Modified files: barcodes : label-print-pdf-demco-142-1685c.pl Log message: seperating 2 char LOC-class values to seperate line. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf-demco-142-1685c.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.5&r2=1.1.2.6 Patches: Index: label-print-pdf-demco-142-1685c.pl =================================================================== RCS file: /sources/koha/koha/barcodes/Attic/label-print-pdf-demco-142-1685c.pl,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -b -r1.1.2.5 -r1.1.2.6 --- label-print-pdf-demco-142-1685c.pl 17 Dec 2007 01:05:13 -0000 1.1.2.5 +++ label-print-pdf-demco-142-1685c.pl 29 Jan 2008 04:31:46 -0000 1.1.2.6 @@ -96,7 +96,6 @@ my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp ); - #-- calculate x,y coords of 1st label if ( $start_label eq 1 ) { $rowcount = 1; @@ -115,7 +114,8 @@ $colcount = ( $start_label - ( ( $rowcount - 1 ) * $block_cols ) ); - $x_pos = $left_margin + ( ($spine_width + $colspace + $label_width) * ( $colcount - 1 ) ) + + $x_pos = $left_margin + + ( ( $spine_width + $colspace + $label_width ) * ( $colcount - 1 ) ) + ( $colspace * ( $colcount - 1 ) ); $y_pos = $page_height - $top_margin - ( $block_height * $rowcount ) - @@ -126,36 +126,38 @@ $x_pos-- if $colcount == 2; } - # # main foreach loop # -# $barcodetype = "CODE39MOD10"; - my $gutter = 2; my $i; foreach $item (@resultsloop) { my $barcode = $item->{'barcode'}; - $item->{'callnumber'} = $item->{'classification'} ." ".$item->{'subclass'}; - my @callnumber = split( / /, $item->{'callnumber'} ); + $item->{'callnumber'} = + $item->{'classification'} . " " . $item->{'subclass'}; + + my @callnumber; + my $loc_class = substr( $item->{'callnumber'}, 0, 2 ); + my @callnumber = split( / /, substr( $item->{'callnumber'}, 2 ) ); my @spine_fields = ( - $item->{'ccode'}, $callnumber[0], $callnumber[1], $callnumber[2] + $item->{'ccode'}, $loc_class, $callnumber[0], + $callnumber[1], $callnumber[2] ); my @circ_fields = ( - $item->{'ccode'}, $callnumber[0], $callnumber[1], $callnumber[2] + $item->{'ccode'}, $loc_class, $callnumber[0], + $callnumber[1], $callnumber[2] ); my @circ2_fields = ( $item->{'author'}, $item->{'title'} ); - my @circ_barcode = ( $item->{'barcode'} ); my $fontsize = 10; - warn "$x_pos, $y_pos, $label_width, $label_height"; + # warn "$x_pos, $y_pos, $label_width, $label_height"; my $barcode = $item->{'barcode'}; # drawbox( $x_pos, $y_pos, $block_width, $block_height, ) if $guidebox; From szrj1m at yahoo.com Tue Jan 29 06:06:08 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 29 Jan 2008 05:06:08 +0000 Subject: [Koha-cvs] koha/barcodes label-print-pdf-demco-142-1685c.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/29 05:06:08 Modified files: barcodes : label-print-pdf-demco-142-1685c.pl Log message: using newer split_lccn() to handle call number splits. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf-demco-142-1685c.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.6&r2=1.1.2.7 Patches: Index: label-print-pdf-demco-142-1685c.pl =================================================================== RCS file: /sources/koha/koha/barcodes/Attic/label-print-pdf-demco-142-1685c.pl,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -b -r1.1.2.6 -r1.1.2.7 --- label-print-pdf-demco-142-1685c.pl 29 Jan 2008 04:31:46 -0000 1.1.2.6 +++ label-print-pdf-demco-142-1685c.pl 29 Jan 2008 05:06:08 -0000 1.1.2.7 @@ -138,18 +138,16 @@ $item->{'callnumber'} = $item->{'classification'} . " " . $item->{'subclass'}; - my @callnumber; - my $loc_class = substr( $item->{'callnumber'}, 0, 2 ); - my @callnumber = split( / /, substr( $item->{'callnumber'}, 2 ) ); + my @callnumber = split_lccn( $item->{'callnumber'} ); my @spine_fields = ( - $item->{'ccode'}, $loc_class, $callnumber[0], - $callnumber[1], $callnumber[2] + $item->{'ccode'}, $callnumber[0], $callnumber[1], + $callnumber[2], $callnumber[3] ); my @circ_fields = ( - $item->{'ccode'}, $loc_class, $callnumber[0], - $callnumber[1], $callnumber[2] + $item->{'ccode'}, $callnumber[0], $callnumber[1], + $callnumber[2], $callnumber[3] ); my @circ2_fields = ( $item->{'author'}, $item->{'title'} ); From szrj1m at yahoo.com Tue Jan 29 06:08:09 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 29 Jan 2008 05:08:09 +0000 Subject: [Koha-cvs] koha/C4 Labels.pm [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/29 05:08:09 Modified files: C4 : Labels.pm Log message: better regexs in split_lccn(). CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.56&r2=1.3.4.57 Patches: Index: Labels.pm =================================================================== RCS file: /sources/koha/koha/C4/Labels.pm,v retrieving revision 1.3.4.56 retrieving revision 1.3.4.57 diff -u -b -r1.3.4.56 -r1.3.4.57 --- Labels.pm 22 Oct 2007 05:02:33 -0000 1.3.4.56 +++ Labels.pm 29 Jan 2008 05:08:09 -0000 1.3.4.57 @@ -27,7 +27,7 @@ use Algorithm::CheckDigits; # use Data::Dumper; - use Smart::Comments '###'; +# use Smart::Comments '###'; $VERSION = 0.01; @@ -113,12 +113,11 @@ sub split_lccn { my ($lccn) = @_; my ( $ll, $wnl, $dec, $cutter, $pubdate); - $_ = $lccn; # lccn example 'HE8700.7 .P6T44 1983'; my @splits = m/ - ([a-zA-Z]+\s*) # HE (with spaces) + (^[a-zA-Z]{2}) # 'HE' ([0-9]+\.*[0-9]+\s*) # 8700.7 or 8700 without '.', # handles trailing space too (\.[a-zA-Z0-9]+\s*) #.P6T44 @@ -132,7 +131,7 @@ # if the regex fails, then just return the whole string, # better than nothing -$splits[0] = $lccn if $splits[0] eq '' ; + $splits[0] = $lccn if $splits[0] eq '' ; return @splits; } @@ -869,7 +868,7 @@ $hPos = $x_pos + $label_width - ( $gutter + $strwidth ); } - warn "HPOS , VPOS $hPos, $vPos\n"; + # warn "HPOS , VPOS $hPos, $vPos\n"; # set the font size A # $str =~ s/^\*$/ /; From szrj1m at yahoo.com Tue Jan 29 21:58:10 2008 From: szrj1m at yahoo.com (Mason James) Date: Tue, 29 Jan 2008 20:58:10 +0000 Subject: [Koha-cvs] koha/C4 Labels.pm [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/29 20:58:10 Modified files: C4 : Labels.pm Log message: better regex for LOC-class in split_lccn(). CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.57&r2=1.3.4.58 Patches: Index: Labels.pm =================================================================== RCS file: /sources/koha/koha/C4/Labels.pm,v retrieving revision 1.3.4.57 retrieving revision 1.3.4.58 diff -u -b -r1.3.4.57 -r1.3.4.58 --- Labels.pm 29 Jan 2008 05:08:09 -0000 1.3.4.57 +++ Labels.pm 29 Jan 2008 20:58:09 -0000 1.3.4.58 @@ -117,7 +117,7 @@ # lccn example 'HE8700.7 .P6T44 1983'; my @splits = m/ - (^[a-zA-Z]{2}) # 'HE' + ([a-zA-Z]+) ([0-9]+\.*[0-9]+\s*) # 8700.7 or 8700 without '.', # handles trailing space too (\.[a-zA-Z0-9]+\s*) #.P6T44 From szrj1m at yahoo.com Wed Jan 30 01:43:39 2008 From: szrj1m at yahoo.com (Mason James) Date: Wed, 30 Jan 2008 00:43:39 +0000 Subject: [Koha-cvs] koha/barcodes label-print-csv.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/30 00:43:39 Modified files: barcodes : label-print-csv.pl Log message: removing unneeded 'location' field. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-csv.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.3&r2=1.1.2.4 Patches: Index: label-print-csv.pl =================================================================== RCS file: /sources/koha/koha/barcodes/Attic/label-print-csv.pl,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -b -r1.1.2.3 -r1.1.2.4 --- label-print-csv.pl 22 Jan 2008 00:32:49 -0000 1.1.2.3 +++ label-print-csv.pl 30 Jan 2008 00:43:38 -0000 1.1.2.4 @@ -56,7 +56,7 @@ my $csv = Text::CSV_XS->new( { eol => "\n", } ); my @fields = qw ( itemcallnumber author title replacementpricedate homebranch - location barcode date_acquired media_number library_name); + barcode date_acquired media_number library_name); my $status = $csv->print( $cgi, \@fields ); @@ -71,7 +71,6 @@ $item->{'replacementpricedate'}, $item->{'homebranch'}, - $item->{'location'}, $item->{'barcode'}, '2001-12-28', From szrj1m at yahoo.com Thu Jan 31 00:37:33 2008 From: szrj1m at yahoo.com (Mason James) Date: Wed, 30 Jan 2008 23:37:33 +0000 Subject: [Koha-cvs] koha/C4 Labels.pm [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Mason James 08/01/30 23:37:33 Modified files: C4 : Labels.pm Log message: split_lccn() better regex again. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.58&r2=1.3.4.59 Patches: Index: Labels.pm =================================================================== RCS file: /sources/koha/koha/C4/Labels.pm,v retrieving revision 1.3.4.58 retrieving revision 1.3.4.59 diff -u -b -r1.3.4.58 -r1.3.4.59 --- Labels.pm 29 Jan 2008 20:58:09 -0000 1.3.4.58 +++ Labels.pm 30 Jan 2008 23:37:33 -0000 1.3.4.59 @@ -27,7 +27,7 @@ use Algorithm::CheckDigits; # use Data::Dumper; -# use Smart::Comments '###'; +# use Smart::Comments '#####'; $VERSION = 0.01; @@ -113,17 +113,21 @@ sub split_lccn { my ($lccn) = @_; my ( $ll, $wnl, $dec, $cutter, $pubdate); + $_ = $lccn; # lccn example 'HE8700.7 .P6T44 1983'; my @splits = m/ - ([a-zA-Z]+) - ([0-9]+\.*[0-9]+\s*) # 8700.7 or 8700 without '.', - # handles trailing space too - (\.[a-zA-Z0-9]+\s*) #.P6T44 - ([0-9]+) # 1983 + (^[a-zA-Z]+) # HE + ([0-9]+\.*[0-9]*) # 8700.7 + \s* + (\.*[a-zA-Z0-9]*) # P6T44 + \s* + ([0-9]*) # 1983 /x; +##### @splits + # strip something occuring spaces too $splits[0] =~ s/\s+$//; $splits[1] =~ s/\s+$//;