From 6e2564450e93fc0b2fd66c71d6c3c128a3099ccd Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Fri, 17 Aug 2007 18:47:26 -0500 Subject: [PATCH] Adding labels generator. Signed-off-by: Joshua Ferraro Signed-off-by: Chris Cormack --- C4/Labels.pm | 638 ++++++++++++++---- barcodes/barcodes.pl | 161 ----- barcodes/barcodesGenerator.pl | 373 ---------- barcodes/label-home.pl | 78 --- barcodes/label-manager.pl | 154 ----- barcodes/label-print-opus-pdf.pl | 189 ------ barcodes/label-print.pl | 135 ---- barcodes/pdfViewer.pl | 40 -- barcodes/printerConfig.pl | 128 ---- barcodes/test.textblock.pl | 33 - installer/kohastructure.sql | 1 + .../prog/en/barcodes/barcodes.tmpl | 85 --- .../en/barcodes/label-create-template.tmpl | 69 -- .../prog/en/barcodes/label-home.tmpl | 189 ------ .../prog/en/barcodes/label-manager.tmpl | 60 -- .../prog/en/barcodes/label-templates.tmpl | 52 -- .../prog/en/barcodes/printerConfig.tmpl | 88 --- .../prog/en/barcodes/search.tmpl | 60 -- .../prog/en/includes/label-status.inc | 7 + .../prog/en/includes/menu-labels.inc | 8 + .../label-bib-search.tmpl | 4 +- .../prog/en/labels/label-create-layout.tmpl | 281 ++++++++ .../prog/en/labels/label-create-template.tmpl | 64 ++ .../prog/en/labels/label-edit-layout.tmpl | 182 +++++ .../label-edit-template.tmpl | 46 +- .../prog/en/labels/label-home.tmpl | 57 ++ .../prog/en/labels/label-manager.tmpl | 111 +++ .../en/{barcodes => labels}/label-print.tmpl | 0 .../prog/en/labels/label-templates.tmpl | 57 ++ .../prog/en/{barcodes => labels}/result.tmpl | 91 ++- .../intranet-tmpl/prog/en/labels/search.tmpl | 128 ++++ .../prog/en/tools/tools-home.tmpl | 4 + labels/label-create-layout.pl | 84 +++ labels/label-create-template.pl | 85 +++ labels/label-edit-layout.pl | 87 +++ labels/label-edit-template.pl | 80 +++ labels/label-home.pl | 95 +++ {barcodes => labels}/label-item-search.pl | 159 +++-- labels/label-manager.pl | 195 ++++++ {barcodes => labels}/label-print-pdf.pl | 175 +++-- labels/label-save-template.pl | 50 ++ labels/label-select-pdf.pl | 32 + labels/label-templates.pl | 82 +++ 43 files changed, 2504 insertions(+), 2193 deletions(-) delete mode 100755 barcodes/barcodes.pl delete mode 100755 barcodes/barcodesGenerator.pl delete mode 100755 barcodes/label-home.pl delete mode 100755 barcodes/label-manager.pl delete mode 100755 barcodes/label-print-opus-pdf.pl delete mode 100755 barcodes/label-print.pl delete mode 100755 barcodes/pdfViewer.pl delete mode 100755 barcodes/printerConfig.pl delete mode 100755 barcodes/test.textblock.pl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/barcodes.tmpl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/label-create-template.tmpl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/label-home.tmpl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/label-manager.tmpl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/label-templates.tmpl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/printerConfig.tmpl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/barcodes/search.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc create mode 100755 koha-tmpl/intranet-tmpl/prog/en/includes/menu-labels.inc rename koha-tmpl/intranet-tmpl/prog/en/{barcodes => labels}/label-bib-search.tmpl (86%) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/label-create-layout.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/label-create-template.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-layout.tmpl rename koha-tmpl/intranet-tmpl/prog/en/{barcodes => labels}/label-edit-template.tmpl (52%) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/label-home.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/label-manager.tmpl rename koha-tmpl/intranet-tmpl/prog/en/{barcodes => labels}/label-print.tmpl (100%) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/label-templates.tmpl rename koha-tmpl/intranet-tmpl/prog/en/{barcodes => labels}/result.tmpl (50%) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/labels/search.tmpl create mode 100755 labels/label-create-layout.pl create mode 100755 labels/label-create-template.pl create mode 100755 labels/label-edit-layout.pl create mode 100755 labels/label-edit-template.pl create mode 100755 labels/label-home.pl rename {barcodes => labels}/label-item-search.pl (61%) create mode 100755 labels/label-manager.pl rename {barcodes => labels}/label-print-pdf.pl (55%) create mode 100755 labels/label-save-template.pl create mode 100755 labels/label-select-pdf.pl create mode 100755 labels/label-templates.pl diff --git a/C4/Labels.pm b/C4/Labels.pm index 933506b1de..4f357d46f3 100755 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -24,10 +24,11 @@ use vars qw($VERSION @ISA @EXPORT); use PDF::Reuse; use Text::Wrap; +use Algorithm::CheckDigits; +# use Data::Dumper; +# use Smart::Comments; -$VERSION = do { my @v = '$Revision$' =~ /\d+/g; - shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); -}; +$VERSION = 0.01; =head1 NAME @@ -39,17 +40,28 @@ C4::Labels - Functions for printing spine labels and barcodes in Koha =cut -@ISA = qw(Exporter); +@ISA = qw(Exporter); @EXPORT = qw( - &get_label_options &get_label_items - &build_circ_barcode &draw_boundaries + &get_label_options &get_label_items + &build_circ_barcode &draw_boundaries &drawbox &GetActiveLabelTemplate &GetAllLabelTemplates &DeleteTemplate &GetSingleLabelTemplate &SaveTemplate &CreateTemplate &SetActiveTemplate &SaveConf &DrawSpineText &GetTextWrapCols &GetUnitsValue &DrawBarcode - + &get_printingtypes + &get_layouts + &get_barcode_types + &get_batches &delete_batch + &add_batch &SetFontSize &printText + &GetItemFields + &get_text_fields + get_layout &save_layout &add_layout + &set_active_layout &by_order + &build_text_dropbox + &delete_layout &get_active_layout +&get_highest_batch ); =item get_label_options; @@ -64,7 +76,7 @@ Return a pointer on a hash list containing info from labels_conf table in Koha D #' sub get_label_options { my $dbh = C4::Context->dbh; - my $query2 = " SELECT * FROM labels_conf LIMIT 1 "; + my $query2 = " SELECT * FROM labels_conf where active = 1"; my $sth = $dbh->prepare($query2); $sth->execute(); my $conf_data = $sth->fetchrow_hashref; @@ -72,6 +84,263 @@ sub get_label_options { return $conf_data; } +sub get_layouts { + +## FIXME: this if/else could be compacted... + my $dbh = C4::Context->dbh; + my @data; + my $query = " Select * from labels_conf"; + my $sth = $dbh->prepare($query); + $sth->execute(); + my @resultsloop; + while ( my $data = $sth->fetchrow_hashref ) { + + $data->{'fieldlist'} = get_text_fields( $data->{'id'} ); + push( @resultsloop, $data ); + } + $sth->finish; + + # @resultsloop + + return @resultsloop; +} + +sub get_layout { + my ($layout_id) = @_; + my $dbh = C4::Context->dbh; + + # get the actual items to be printed. + my $query = " Select * from labels_conf where id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($layout_id); + my $data = $sth->fetchrow_hashref; + $sth->finish; + return $data; +} + +sub get_active_layout { + my ($layout_id) = @_; + my $dbh = C4::Context->dbh; + + # get the actual items to be printed. + my $query = " Select * from labels_conf where active = 1"; + my $sth = $dbh->prepare($query); + $sth->execute(); + my $data = $sth->fetchrow_hashref; + $sth->finish; + return $data; +} + +sub delete_layout { + my ($layout_id) = @_; + my $dbh = C4::Context->dbh; + + # get the actual items to be printed. + my $query = "delete from labels_conf where id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($layout_id); + $sth->finish; +} + +sub get_printingtypes { + my ($layout_id) = @_; + my @printtypes; + + push( @printtypes, { code => 'BAR', desc => "barcode" } ); + push( @printtypes, { code => 'BIB', desc => "biblio" } ); + push( @printtypes, { code => 'BARBIB', desc => "barcode / biblio" } ); + push( @printtypes, { code => 'BIBBAR', desc => "biblio / barcode" } ); + push( @printtypes, { code => 'ALT', desc => "alternating labels" } ); + + my $conf = get_layout($layout_id); + my $active_printtype = $conf->{'printingtype'}; + + # lop thru layout, insert selected to hash + + foreach my $printtype (@printtypes) { + if ( $printtype->{'code'} eq $active_printtype ) { + $printtype->{'active'} = 'MOO'; + } + } + return @printtypes; +} + +sub build_text_dropbox { + my ($order) = @_; + + # my @fields = get_text_fields(); + # my $field_count = scalar @fields; + my $field_count = 10; # <----------- FIXME hard coded + + my @lines; + !$order + ? push( @lines, { num => '', selected => '1' } ) + : push( @lines, { num => '' } ); + for ( my $i = 1 ; $i <= $field_count ; $i++ ) { + my $line = { num => "$i" }; + $line->{'selected'} = 1 if $i eq $order; + push( @lines, $line ); + } + + # add a blank row too + + return @lines; +} + +sub get_text_fields { + my ($layout_id, $sorttype) = @_; + + my ( $a, $b, $c, $d, $e, $f, $g, $h, $i ,$j, $k ); + + my $sortorder = get_layout($layout_id); + + # $sortorder + + $a = { + code => 'itemtype', + desc => "Item Type", + order => $sortorder->{'itemtype'} + }; + $b = { + code => 'dewey', + desc => "Dewey", + order => $sortorder->{'dewey'} + }; + $c = { code => 'issn', desc => "ISSN", + order => $sortorder->{'issn'} }; + $d = { code => 'isbn', desc => "ISBN", + order => $sortorder->{'isbn'} }; + $e = { + code => 'class', + desc => "Classification", + order => $sortorder->{'class'} + }; + $f = { + code => 'subclass', + desc => "Sub-Class", + order => $sortorder->{'subclass'} + }; + $g = { + code => 'barcode', + desc => "Barcode", + order => $sortorder->{'barcode'} + }; + $h = + { code => 'author', desc => "Author", order => $sortorder->{'author'} }; + $i = { code => 'title', desc => "Title", order => $sortorder->{'title'} }; + $j = { code => 'itemcallnumber', desc => "Call Number", order => $sortorder->{'itemcallnumber'} }; + $k = { code => 'subtitle', desc => "Subtitle", order => $sortorder->{'subtitle'} }; + + my @text_fields = ( $a, $b, $c, $d, $e, $f, $g, $h, $i ,$j, $k ); + + my @new_fields; + foreach my $field (@text_fields) { + push( @new_fields, $field ) if $field->{'order'} > 0; + } + + my @sorted_fields = sort by_order @new_fields; + my $active_fields; + foreach my $field (@sorted_fields) { + $sorttype eq 'codes' ? $active_fields .= "$field->{'code'} " : + $active_fields .= "$field->{'desc'} "; + } + return $active_fields; + +} + +sub by_order { + $$a{order} <=> $$b{order}; +} + +sub add_batch { + my $new_batch; + my $dbh = C4::Context->dbh; + my $q = + "select distinct batch_id from labels order by batch_id desc limit 1"; + my $sth = $dbh->prepare($q); + $sth->execute(); + my $data = $sth->fetchrow_hashref; + $sth->finish; + + if ( !$data->{'batch_id'} ) { + $new_batch = 1; + } + else { + $new_batch = ( $data->{'batch_id'} + 1 ); + } + + return $new_batch; +} + + +sub get_highest_batch { + my $new_batch; + my $dbh = C4::Context->dbh; + my $q = + "select distinct batch_id from labels order by batch_id desc limit 1"; + my $sth = $dbh->prepare($q); + $sth->execute(); + my $data = $sth->fetchrow_hashref; + $sth->finish; + + if ( !$data->{'batch_id'} ) { + $new_batch = 1; + } + else { + $new_batch = $data->{'batch_id'}; + } + + return $new_batch; +} + + +sub get_batches { + my $dbh = C4::Context->dbh; + my $q = "select batch_id, count(*) as num from labels group by batch_id"; + my $sth = $dbh->prepare($q); + $sth->execute(); + my @resultsloop; + while ( my $data = $sth->fetchrow_hashref ) { + push( @resultsloop, $data ); + } + $sth->finish; + + # adding a dummy batch=1 value , if none exists in the db + if ( !scalar(@resultsloop) ) { + push( @resultsloop, { batch_id => '1' , num => '0' } ); + } + return @resultsloop; +} + +sub delete_batch { + my ($batch_id) = @_; + my $dbh = C4::Context->dbh; + my $q = "DELETE FROM labels where batch_id = ?"; + my $sth = $dbh->prepare($q); + $sth->execute($batch_id); + $sth->finish; +} + +sub get_barcode_types { + my ($layout_id) = @_; + my $layout = get_layout($layout_id); + my $barcode = $layout->{'barcodetype'}; + my @array; + + push( @array, { code => 'CODE39', desc => 'Code 39' } ); + push( @array, { code => 'CODE39MOD', desc => 'Code39 + Modulo43' } ); + push( @array, { code => 'CODE39MOD10', desc => 'Code39 + Modulo10' } ); + push( @array, { code => 'ITF', desc => 'Interleaved 2 of 5' } ); + + foreach my $line (@array) { + if ( $line->{'code'} eq $barcode ) { + $line->{'active'} = 1; + } + + } + return @array; +} + sub GetUnitsValue { my ($units) = @_; my $unitvalue; @@ -80,7 +349,6 @@ sub GetUnitsValue { $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; } @@ -94,7 +362,7 @@ sub GetTextWrapCols { while ( $strwidth < $textlimit ) { $strwidth = prStrWidth( $string, 'C', $fontsize ); - $string = $string . '0'; + $string = $string . '0'; # warn "strwidth $strwidth, $textlimit, $string"; $count++; @@ -113,11 +381,11 @@ sub GetActiveLabelTemplate { } sub GetSingleLabelTemplate { - my ($tmpl_code) = @_; - my $dbh = C4::Context->dbh; - my $query = " SELECT * FROM labels_templates where tmpl_code = ?"; - my $sth = $dbh->prepare($query); - $sth->execute($tmpl_code); + my ($tmpl_id) = @_; + my $dbh = C4::Context->dbh; + my $query = " SELECT * FROM labels_templates where tmpl_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($tmpl_id); my $template = $sth->fetchrow_hashref; $sth->finish; return $template; @@ -126,45 +394,54 @@ sub GetSingleLabelTemplate { sub SetActiveTemplate { my ($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); - $sth->execute; + $sth->execute(); - $query = "UPDATE labels_templates SET active = 1 WHERE tmpl_id = ?"; - $sth = $dbh->prepare($query); + my $query = "UPDATE labels_templates SET active = 1 WHERE tmpl_id = ?"; + my $sth = $dbh->prepare($query); $sth->execute($tmpl_id); $sth->finish; } -sub DeleteTemplate { - my ($tmpl_code) = @_; +sub set_active_layout { + + my ($layout_id) = @_; my $dbh = C4::Context->dbh; - my $query = " DELETE FROM labels_templates where tmpl_code = ?"; + my $query = " UPDATE labels_conf SET active = NULL"; my $sth = $dbh->prepare($query); - $sth->execute($tmpl_code); + $sth->execute(); + + my $query = "UPDATE labels_conf SET active = 1 WHERE id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($layout_id); $sth->finish; } -sub SaveTemplate { +sub DeleteTemplate { + my ($tmpl_id) = @_; + my $dbh = C4::Context->dbh; + my $query = " DELETE FROM labels_templates where tmpl_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($tmpl_id); + $sth->finish; +} +sub SaveTemplate { my ( $tmpl_id, $tmpl_code, $tmpl_desc, $page_width, $page_height, $label_width, $label_height, $topmargin, $leftmargin, $cols, $rows, $colgap, - $rowgap, $active, $fontsize, $units - ) - = @_; - - #warn "FONTSIZE =$fontsize"; - - my $dbh = C4::Context->dbh; + $rowgap, $fontsize, $units + ) = @_; + my $dbh = C4::Context->dbh; my $query = " UPDATE labels_templates SET tmpl_code=?, tmpl_desc=?, page_width=?, - page_height=?, label_width=?, label_height=?, topmargin=?, - leftmargin=?, cols=?, rows=?, colgap=?, rowgap=?, fontsize=?, - units=? + page_height=?, label_width=?, label_height=?, topmargin=?, + leftmargin=?, cols=?, rows=?, colgap=?, rowgap=?, fontsize=?, + units=? WHERE tmpl_id = ?"; my $sth = $dbh->prepare($query); @@ -175,8 +452,6 @@ sub SaveTemplate { $fontsize, $units, $tmpl_id ); $sth->finish; - - SetActiveTemplate($tmpl_id) if ( $active eq '1' ); } sub CreateTemplate { @@ -185,9 +460,8 @@ sub CreateTemplate { $tmpl_code, $tmpl_desc, $page_width, $page_height, $label_width, $label_height, $topmargin, $leftmargin, $cols, $rows, $colgap, $rowgap, - $active, $fontsize, $units - ) - = @_; + $fontsize, $units + ) = @_; my $dbh = C4::Context->dbh; @@ -203,24 +477,6 @@ sub CreateTemplate { $cols, $rows, $colgap, $rowgap, $fontsize, $units ); - - warn "ACTIVE = $active"; - - 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 $sth = $dbh->prepare($query); - $sth->execute(); - - my $data = $sth->fetchrow_hashref; - my $tmpl_id = $data->{'tmpl_id'}; - - SetActiveTemplate($tmpl_id); - $sth->finish; - } - return $tmpl_id; } sub GetAllLabelTemplates { @@ -237,34 +493,36 @@ sub GetAllLabelTemplates { } $sth->finish; + #warn Dumper @resultsloop; return @resultsloop; } -sub SaveConf { +#sub SaveConf { +sub add_layout { my ( - $barcodetype, $title, $isbn, $itemtype, - $bcn, $dcn, $classif, $subclass, - $itemcallnumber, $author, $tmpl_id, $printingtype, - $guidebox, $startlabel - ) - = @_; + $barcodetype, $title, $subtitle, $isbn, $issn, + $itemtype, $bcn, $dcn, $classif, + $subclass, $itemcallnumber, $author, $tmpl_id, + $printingtype, $guidebox, $startlabel, $layoutname + ) = @_; my $dbh = C4::Context->dbh; - my $query2 = "DELETE FROM labels_conf"; + my $query2 = "update labels_conf set active = NULL"; my $sth2 = $dbh->prepare($query2); - $sth2->execute; - $query2 = "INSERT INTO labels_conf - ( barcodetype, title, isbn, itemtype, barcode, + $sth2->execute(); + my $query2 = "INSERT INTO labels_conf + ( barcodetype, title, subtitle, isbn,issn, itemtype, barcode, dewey, class, subclass, itemcallnumber, author, printingtype, - guidebox, startlabel ) - values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; - $sth2 = $dbh->prepare($query2); + guidebox, startlabel, layoutname, active ) + values ( ?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?,?,?, 1 )"; + my $sth2 = $dbh->prepare($query2); $sth2->execute( - $barcodetype, $title, $isbn, $itemtype, - $bcn, $dcn, $classif, $subclass, - $itemcallnumber, $author, $printingtype, $guidebox, - $startlabel + $barcodetype, $title, $subtitle, $isbn, $issn, + + $itemtype, $bcn, $dcn, $classif, + $subclass, $itemcallnumber, $author, $printingtype, + $guidebox, $startlabel, $layoutname ); $sth2->finish; @@ -272,6 +530,36 @@ sub SaveConf { return; } +sub save_layout { + + my ( + $barcodetype, $title, $subtitle, $isbn, $issn, + $itemtype, $bcn, $dcn, $classif, + $subclass, $itemcallnumber, $author, $tmpl_id, + $printingtype, $guidebox, $startlabel, $layoutname, + $layout_id + ) = @_; +### $layoutname +### $layout_id + + my $dbh = C4::Context->dbh; + my $query2 = "update labels_conf set + barcodetype=?, title=?, subtitle=?, isbn=?,issn=?, + itemtype=?, barcode=?, dewey=?, class=?, + subclass=?, itemcallnumber=?, author=?, printingtype=?, + guidebox=?, startlabel=?, layoutname=? where id = ?"; + my $sth2 = $dbh->prepare($query2); + $sth2->execute( + $barcodetype, $title, $subtitle, $isbn, $issn, + $itemtype, $bcn, $dcn, $classif, + $subclass, $itemcallnumber, $author, $printingtype, + $guidebox, $startlabel, $layoutname, $layout_id + ); + $sth2->finish; + + return; +} + =item get_label_items; $options = get_label_items() @@ -283,28 +571,46 @@ Returns an array of references-to-hash, whos keys are the field from the biblio, #' sub get_label_items { + my ($batch_id) = @_; my $dbh = C4::Context->dbh; - # get the actual items to be printed. + my @resultsloop = (); + my $count; my @data; - my $query3 = " Select * from labels "; - my $sth = $dbh->prepare($query3); - $sth->execute(); - my @resultsloop; + my $sth; + + if ($batch_id) { + my $query3 = "Select * from labels where batch_id = ? order by labelid "; + $sth = $dbh->prepare($query3); + $sth->execute($batch_id); + + } + else { + + my $query3 = "Select * from labels"; + $sth = $dbh->prepare($query3); + $sth->execute(); + } my $cnt = $sth->rows; my $i1 = 1; 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 - biblioitems.biblionumber=biblio.biblionumber"; - - my $sth1 = $dbh->prepare($query1); + my $query1 = " + select i.*, bi.*, b.* from items i,biblioitems bi,biblio b + where itemnumber=? and i.biblioitemnumber=bi.biblioitemnumber and + bi.biblionumber=b.biblionumber"; + + my $sth1 = $dbh->prepare($query1); $sth1->execute( $data->{'itemnumber'} ); + my $data1 = $sth1->fetchrow_hashref(); + $data1->{'labelno'} = $i1; + $data1->{'batch_id'} = $batch_id; + $data1->{'summary'} = + "$data1->{'barcode'}, $data1->{'title'}, $data1->{'isbn'}"; + push( @resultsloop, $data1 ); $sth1->finish; @@ -312,6 +618,17 @@ sub get_label_items { } $sth->finish; return @resultsloop; + +} + +sub GetItemFields { + my @fields = qw ( + barcode title subtitle + dewey isbn issn author class + itemtype subclass itemcallnumber + + ); + return @fields; } sub DrawSpineText { @@ -319,23 +636,39 @@ sub DrawSpineText { my ( $y_pos, $label_height, $fontsize, $x_pos, $left_text_margin, $text_wrap_cols, $item, $conf_data ) = @_; - +# hack to fix column name mismatch betwen labels_conf.class, and bibitems.classification + $$item->{'class'} = $$item->{'classification'}; + $Text::Wrap::columns = $text_wrap_cols; $Text::Wrap::separator = "\n"; my $str; + ## $item my $top_text_margin = ( $fontsize + 3 ); my $line_spacer = ($fontsize); # number of pixels between text rows. # add your printable fields manually in here - my @fields = - qw (dewey isbn classification itemtype subclass itemcallnumber); - my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) ); - my $hPos = ( $x_pos + $left_text_margin ); + +my $layout_id = $$conf_data->{'id'}; + +# my @fields = GetItemFields(); + +my $str_fields = get_text_fields($layout_id, 'codes' ); +my @fields = split(/ /, $str_fields); +### @fields + + 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) { + # testing hack +# $$item->{"$field"} = $field . ": " . $$item->{"$field"}; + # 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"} ) { @@ -344,7 +677,6 @@ sub DrawSpineText { # get the string $str = $$item->{"$field"}; - # strip out naughty existing nl/cr's $str =~ s/\n//g; $str =~ s/\r//g; @@ -362,26 +694,43 @@ sub DrawSpineText { foreach my $str (@strings) { #warn "HPOS , VPOS $hPos, $vPos "; - prText( $hPos, $vPos, $str ); + # set the font size A + + # prText( $hPos, $vPos, $str ); + PrintText( $hPos, $vPos, $fontsize, $str ); $vPos = $vPos - $line_spacer; } - } # if field is valid - } #foreach feild + } # if field is } #foreach feild + } +} + +sub PrintText { + my ( $hPos, $vPos, $fontsize, $text ) = @_; + my $str = "BT /Ft1 $fontsize Tf $hPos $vPos Td ($text) Tj ET"; + prAdd($str); +} + +sub SetFontSize { + + my ($fontsize) = @_; +### fontsize + my $str = "BT/F13 30 Tf288 720 Td( AAAAAAAAAA ) TjET"; + prAdd($str); } sub DrawBarcode { + # x and y are from the top-left :) 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'; + if ( $barcodetype eq 'CODE39' ) { + $bar_length = '17.5'; $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length * 2 ); $xsize_ratio = ( $bar_width / $tot_bar_length ); @@ -389,10 +738,10 @@ sub DrawBarcode { PDF::Reuse::Barcode::Code39( x => ( $x_pos + ( $width / 10 ) ), y => ( $y_pos + ( $height / 10 ) ), - value => "*$barcode*", - ySize => ( .02 * $height ), - xSize => $xsize_ratio, - hide_asterisk => $xsize_ratio, + value => "*$barcode*", + ySize => ( .02 * $height ), + xSize => $xsize_ratio, + hide_asterisk => 1, ); }; if ($@) { @@ -400,8 +749,61 @@ sub DrawBarcode { } } - elsif ( $barcodetype eq 'COOP2of5' ) { - $bar_length = '9.43333333333333'; + elsif ( $barcodetype eq 'CODE39MOD' ) { + + # 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 ); + 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 'CODE39MOD10' ) { + + # get modulo43 checksum + my $c39_10 = CheckDigits('visa'); + $barcode = $c39_10->complete($barcode); + + $bar_length = '19'; + $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, + text => 0, + ); + }; + + 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; @@ -419,8 +821,8 @@ sub DrawBarcode { } } - elsif ( $barcodetype eq 'Industrial2of5' ) { - $bar_length = '13.1333333333333'; + 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; @@ -437,6 +839,7 @@ sub DrawBarcode { warn "$barcodetype, $barcode FAILED:$@"; } } + my $moo2 = $tot_bar_length * $xsize_ratio; warn " $x_pos, $y_pos, $barcode, $barcodetype\n"; @@ -457,6 +860,8 @@ $item is the result of a previous call to get_label_items(); sub build_circ_barcode { my ( $x_pos_circ, $y_pos, $value, $barcodetype, $item ) = @_; + #warn Dumper \$item; + #warn "value = $value\n"; #$DB::single = 1; @@ -495,15 +900,17 @@ sub build_circ_barcode { } elsif ( $barcodetype eq 'Code39' ) { + eval { 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 ($@) { @@ -751,11 +1158,10 @@ sub draw_boundaries { my ( $x_pos_spine, $x_pos_circ1, $x_pos_circ2, $y_pos, $spine_width, $label_height, $circ_width - ) - = @_; + ) = @_; my $y_pos_initial = ( ( 792 - 36 ) - 90 ); - $y_pos = $y_pos_initial; + my $y_pos = $y_pos_initial; my $i = 1; for ( $i = 1 ; $i <= 8 ; $i++ ) { @@ -791,9 +1197,11 @@ sub drawbox { # 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 - $str .= "1.0 0.0 0.0 RG\n"; # border color red - $str .= "0.5 0.75 1.0 rg\n"; # fill color blue + $str .= "0.5 w\n"; # border color red + $str .= "1.0 0.0 0.0 RG\n"; # border color red + # $str .= "0.5 0.75 1.0 rg\n"; # fill color blue + $str .= "1.0 1.0 1.0 rg\n"; # fill color white + $str .= "$llx $lly $urx $ury re\n"; # a rectangle $str .= "B\n"; # fill (and a little more) $str .= "Q\n"; # save the graphic state diff --git a/barcodes/barcodes.pl b/barcodes/barcodes.pl deleted file mode 100755 index 7e78ffb036..0000000000 --- a/barcodes/barcodes.pl +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/perl - -# script to generate items barcodes -# written 07/04 -# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and -# Casta�eda Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina and - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use CGI; -use C4::Auth; -use C4::Output; -use C4::Context; -use C4::Barcodes::PrinterConfig; - -# This function returns the path to deal with the correct files, considering -# templates set and language. -sub getPath { - my $type = shift @_; - my $templatesSet = C4::Context->preference('template'); - my $lang = C4::Context->preference('opaclanguages'); - if ( $type eq "intranet" ) { - return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang"; - } - else { - return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang"; - } -} - -# Load a configuration file. Before use this function, check if that file exists. -sub loadConfFromFile { - my $fileName = shift @_; - my %keyValues; - open FILE, "<$fileName"; - while () { - chomp; - if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) { - $keyValues{$1} = $2; - } - } - close FILE; - return %keyValues; -} - -# Save settings to a configuration file. It delete previous configuration settings. -sub saveConfToFile { - my $fileName = shift @_; - my %keyValues = %{ shift @_ }; - my $i; - open FILE, ">$fileName"; - foreach $i ( keys(%keyValues) ) { - print FILE $i . " = " . $keyValues{$i} . "\n"; - } - close FILE; -} - -# Load the config file. -my $filenameConf = - &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf"; -my %labelConfig = &loadConfFromFile($filenameConf); - -my $input = new CGI; - -# Defines type of page to use in the printer process -my @labelTable = - C4::Barcodes::PrinterConfig::labelsPage( $labelConfig{'rows'}, - $labelConfig{'columns'} ); - -# It creates a list of posible intervals to choose codes to generate -my %list = ( - 'continuous' => 'Continuous Range of items', - 'individuals' => 'Individual Codes' -); -my @listValues = keys(%list); -my $rangeType = CGI::scrolling_list( - -name => 'rangeType', - -values => \@listValues, - -labels => \%list, - -size => 1, - -default => ['continuous'], - -multiple => 0, - -id => "rangeType", - -onChange => "changeRange(this)" -); - -# It creates a list of posible standard codifications. First checks if the user has just added a new code. -if ( $input->param('addCode') ) { - my $newCountryName = $input->param('countryName'); - my $newCountryCode = $input->param('countryCode'); - - my $countryCodesFilename = - &getPath("intranet") . "/includes/countryCodes/countryCodes.dat"; - open COUNTRY_CODES, ">>$countryCodesFilename"; - print COUNTRY_CODES $newCountryCode . " = " . $newCountryName . "\n"; - close COUNTRY_CODES; -} - -# Takes the country codes from a file and use them to set the country list. -my $countryCodes = - &getPath("intranet") . "/includes/countryCodes/countryCodes.dat"; -%list = &loadConfFromFile($countryCodes); -@listValues = keys(%list); -my $number_system = CGI::scrolling_list( - -name => 'numbersystem', - -values => \@listValues, - -labels => \%list, - -size => 1, - -multiple => 0 -); - -# Set the script name -my $script_name = "/cgi-bin/koha/barcodes/barcodesGenerator.pl"; - -# Get the template to use -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "barcodes/barcodes.tmpl", - type => "intranet", - query => $input, - authnotrequired => 0, - flagsrequired => { tools => 1 }, - debug => 1, - } -); - -# Replace the template values with the real ones -$template->param( SCRIPT_NAME => $script_name ); -$template->param( NUMBER_SYSTEM => $number_system ); -$template->param( PAGES => $labelConfig{'pageType'} ); -$template->param( RANGE_TYPE => $rangeType ); -$template->param( LABEL_TABLE => \@labelTable ); -$template->param( COL_SPAN => $labelConfig{'columns'} ); -if ( $input->param('error') ) { - $template->param( ERROR => 1 ); -} -else { - $template->param( ERROR => 0 ); -} -$template->param( - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), -); - -# Shows the template with the real values replaced -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/barcodes/barcodesGenerator.pl b/barcodes/barcodesGenerator.pl deleted file mode 100755 index af0c4dc5ff..0000000000 --- a/barcodes/barcodesGenerator.pl +++ /dev/null @@ -1,373 +0,0 @@ -#!/usr/bin/perl - -# script to generate items barcodes -# written 07/04 -# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and -# Castañeda Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina and - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -require Exporter; - -use strict; - -use CGI; -use C4::Context; -use C4::Output; - - -#FIXME : module deprecated ? -use PDF::API2; -use PDF::API2::Page; -use PDF::API2::Util; -use C4::Barcodes::PrinterConfig; -use Time::localtime; - -# This function returns the path to deal with the correct files, considering -# templates set and language. -sub getPath { - my $type = shift @_; - my $templatesSet = C4::Context->preference('template'); - my $lang = C4::Context->preference('opaclanguages'); - if ( $type eq "intranet" ) { - return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang"; - } - else { - return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang"; - } -} - -# Load a configuration file. Before use this function, check if that file exists. -sub loadConfFromFile { - my $fileName = shift @_; - my %keyValues; - open FILE, "<$fileName"; - while () { - chomp; - if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) { - $keyValues{$1} = $2; - } - } - close FILE; - return %keyValues; -} - -# Save settings to a configuration file. It delete previous configuration settings. -sub saveConfToFile { - my $fileName = shift @_; - my %keyValues = %{ shift @_ }; - my $i; - open FILE, ">$fileName"; - foreach $i ( keys(%keyValues) ) { - print FILE $i . " = " . $keyValues{$i} . "\n"; - } - close FILE; -} - -# Load the config file. -my $filenameConf = - &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf"; -my %labelConfig = &loadConfFromFile($filenameConf); - -# Creates a CGI object and take its parameters -my $cgi = new CGI; -my $from = $cgi->param('from'); -my $to = $cgi->param('to'); -my $individualCodes = $cgi->param('individualCodes'); -my $rangeType = $cgi->param('rangeType'); -my $pageType = $cgi->param('pages'); -my $label = $cgi->param('label'); -my $numbersystem = $cgi->param('numbersystem'); -my $text_under_label = $cgi->param('text_under_label'); - -# Generate the checksum from an inventary code -sub checksum { - - sub calculateDigit { - my $code = shift @_; - my $sum = 0; - my $odd_parity = 1; - my $i; - for ( $i = length($code) - 1 ; $i >= 0 ; $i-- ) { - if ($odd_parity) { - $sum = $sum + ( 3 * substr( $code, $i, 1 ) ); - } - else { - $sum = $sum + substr( $code, $i, 1 ); - } - $odd_parity = !$odd_parity; - } - my $check_digit = 10 - ( $sum % 10 ); - if ( $check_digit == 10 ) { - $check_digit = 0; - } - return $code . $check_digit; - } - - my $currentCode = shift @_; - $currentCode = &calculateDigit($currentCode); - return $currentCode; -} - -# Assigns a temporary name to the PDF file -sub assingFilename { - my ( $from, $to ) = @_; - my $ip = $cgi->remote_addr(); - my $random = int( rand(1000000) ); - my $timeObj = localtime(); - my ( $day, $month, $year, $hour, $min, $sec ) = ( - $timeObj->mday, - $timeObj->mon + 1, - $timeObj->year + 1900, - $timeObj->hour, $timeObj->min, $timeObj->sec - ); - my $tmpFileName = - $random . '-' . $ip - . '-(From ' - . $from . ' to ' - . $to . ')-[' - . $day . '.' - . $month . '.' - . $year . ']-[' - . $hour . ':' - . $min . ':' - . $sec . '].pdf'; - return $tmpFileName; -} - -sub getCallnum { - - #grabs a callnumber for the specified barcode - my ($barcode) = @_; - my $query = -"select dewey from items,biblioitems where items.biblionumber=biblioitems.biblionumber and items.barcode=?"; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare($query); - $sth->execute($barcode); - my ($callnum) = $sth->fetchrow_array(); - warn "Call number is:" . $barcode; - return $callnum; -} - -# Takes inventary codes from database and if they are between -# the interval specify by parameters, it generates the correspond barcodes -sub barcodesGenerator { - my ( $from, $to, $rangeType, $individualCodes, $text_under_label ) = @_; - - # Returns a database handler - my $dbh = C4::Context->dbh; - - # Create the query to database - # Assigns a temporary filename for the pdf file - my $tmpFileName = &assingFilename( $from, $to ); - - # warn "range type: ".$rangeType; - if ( $rangeType eq 'continuous' ) { - - # Set the temp directory for pdf´s files - if ( !defined( $ENV{'TEMP'} ) ) { - $ENV{'TEMP'} = '/tmp/'; - } - $tmpFileName = $ENV{'TEMP'} . $tmpFileName; - - # Creates a PDF object - my $pdf = PDF::API2->new( -file => $tmpFileName ); - - # Set the positions where barcodes are going to be placed - C4::Barcodes::PrinterConfig::setPositionsForX( - $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'}, - $labelConfig{'columns'}, $labelConfig{'pageType'} - ); - C4::Barcodes::PrinterConfig::setPositionsForY( - $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'}, - $labelConfig{'rows'}, $labelConfig{'pageType'} - ); - - # Creates a font object - my $tr = $pdf->corefont('Helvetica-Bold'); - - # Barcode position - my ( $page, $gfx, $text ); - for ( my $code = $from ; $code <= $to ; $code++ ) { - - # Generetase checksum - my $codeC = &checksum($code); - - # Generate the corresponde barcode to $code - # warn "Code is :-->".$codeC."<--"; - my $barcode = $pdf->barcode( - -font => $tr, # The font object to use - -type => 'ean128', # Standard of codification - -code => $codeC, # Text to codify - -extn => '012345', # Barcode extension (if it is aplicable) - -umzn => 10, # Top limit of the finished bar - -lmzn => 10, # Bottom limit of the finished bar - -zone => 15, # Bars size - -quzn => 0, # Space destinated for legend - -ofwt => 0.01, # Bars width - -fnsz => 8, # Font size - -text => '' - ); - - ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) = - C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf, - $page, $gfx, $text, $tr, $pageType ); - - # Assigns a barcodes to $gfx - $gfx->barcode( $barcode, $x, $y, - ( 72 / $labelConfig{'systemDpi'} ) ); - - # Assigns the additional information to the barcode (Legend) - $text->translate( $x - 48, $y - 22 ); - - #warn "code is ".$codeC; - if ($text_under_label) { - $text->text($text_under_label); - } - else { - $text->text( getCallnum($code) ); - } - } - - # Writes the objects added in $gfx to $page - $pdf->finishobjects( $page, $gfx, $text ); - - # Save changes to the PDF - $pdf->saveas; - - # Close the conection with the PDF file - $pdf->end; - - # Show the PDF file - print $cgi->redirect( - "/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName"); - } - else { - my $rangeCondition; - if ( $individualCodes ne "" ) { - $rangeCondition = "AND (I.barcode IN " . $individualCodes . ")"; - } - else { - $rangeCondition = - "AND (I.barcode >= " . $from . " AND I.barcode <=" . $to . " )"; - } - - my $query = -"SELECT CONCAT('$numbersystem',REPEAT('0',((12 - LENGTH('$numbersystem')) - LENGTH(I.barcode))), I.barcode) AS Codigo, B.title, B.author FROM biblio B, items I WHERE (I.biblionumber = B.biblioNumber ) " - . $rangeCondition - . " AND (I.barcode <> 'FALTA') ORDER BY Codigo"; - - # Prepare the query - my $sth = $dbh->prepare($query); - - # Executes the query - $sth->execute; - if ( $sth->rows ) { # There are inventary codes - # Set the temp directory for pdf´s files - if ( !defined( $ENV{'TEMP'} ) ) { - $ENV{'TEMP'} = '/tmp/'; - } - - # Assigns a temporary filename for the pdf file - my $tmpFileName = &assingFilename( $from, $to ); - $tmpFileName = $ENV{'TEMP'} . $tmpFileName; - - # Creates a PDF object - my $pdf = PDF::API2->new( -file => $tmpFileName ); - - # Set the positions where barcodes are going to be placed - C4::Barcodes::PrinterConfig::setPositionsForX( - $labelConfig{'marginLeft'}, $labelConfig{'labelWidth'}, - $labelConfig{'columns'}, $labelConfig{'pageType'} - ); - C4::Barcodes::PrinterConfig::setPositionsForY( - $labelConfig{'marginBottom'}, $labelConfig{'labelHeigth'}, - $labelConfig{'rows'}, $labelConfig{'pageType'} - ); - - # Creates a font object - my $tr = $pdf->corefont('Helvetica-Bold'); - - # Barcode position - my ( $page, $gfx, $text ); - while ( my ( $code, $dewey, $title, $author ) = - $sth->fetchrow_array ) - { - - # Generetase checksum - $code = &checksum($code); - - # Generate the corresponde barcode to $code - my $barcode = $pdf->barcode( - -font => $tr, # The font object to use - -type => 'ean13', # Standard of codification - -code => $code, # Text to codify - -extn => '012345', # Barcode extension (if it is aplicable) - -umzn => 10, # Top limit of the finished bar - -lmzn => 10, # Bottom limit of the finished bar - -zone => 15, # Bars size - -quzn => 0, # Space destinated for legend - -ofwt => 0.01, # Bars width - -fnsz => 8, # Font size - -text => '' - ); - - ( my $x, my $y, $pdf, $page, $gfx, $text, $tr, $label ) = - C4::Barcodes::PrinterConfig::getLabelPosition( $label, $pdf, - $page, $gfx, $text, $tr, $pageType ); - - # Assigns a barcodes to $gfx - $gfx->barcode( $barcode, $x, $y, - ( 72 / $labelConfig{'systemDpi'} ) ); - - # Assigns the additional information to the barcode (Legend) - $text->translate( $x - 48, $y - 22 ); - if ($text_under_label) { - $text->text($text_under_label); - } - else { - $text->text( substr $title, 0, 30 ); - $text->translate( $x - 48, $y - 29 ); - - #$text->text(substr $author, 0, 30); - $text->text( substr $author, 0, 30 ); - } - } - - # Writes the objects added in $gfx to $page - $pdf->finishobjects( $page, $gfx, $text ); - - # Save changes to the PDF - $pdf->saveas; - - # Close the conection with the PDF file - $pdf->end; - - # Show the PDF file - print $cgi->redirect( - "/cgi-bin/koha/barcodes/pdfViewer.pl?tmpFileName=$tmpFileName"); - } - else { - - # Rollback and shows the error legend - print $cgi->redirect("/cgi-bin/koha/barcodes/barcodes.pl?error=1"); - } - $sth->finish; - } -} - -barcodesGenerator( $from, $to, $rangeType, $individualCodes, - $text_under_label ); diff --git a/barcodes/label-home.pl b/barcodes/label-home.pl deleted file mode 100755 index 5fa02ad9f1..0000000000 --- a/barcodes/label-home.pl +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use CGI; -use C4::Auth; -use C4::Output; -use C4::Labels; -use C4::Context; - - -my $query = new CGI; -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "barcodes/label-home.tmpl", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => { tools => 1 }, - debug => 1, - } -); - -my $data = get_label_options(); - -my $active_template = GetActiveLabelTemplate(); -my @label_templates = GetAllLabelTemplates(); - -$template->param( guidebox => 1 ) if ( $data->{'guidebox'} ); - -$data->{'printingtype'} = 'both' if ( !$data->{'printingtype'} ); -$template->param( "printingtype_$data->{'printingtype'}" => 1 ); -$template->param( "papertype_$data->{'papertype'}" => 1 ); - -$template->param( "$data->{'barcodetype'}_checked" => 1 ); - -$template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 ); -$template->param( - itemtype => $data->{'itemtype'}, - active_template => $data->{'active_template'}, - label_templates => \@label_templates, - - papertype => $data->{'papertype'}, - author => $data->{'author'}, - barcode => $data->{'barcode'}, - id => $data->{'id'}, - barcodetype => $data->{'barcodetype'}, - title => $data->{'title'}, - isbn => $data->{'isbn'}, - dewey => $data->{'dewey'}, - class => $data->{'class'}, - startrow => $data->{'startrow'}, - subclass => $data->{'subclass'}, - itemcallnumber => $data->{'itemcallnumber'}, - startlabel => $data->{'startlabel'}, - fontsize => $active_template->{'fontsize'}, - - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), -); - -output_html_with_http_headers $query, $cookie, $template->output; diff --git a/barcodes/label-manager.pl b/barcodes/label-manager.pl deleted file mode 100755 index b25ac2f80f..0000000000 --- a/barcodes/label-manager.pl +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/perl - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use CGI; -use C4::Auth; -use C4::Labels; -use C4::Output; - -use POSIX; - -my $dbh = C4::Context->dbh; -my $query = new CGI; -my $op = $query->param('op'); -my $barcodetype = $query->param('barcodetype'); -my $title = $query->param('title'); -my $isbn = $query->param('isbn'); -my $itemtype = $query->param('itemtype'); -my $bcn = $query->param('bcn'); -my $dcn = $query->param('dcn'); -my $classif = $query->param('classif'); -my $itemcallnumber = $query->param('itemcallnumber'); -my $subclass = $query->param('subclass'); -my $author = $query->param('author'); -my $tmpl_id = $query->param('tmpl_id'); -my $itemnumber = $query->param('itemnumber'); -my $summary = $query->param('summary'); -my $startlabel = $query->param('startlabel'); -my $printingtype = $query->param('printingtype'); -my $guidebox = $query->param('guidebox'); -my $fontsize = $query->param('fontsize'); - -#warn "ID =$tmpl_id"; - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "barcodes/label-manager.tmpl", - query => $query, - type => "intranet", - authnotrequired => 1, - flagsrequired => { tools => 1 }, - debug => 1, - } -); - -if ( $op eq 'save_conf' ) { - SaveConf( - $barcodetype, $title, $isbn, $itemtype, - $bcn, $dcn, $classif, $subclass, - $itemcallnumber, $author, $tmpl_id, $printingtype, - $guidebox, $startlabel - ); - -} -elsif ( $op eq 'add' ) { - my $query2 = "INSERT INTO labels ( itemnumber ) values ( ? )"; - my $sth2 = $dbh->prepare($query2); - $sth2->execute($itemnumber); - $sth2->finish; -} -elsif ( $op eq 'deleteall' ) { - my $query2 = "DELETE FROM labels"; - my $sth2 = $dbh->prepare($query2); - $sth2->execute(); - $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); - $sth2->finish; -} - -# first lets do a read of the labels table , to get the a list of the -# currently entered items to be prinited - -my @resultsloop = (); -my $count; -my @data; -my $query3 = "Select * from labels"; -my $sth = $dbh->prepare($query3); -$sth->execute(); - -my $cnt = $sth->rows; -my $i1 = 1; -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 - biblioitems.biblionumber=biblio.biblionumber"; - - my $sth1 = $dbh->prepare($query1); - $sth1->execute( $data->{'itemnumber'} ); - my $data1 = $sth1->fetchrow_hashref(); - - $data1->{'labelno'} = $i1; - $data1->{'summary'} = - "$data1->{'barcode'}, $data1->{'title'}, $data1->{'isbn'}"; - - push( @resultsloop, $data1 ); - $sth1->finish; - - $i1++; -} -$sth->finish; - -# this script can be run from the side nav, and is not passed a value for $startrow -# so lets get it from the DB - -my $dbh = C4::Context->dbh; -my $query2 = "SELECT * FROM labels_conf LIMIT 1"; -my $sth = $dbh->prepare($query2); -$sth->execute(); - -my $data = $sth->fetchrow_hashref; -$sth->finish; - -#calc-ing number of sheets - -#$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 ); - -$template->param( - resultsloop => \@resultsloop, - - # startrow => $startrow, - # sheets => $sheets_needed, - # labels_remaining => $labels_remaining, - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), -); -output_html_with_http_headers $query, $cookie, $template->output; diff --git a/barcodes/label-print-opus-pdf.pl b/barcodes/label-print-opus-pdf.pl deleted file mode 100755 index 5247ce9417..0000000000 --- a/barcodes/label-print-opus-pdf.pl +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/perl - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use CGI; -use C4::Labels; -use C4::Auth; -use C4::Output; -use C4::Context; -use PDF::Reuse; -use PDF::Reuse::Barcode; -use POSIX; -use Text::Wrap; - - -$Text::Wrap::columns = 39; -$Text::Wrap::separator = "\n"; - -my $htdocs_path = C4::Context->config('intrahtdocs'); -my $cgi = new CGI; -my $spine_text = ""; - -# get the printing settings -my $conf_data = get_label_options(); -my @resultsloop = get_label_items(); -my $barcodetype = $conf_data->{'barcodetype'}; -my $printingtype = $conf_data->{'printingtype'}; -my $guidebox = $conf_data->{'guidebox'}; -my $startrow = $conf_data->{'startrow'}; - -# if none selected, then choose 'both' -if ( !$printingtype ) { - $printingtype = 'both'; -} - -# opus paper dims. in *millimeters* -# multiply values by '2.83465', to find their value in Postscript points. - -# $xmargin = 12; -# $label_height = 34; -# $label_width = 74; -# $x_pos_spine = 12; -# $pageheight = 304; -# $pagewidth = 174; -# $line_spacer = 10; -# $label_rows = 8; - -# sheet dimensions in PS points. - -my $top_margin = 7; -my $left_margin = 34; -my $top_text_margin = 20; -my $left_text_margin = 10; -my $label_height = 96; -my $spine_width = 210; -my $colspace = 9; -my $rowspace = 11; -my $x_pos_spine = 36; -my $pageheight = 861; -my $pagewidth = 493; -my $line_spacer = 10; -my $label_rows = 8; - -# 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"); - -# fix, no longer writes to temp dir -prInitVars(); # To initiate ALL global variables and tables -$| = 1; -print STDOUT "Content-Type: application/pdf \n\n"; -prFile(); - -prMbox( 0, 0, $pagewidth, $pageheight ); -prFont('courier'); # Just setting a font -prFontSize(9); - -my $str; - -my $y_pos_initial = ( ( $pageheight - $top_margin ) - $label_height ); -my $y_pos_initial_startrow = - ( ( $pageheight - $top_margin ) - ( $label_height * $startrow ) ); -my $y_pos = $y_pos_initial_startrow; - -my $page_break_count = $startrow; -my $codetype = 'Code39'; - -#do page border -# commented out coz it was running into the side-feeds of the paper. -# drawbox( 0, 0 , $pagewidth, $pageheight ); - -my $item; - -# for loop -my $i2 = 1; - -foreach $item (@resultsloop) { - my $x_pos_spine_tmp = $x_pos_spine; - - for ( 1 .. 2 ) { - - if ( $guidebox == 1 ) { - warn -"COUNT1, PBREAKCNT=$page_break_count, y=$y_pos, labhght = $label_height"; - drawbox( $x_pos_spine_tmp, $y_pos, $spine_width, $label_height ); - } - - #-----------------draw spine text - if ( $printingtype eq 'spine' || $printingtype eq 'both' ) { - - #warn "PRINTTYPE = $printingtype"; - - # add your printable fields manually in here - my @fields = qw (itemtype dewey isbn classification); - my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) ); - my $hPos = ( $x_pos_spine_tmp + $left_text_margin ); - 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"; - - # get the string - $str = $item->{"$field"}; - - # strip out naughty existing nl/cr's - $str =~ s/\n//g; - $str =~ s/\r//g; - - # chop the string up into _upto_ 12 chunks - # and seperate the chunks with newlines - - $str = wrap( "", "", "$str" ); - $str = wrap( "", "", "$str" ); - - # split the chunks between newline's, into an array - my @strings = split /\n/, $str; - - # then loop for each string line - foreach my $str (@strings) { - - warn "HPOS , VPOS $hPos, $vPos "; - prText( $hPos, $vPos, $str ); - $vPos = $vPos - $line_spacer; - } - } # if field is valid - } # foreach @field - } #if spine - - $x_pos_spine_tmp = ( $x_pos_spine_tmp + $spine_width + $colspace ); - } # for 1 ..2 - warn " $y_pos - $label_height - $rowspace"; - $y_pos = ( $y_pos - $label_height - $rowspace ); - warn " $y_pos - $label_height - $rowspace"; - - #-----------------draw spine text - - # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows - if ( $page_break_count == $label_rows ) { - prPage(); - $page_break_count = 0; - $i2 = 0; - $y_pos = $y_pos_initial; - } - $page_break_count++; - $i2++; -} -prEnd(); - -#print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf"); - diff --git a/barcodes/label-print.pl b/barcodes/label-print.pl deleted file mode 100755 index acf6a515f2..0000000000 --- a/barcodes/label-print.pl +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/perl - -# This file is part of koha -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use CGI; -use C4::Auth; -use C4::Serials; -use C4::Output; -use C4::Context; - -use GD::Barcode::UPCE; -use Data::Random qw(:all); - -my $htdocs_path = C4::Context->config('intrahtdocs'); - -my $query = new CGI; - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "barcodes/label-print.tmpl", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => { tools => 1 }, - debug => 1, - } -); - -my $dbh = C4::Context->dbh; -my $query2 = "SELECT * FROM labels_conf LIMIT 1"; -my $sth = $dbh->prepare($query2); -$sth->execute(); - -my $conf_data = $sth->fetchrow_hashref; - -$sth->finish; - -my @data; -my $query3 = "Select * from labels"; -my $sth = $dbh->prepare($query3); -$sth->execute(); -my @resultsloop; -my $cnt = $sth->rows; -my $i1 = 1; -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 - biblioitems.biblionumber=biblio.biblionumber"; - - my $sth1 = $dbh->prepare($query1); - $sth1->execute( $data->{'itemnumber'} ); - my $data1 = $sth1->fetchrow_hashref(); - - push( @resultsloop, $data1 ); - $sth1->finish; - - $i1++; -} -$sth->finish; - -#------------------------------------------------------ - -#lets write barcode files to tmp dir for every item in @resultsloop - -binmode(FILE); -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 => \@resultsloop, - - 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'}, - 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'}, - subclass_opt => $conf_data->{'subclass'}, - itemcallnumber_opt => $conf_data->{'itemcallnumber'}, - - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), -); -output_html_with_http_headers $query, $cookie, $template->output; - diff --git a/barcodes/pdfViewer.pl b/barcodes/pdfViewer.pl deleted file mode 100755 index 4060224600..0000000000 --- a/barcodes/pdfViewer.pl +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/perl - -# script to show a PDF file. -# written 07/04 -# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and -# Castañeda Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina and - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -require Exporter; - -use strict; -use C4::Context; -use CGI; - -# This script take a pdf filename as a parameter and output it to the browser. -my $cgi = new CGI; -my $filename = "barcodes.pdf"; -my $tmpFileName = $cgi->param('tmpFileName'); -print "Content-Disposition: attachment; filename = $filename\n\n"; -print $cgi->header( -type => 'application/pdf' ), - $cgi->start_html( -title => "Codify to PDF" ); -open fh, "<$tmpFileName"; -while () { - print; -} -print $cgi->end_html(); diff --git a/barcodes/printerConfig.pl b/barcodes/printerConfig.pl deleted file mode 100755 index 174801bb60..0000000000 --- a/barcodes/printerConfig.pl +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/perl - -# script to set the labels configuration for the printer process. -# written 07/04 -# by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -require Exporter; - -use strict; - -use CGI; -use C4::Context; -use C4::Output; -use C4::Auth; - -use PDF::API2; -use PDF::API2::Page; -use PDF::API2::Util; - -# This function returns the path to deal with the correct files, considering -# templates set and language. -sub getPath { - my $type = shift @_; - my $templatesSet = C4::Context->preference('template'); - my $lang = C4::Context->preference('opaclanguages'); - if ( $type eq "intranet" ) { - return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang"; - } - else { - return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang"; - } -} - -# Load a configuration file. -sub loadConfFromFile { - my $fileName = shift @_; - my %keyValues; - open FILE, "<$fileName"; - while () { - chomp; - if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) { - $keyValues{$1} = $2; - } - } - close FILE; - return %keyValues; -} - -# Save settings to a configuration file. -sub saveConfToFile { - my $fileName = shift @_; - my %keyValues = %{ shift @_ }; - my $i; - open FILE, ">$fileName"; - my $i; - foreach $i ( keys(%keyValues) ) { - print FILE $i . " = " . $keyValues{$i} . "\n"; - } - close FILE; -} - -# Creates a CGI object and take his parameters -my $input = new CGI; - -if ( $input->param('saveSettings') ) { - my $labelConf = - &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf"; - my %newConfiguration = ( - pageType => $input->param('pageType'), - columns => $input->param('columns'), - rows => $input->param('rows'), - systemDpi => $input->param('systemDpi'), - labelWidth => $input->param('labelWidth'), - labelHeigth => $input->param('labelHeigth'), - marginBottom => $input->param('marginBottom'), - marginLeft => $input->param('marginLeft') - ); - saveConfToFile( $labelConf, \%newConfiguration ); - print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl'); -} - -# Get the template to use -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "barcodes/printerConfig.tmpl", - type => "intranet", - query => $input, - authnotrequired => 0, - flagsrequired => { tools => 1 }, - debug => 1, - } -); - -my $filenameConf = - &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf"; -my %labelConfig = &loadConfFromFile($filenameConf); - -$template->param( COLUMNS => $labelConfig{'columns'} ); -$template->param( ROWS => $labelConfig{'rows'} ); -$template->param( SYSTEM_DPI => $labelConfig{'systemDpi'} ); -$template->param( LABEL_WIDTH => $labelConfig{'labelWidth'} ); -$template->param( LABEL_HEIGTH => $labelConfig{'labelHeigth'} ); -$template->param( MARGIN_TOP => $labelConfig{'marginBottom'} ); -$template->param( MARGIN_LEFT => $labelConfig{'marginLeft'} ); -$template->param( SCRIPT_NAME => '/cgi-bin/koha/barcodes/printerConfig.pl' ); -$template->param( "$labelConfig{'pageType'}" => 1 ); -$template->param( - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), -); -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/barcodes/test.textblock.pl b/barcodes/test.textblock.pl deleted file mode 100755 index 67d9c9ba3f..0000000000 --- a/barcodes/test.textblock.pl +++ /dev/null @@ -1,33 +0,0 @@ -#!/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"); diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index 7717c083f0..d3c89278eb 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -912,6 +912,7 @@ CREATE TABLE `itemtypes` ( DROP TABLE IF EXISTS `labels`; CREATE TABLE `labels` ( `labelid` int(11) NOT NULL auto_increment, + `batch_id` varchar(10) NOT NULL, `itemnumber` varchar(100) NOT NULL default '', `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`labelid`) diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/barcodes.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/barcodes.tmpl deleted file mode 100644 index 26b7fe369e..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/barcodes.tmpl +++ /dev/null @@ -1,85 +0,0 @@ - -Koha › Label and Barcode Printing - - - - - - -
-
- -

