3 # This file is part of koha
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
25 use GD::Barcode::UPCE;
26 use Data::Random qw(:all);
28 my $htdocs_path = C4::Context->config('intrahtdocs');
32 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34 template_name => "barcodes/label-print.tmpl",
38 flagsrequired => { tools => 1 },
43 my $dbh = C4::Context->dbh;
44 my $query2 = "SELECT * FROM labels_conf LIMIT 1";
45 my $sth = $dbh->prepare($query2);
48 my $conf_data = $sth->fetchrow_hashref;
53 my $query3 = "Select * from labels";
54 my $sth = $dbh->prepare($query3);
59 while ( my $data = $sth->fetchrow_hashref ) {
61 # lets get some summary info from each item
64 select * from biblio,biblioitems,items where itemnumber=? and
65 items.biblioitemnumber=biblioitems.biblioitemnumber and
66 biblioitems.biblionumber=biblio.biblionumber";
68 my $sth1 = $dbh->prepare($query1);
69 $sth1->execute( $data->{'itemnumber'} );
70 my $data1 = $sth1->fetchrow_hashref();
72 push( @resultsloop, $data1 );
79 #------------------------------------------------------
81 #lets write barcode files to tmp dir for every item in @resultsloop
84 foreach my $item (@resultsloop) {
86 my $random = int( rand(100000000000) ) + 999999999999;
90 $item->{'barcode'} = $random;
92 # my $itembarcode = $item->{'barcode'};
93 # warn $item->{'barcode'};
95 my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
98 open( FILE, ">$filename" );
100 print FILE GD::Barcode->new( 'EAN13', $item->{'barcode'} )->plot->png;
102 # warn $GD::Barcode::errStr;
106 #warn Dumper $item->{'barcode'};
110 # lets pass the config setting
114 resultsloop => \@resultsloop,
116 itemtype_opt => $conf_data->{'itemtype'},
117 papertype_opt => $conf_data->{'papertype'},
118 author_opt => $conf_data->{'author'},
119 barcode_opt => $conf_data->{'barcode'},
120 id_opt => $conf_data->{'id'},
121 type_opt => $conf_data->{'type'},
122 title_opt => $conf_data->{'title'},
123 isbn_opt => $conf_data->{'isbn'},
124 dewey_opt => $conf_data->{'dewey'},
125 class_opt => $conf_data->{'class'},
126 subclass_opt => $conf_data->{'subclass'},
127 itemcallnumber_opt => $conf_data->{'itemcallnumber'},
129 intranetcolorstylesheet =>
130 C4::Context->preference("intranetcolorstylesheet"),
131 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
132 IntranetNav => C4::Context->preference("IntranetNav"),
134 output_html_with_http_headers $query, $cookie, $template->output;