7 use Data::Dump qw(dump);
10 binmode STDOUT, ':encoding(UTF-8)';
14 my $barcode = $q->param('barcode');
15 warn "# barcode: $barcode\n";
16 $q->delete('barcode'); # empty form field
20 $ENV{REQUEST_URI} =~ s{/intranet/}{/cgi-bin/koha/}; # fix plack rewrite
22 print $q->header( -charset => 'utf-8' ), qq{
26 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
32 <title>Inventura</title>
38 my ($status, $cookie, $sessionId) = C4::Auth::check_api_auth($q, { tools => 'inventory' });
39 if ($status ne "ok") {
40 print "This requres tools - inventory permission";
46 $q->start_form( -autocomplete => 'off' )
47 , $q->textfield( -name => 'barcode', -autofocus => 'autofocus' )
48 , $q->submit( -value => 'Search' )
49 # , $q->checkbox( -name => 'izdatnice', -label => 'izdatnice' )
50 # , $q->checkbox( -name => 'proizvodi', -label => 'prozivodi', -checked => 1 )
54 <script type="text/javascript">
55 document.getElementsByName('barcode')[0].focus();
63 my $dbh = C4::Context->dbh;
68 items.biblionumber as biblionumber,
72 join biblio on items.biblionumber = biblio.biblionumber
78 my $sth = $dbh->prepare( $sql );
79 $sth->execute( $barcode );
82 $row = $sth->fetchrow_hashref;
85 BARCODE: <tt>$barcode</tt><br>
86 TITLE: <b>$row->{title}</b><br>
87 AUTHOR: $row->{author}<br>
90 my $sth_update = $dbh->prepare(qq{
91 update items set datelastseen = now() where barcode = ?
93 $sth_update->execute( $barcode );
95 my $sth_inventura = $dbh->prepare(qq{
96 insert ignore into fer_inventura (date_scanned,barcode,source_id) values (date(now()), ?, ?)
98 $sth_inventura->execute( $barcode, C4::Context->userenv->{'id'} );
100 my $sth_issues = $dbh->prepare(qq{
101 select firstname,surname,userid,email from issues join borrowers on issues.borrowernumber = borrowers.borrowernumber where itemnumber = ?
104 $sth_issues->execute( $row->{'itemnumber'} );
105 while ( my $row = $sth_issues->fetchrow_hashref ) {
106 warn "# issues row ",dump($row);
107 print "issued to ", $row->{firstname}, ' ', $row->{surname}, " returning...";
108 AddReturn( $barcode, C4::Context->userenv->{'branch'} );
111 print "no barcode $barcode\n";
112 warn "ERROR: can't find $barcode\n";