Add a new Country Code

-
    -
  • -
  • -
- - -
-
- - - -

Barcodes Generator

-

Generate barcodes from inventory codes

-
    -
  • Select a range of inventary codes. You can choose a continuous range or individual inventory codes
  • -
  • Select the standard type to generate barcodes.
  • -
  • Define the page size for output the PDF.
  • -
  • Depending on page size, Koha will show you how the page is arranged - for each barcode. You can define wich point to start printing the page. -
  • -
- -Can't find inventory codes in that range. Please try again. - -
" name="form1" onsubmit="return checkFields(this);" target="_blank"> - - -
-
    -
  • -
  • -
-
- - - - -

-[+]

- -

" size="10" />[Go to Printer Configuration]

- - -

- " /> If this field is empty, author and title will be used instead

- - - - - - - - - - - - -
">Label number to start printing
- " name="label" > Label
- - - -
- - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-create-template.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-create-template.tmpl deleted file mode 100644 index a40db5aa0c..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-create-template.tmpl +++ /dev/null @@ -1,69 +0,0 @@ - -Koha › Label and Barcode Printing - - - - - -
-
- -

- Create Label Template -

- - - -

Template Settings

- - -Template Code:
-Template Description:
- - - - - - - - - - - - - - - - - - - - - -
Page Width:Page Height:
Label Width:Label Height:
Top Page Margin:Left Page Margin:
Number of Columns:Number of Rows:
Gap between Columns:Gap between Rows:
- - -
-Units: - -
-
-Font Size: -
-
-Active: - - -
-
- - -
-
- - diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-home.tmpl deleted file mode 100644 index de92f94f5a..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-home.tmpl +++ /dev/null @@ -1,189 +0,0 @@ - -Koha › Label and Barcode Printing - - - - -
- -

