From 9af1253ce35099d6d17329f131730f28b95c809c Mon Sep 17 00:00:00 2001 From: amillar Date: Tue, 21 May 2002 06:17:48 +0000 Subject: [PATCH] Add item using newitem() from C4::Acquisitions.pm --- acqui.simple/marcimport.pl | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/acqui.simple/marcimport.pl b/acqui.simple/marcimport.pl index 709daa2f59..5df3765e6b 100755 --- a/acqui.simple/marcimport.pl +++ b/acqui.simple/marcimport.pl @@ -395,28 +395,32 @@ exit; } if ($input->param('newitem')) { + use strict; + my $error; my $barcode=$input->param('barcode'); - my $q_barcode=$dbh->quote($barcode); - my $q_notes=$dbh->quote($input->param('notes')); - my $q_homebranch=$dbh->quote($input->param('homebranch')); - my $biblionumber=$input->param('biblionumber'); - my $biblioitemnumber=$input->param('biblioitemnumber'); my $replacementprice=($input->param('replacementprice') || 0); - my $sth=$dbh->prepare("select barcode from items where - barcode=$q_barcode"); - $sth->execute; + + my $sth=$dbh->prepare("select barcode + from items + where barcode=?"); + $sth->execute($barcode); if ($sth->rows) { print "Barcode '$barcode' has already been assigned.

\n"; } else { - $sth=$dbh->prepare("select max(itemnumber) from items"); - $sth->execute; - my ($itemnumber) = $sth->fetchrow; - $itemnumber++; - my @datearr=localtime(time); - my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3]; - $sth=$dbh->prepare("insert into items (itemnumber, biblionumber, biblioitemnumber, barcode, itemnotes, homebranch, holdingbranch, dateaccessioned, replacementprice) values ($itemnumber, $biblionumber, $biblioitemnumber, $q_barcode, $q_notes, $q_homebranch, 'STWE', '$date', $replacementprice)"); - $sth->execute; - } + # Insert new item into database + $error=&newitems( + { biblionumber=> $input->param('biblionumber'), + biblioitemnumber=> $input->param('biblioitemnumber'), + itemnotes=> $input->param('notes'), + homebranch=> $input->param('homebranch'), + replacementprice=> $replacementprice, + }, + $barcode + ); + if ( $error ) { + print "Error: $error

\n"; + } # if error + } # if barcode exists } -- 2.39.5