8 use C4::Interface::CGI::Output;
11 use GD::Barcode::UPCE;
12 use Data::Random qw(:all);
14 my $htdocs_path = C4::Context->config('intrahtdocs');
20 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
22 template_name => "barcodes/label-print.tmpl",
26 flagsrequired => { catalogue => 1 },
31 my $dbh = C4::Context->dbh;
32 my $query2 = "SELECT * FROM labels_conf LIMIT 1";
33 my $sth = $dbh->prepare($query2);
36 my $conf_data = $sth->fetchrow_hashref;
38 #warn Dumper $conf_data;
43 my $query3 = "Select * from labels";
44 my $sth = $dbh->prepare($query3);
49 while ( my $data = $sth->fetchrow_hashref ) {
51 # lets get some summary info from each item
54 select * from biblio,biblioitems,items where itemnumber=? and
55 items.biblioitemnumber=biblioitems.biblioitemnumber and
56 biblioitems.biblionumber=biblio.biblionumber";
58 my $sth1 = $dbh->prepare($query1);
59 $sth1->execute( $data->{'itemnumber'} );
60 my $data1 = $sth1->fetchrow_hashref();
62 push( @resultsloop, $data1 );
69 #warn Dumper @resultsloop;
74 #------------------------------------------------------
76 #lets write barcode files to tmp dir for every item in @resultsloop
81 foreach my $item (@resultsloop){
84 my $random = int( rand(100000000000)) + 999999999999;
87 $item->{'barcode'} = $random;
89 # my $itembarcode = $item->{'barcode'};
90 # warn $item->{'barcode'};
93 my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
95 open(FILE, ">$filename");
97 print FILE GD::Barcode->new('EAN13', $item->{'barcode'})->plot->png;
98 # warn $GD::Barcode::errStr;
102 #warn Dumper $item->{'barcode'};
110 # lets pass the config setting
114 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'},
131 intranetcolorstylesheet =>
132 C4::Context->preference("intranetcolorstylesheet"),
133 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
134 IntranetNav => C4::Context->preference("IntranetNav"),
136 output_html_with_http_headers $query, $cookie, $template->output;