- Choose Fields to Print -

- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - -
-

- -

Confirm Label Template

- - - -

Confirm Barcode Type

- - - - -

Confirm Printing Type

- - - - - - - Spine Labels - - - - - -Barcode Labels - - - - - - -Both Labels - -

- Start printing from Label number:"> - -

- -

-

- - - - - - -

- - -

-
- - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-manager.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-manager.tmpl deleted file mode 100644 index 4a9d11382a..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-manager.tmpl +++ /dev/null @@ -1,60 +0,0 @@ - -Koha › Label and Barcode Printing - - - - -
-

Labels to be Printed

-

- Printing will start on row
- Printing will use sheets
- Currently rows spare on sheet -

- - -

Items

- - - - - - - - - - - - - - - -
Label NumberSummaryItem TypeDelete
- - - "> : : - : - - - - ">Delete -
- -


- Add Item    - Preview    - Delete All -

- - Add Item - - -
- - - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-templates.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-templates.tmpl deleted file mode 100644 index cd61f1c0e6..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-templates.tmpl +++ /dev/null @@ -1,52 +0,0 @@ - -Koha › Label and Barcode Printing - - - - -
-

Current Templates - - -

- - -

Templates

- - - - - - - - - - - - - - - - - -
Template CodeDescriptionEditDeleteActive
- - - - - ">Edit - - ">Delete - - Active -
- -


