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
23 use C4::Interface::CGI::Output;
26 use GD::Barcode::UPCE;
27 use Data::Random qw(:all);
29 my $htdocs_path = C4::Context->config('intrahtdocs');
33 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35 template_name => "barcodes/label-print.tmpl",
39 flagsrequired => { tools => 1 },
44 my $dbh = C4::Context->dbh;
45 my $query2 = "SELECT * FROM labels_conf LIMIT 1";
46 my $sth = $dbh->prepare($query2);
49 my $conf_data = $sth->fetchrow_hashref;
54 my $query3 = "Select * from labels";
55 my $sth = $dbh->prepare($query3);
60 while ( my $data = $sth->fetchrow_hashref ) {
62 # lets get some summary info from each item
65 select * from biblio,biblioitems,items where itemnumber=? and
66 items.biblioitemnumber=biblioitems.biblioitemnumber and
67 biblioitems.biblionumber=biblio.biblionumber";
69 my $sth1 = $dbh->prepare($query1);
70 $sth1->execute( $data->{'itemnumber'} );
71 my $data1 = $sth1->fetchrow_hashref();
73 push( @resultsloop, $data1 );
80 #------------------------------------------------------
82 #lets write barcode files to tmp dir for every item in @resultsloop
85 foreach my $item (@resultsloop) {
87 my $random = int( rand(100000000000) ) + 999999999999;
91 $item->{'barcode'} = $random;
93 # my $itembarcode = $item->{'barcode'};
94 # warn $item->{'barcode'};
96 my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
99 open( FILE, ">$filename" );
101 print FILE GD::Barcode->new( 'EAN13', $item->{'barcode'} )->plot->png;
103 # warn $GD::Barcode::errStr;
107 #warn Dumper $item->{'barcode'};
111 # lets pass the config setting
115 resultsloop => \@resultsloop,
117 itemtype_opt => $conf_data->{'itemtype'},
118 papertype_opt => $conf_data->{'papertype'},
119 author_opt => $conf_data->{'author'},
120 barcode_opt => $conf_data->{'barcode'},
121 id_opt => $conf_data->{'id'},
122 type_opt => $conf_data->{'type'},
123 title_opt => $conf_data->{'title'},
124 isbn_opt => $conf_data->{'isbn'},
125 dewey_opt => $conf_data->{'dewey'},
126 class_opt => $conf_data->{'class'},
127 subclass_opt => $conf_data->{'subclass'},
128 itemcallnumber_opt => $conf_data->{'itemcallnumber'},
130 intranetcolorstylesheet =>
131 C4::Context->preference("intranetcolorstylesheet"),
132 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
133 IntranetNav => C4::Context->preference("IntranetNav"),
135 output_html_with_http_headers $query, $cookie, $template->output;