From 4da24ba00649b093be96dbed50631833cf0ccdaf Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 30 Oct 2018 08:29:08 +0100 Subject: [PATCH] simplest possible mojo web scan barcode app --- barcode-seen.pl | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 barcode-seen.pl diff --git a/barcode-seen.pl b/barcode-seen.pl new file mode 100755 index 0000000..405c5df --- /dev/null +++ b/barcode-seen.pl @@ -0,0 +1,68 @@ +#!/usr/bin/env perl +use Mojolicious::Lite; + +use lib '/srv/koha_ffzg'; +BEGIN { + $ENV{KOHA_CONF} = '/etc/koha/sites/ffzg/koha-conf.xml'; +} +use C4::Context; + +use Data::Dump qw(dump); + +my $sql = qq{ +select + title, + author +from items +join biblio on biblio.biblionumber = items.biblionumber where barcode = ? +}; + +my $dbh = C4::Context->dbh; +my $sth = $dbh->prepare($sql); + +my $sth_update = $dbh->prepare(qq{ +update items set datelastseen = now() where barcode = ? +}); + +get '/' => sub { + my $c = shift; + + my $barcode = $c->param('barcode'); + warn "# $barcode"; + $sth->execute( $barcode ); + while ( my $row = $sth->fetchrow_hashref ) { + warn "# row ",dump($row); + $c->stash( $_ => $row->{$_} ) foreach keys %$row; + } + $sth_update->execute( $barcode ); + $c->render(template => 'index'); +}; + +app->start; +__DATA__ + +@@ index.html.ep +% layout 'default'; + +%= form_for '/' => begin + %#= text_field 'barcode' + + %= submit_button 'Scan' +% end + +<%= stash('author') %> +<%= stash('title') %> + +@@ layouts/default.html.ep + + + + + Inventura + + <%= content %> + -- 2.20.1