- - Create New Label Template - - - -

- - diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/printerConfig.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/printerConfig.tmpl deleted file mode 100644 index 1d04674585..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/printerConfig.tmpl +++ /dev/null @@ -1,88 +0,0 @@ - -Koha › Printer Configuration - - - - - -

Printer Configuration

-

Set printer configuration corresponding to your environment

-
    -
  • Set width and height of the label that you are going to work with.
  • -
  • Set your system's default DPI.
  • -
  • Set the page type.
  • -
  • Select how many columns and rows are in your page type.
  • -
  • Set left- and bottom-margins of the page that you are going to use. This parameter will help to center the barcodes on the labels.
  • -
-
-
" name="form1"> - - - - - - - - - - - -
- Label width (Expressed in mm) - - "> -
- Label heigth (Expressed in mm) - - "> -
- System dpi - - "> -
- Page Type - - -
- Columns - - "> -
- Rows - - "> -
- Margin Bottom (Expressed in mm) - - "> -
- Margin Left (Expressed in mm) - - "> -
-
- - diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/barcodes/search.tmpl deleted file mode 100644 index acb2c93fd9..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/search.tmpl +++ /dev/null @@ -1,60 +0,0 @@ - -Koha › Label and Barcode Printing › Search - - - - - -
- -

Catalogue Item Search

- -
- - - " /> - - - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - -
-

-
-
- diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc new file mode 100644 index 0000000000..88d85edfcb --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc @@ -0,0 +1,7 @@ +
+ + + + +
Layout:Select a Label Layout
Template: Select a Label Template
Batch: Select items to print
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/menu-labels.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/menu-labels.inc new file mode 100755 index 0000000000..d54babbb21 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/menu-labels.inc @@ -0,0 +1,8 @@ + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-bib-search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/labels/label-bib-search.tmpl similarity index 86% rename from koha-tmpl/intranet-tmpl/prog/en/barcodes/label-bib-search.tmpl rename to koha-tmpl/intranet-tmpl/prog/en/labels/label-bib-search.tmpl index 6ce3faeb49..82feff00ff 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-bib-search.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/labels/label-bib-search.tmpl @@ -1,6 +1,4 @@ - -Koha › Label and Barcode Printing › Search - +Koha -- Barcodes and Labels: Search

Search

diff --git a/koha-tmpl/intranet-tmpl/prog/en/labels/label-create-layout.tmpl b/koha-tmpl/intranet-tmpl/prog/en/labels/label-create-layout.tmpl new file mode 100644 index 0000000000..df5f979f18 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/labels/label-create-layout.tmpl @@ -0,0 +1,281 @@ +Koha › Labels + + + + +
+ +
+ + + +

+ Layout Name + +

+"> + + +

+

+

+ + + +

+ Choose Order Of Fields to Print +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + +
+

+ + + +

Choose Barcode Type

+ + + + +

Choose Layout Type

+ + + + + +

+ Start printing from Label number: + + +

+ +

+

+

Draw Guide Boxes

+

+

+

+ + +

+
+
+ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/labels/label-create-template.tmpl b/koha-tmpl/intranet-tmpl/prog/en/labels/label-create-template.tmpl new file mode 100644 index 0000000000..0fea0072b3 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/labels/label-create-template.tmpl @@ -0,0 +1,64 @@ +Koha › Labels + + + + +
+ +
+ +

+ Create Label Template +

+ + + +

Template Settings

+ + +Template Code:
+Template Description:
+ + + + + + + + + + + + + + + + + + + + + +
Page Width:Page Height:
Label Width:Label Height:
Top Page Margin:Left Page Margin:
Number of Columns:Number of Rows:
Gap between Columns:Gap between Rows:
+ + +
+Units: + +
+
+Font Size: +
+
+ + + +
+
+ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-layout.tmpl b/koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-layout.tmpl new file mode 100644 index 0000000000..aa0fd867d3 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-layout.tmpl @@ -0,0 +1,182 @@ +Koha -- Labels + + + + +
+ +
+ +

Layout Name

+"> + +
+
+ +

Choose Barcode Type (encoding)

+ +
+ +

Choose Layout Type

+ + +
+
+ +

+ Choose Order Of Text Fields to Print +

+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + +
+ +
+

+ Start printing from Label number: "> +

+ +
+

Draw Guide Boxes + checked + >

+ +

+ + + "> +

+
+
+ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-edit-template.tmpl b/koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-template.tmpl similarity index 52% rename from koha-tmpl/intranet-tmpl/prog/en/barcodes/label-edit-template.tmpl rename to koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-template.tmpl index abab686492..c955f22344 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/barcodes/label-edit-template.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/labels/label-edit-template.tmpl @@ -1,12 +1,10 @@ - -Koha › Label and Barcode Printing +Koha › Labels - - - + +
-
+

Edit Label Template @@ -22,24 +20,24 @@ Template Code:
- Page Width:"> - Page Height:"> + Page Width:"> + Page Height:"> - Label Width:"> - Label Height:"> + Label Width:"> + Label Height:"> - Top Page Margin:"> - Left Page Margin:"> + Top Page Margin:"> + Left Page Margin:"> - Number of Columns:"> - Number of Rows:"> + Number of Columns:"> + Number of Rows:"> - Gap between Columns:"> - Gap between Rows:"> + Gap between Columns:"> + Gap between Rows:"> @@ -48,11 +46,9 @@ Template Description: