From 23af68684c78e30cf76ad20240bddd79a1be0968 Mon Sep 17 00:00:00 2001 From: rangi Date: Wed, 3 Apr 2002 08:44:23 +0000 Subject: [PATCH] More work on the addbooks scripts, committing on behalf of Roger Need testing before use in a production environment --- acqui.simple/addbooks.pl | 39 ++++++++++++++++++++++++------------ acqui.simple/addbookslccn.pl | 32 ++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/acqui.simple/addbooks.pl b/acqui.simple/addbooks.pl index 1ff804ff39..84569afda0 100755 --- a/acqui.simple/addbooks.pl +++ b/acqui.simple/addbooks.pl @@ -1,10 +1,17 @@ #!/usr/bin/perl +# +# Modified saas@users.sf.net 12:00 01 April 2001 +# The biblioitemnumber was not correctly initialised +# The max(barcode) value was broken - koha 'barcode' is a string value! +# - If left blank, barcode value now defaults to max(biblionumber) + # # TODO # -# Add info on biblioitems and items already entered as you enter new ones +# Error checking for pre-existing barcodes, biblionumbers and maybe others # +# Add info on biblioitems and items already entered as you enter new ones use C4::Database; use CGI; @@ -16,7 +23,6 @@ use C4::Circulation::Circ2; my $input = new CGI; my $dbh=C4Connect; - my $isbn=$input->param('isbn'); my $q_isbn=$dbh->quote($isbn); my $biblioitemnumber; @@ -138,8 +144,6 @@ EOF Notes - - @@ -198,6 +202,7 @@ sub newbiblioitem { $sth->execute; ($biblioitemnumber) = $sth->fetchrow; $biblioitemnumber++; +# print STDERR "NEW BiblioItemNumber: $biblioitemnumber \n"; ($q_isbn='') if ($q_isbn eq 'NULL'); my $query="insert into biblioitems (biblioitemnumber, biblionumber, volume, number, classification, itemtype, isbn, issn, lccn, dewey, subclass, @@ -272,10 +277,18 @@ sub newitem { if ($isbn) { my $sth; if ($isbn eq 'NULL') { + # set biblioitemnumber if not already initialised... + if ($biblioitemnumber eq '') { + $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems"); + $sth->execute; + ($biblioitemnumber) = $sth->fetchrow; + $biblioitemnumber++; +# print STDERR "BiblioItemNumber was missing: $biblioitemnumber \n"; + } $sth=$dbh->prepare("select biblionumber,biblioitemnumber from biblioitems where biblioitemnumber=$biblioitemnumber"); } else { - $sth=$dbh->prepare("select biblionumber,biblioitemnumber from + $sth=$dbh->prepare("select biblionumber, biblioitemnumber from biblioitems where isbn=$q_isbn"); } $sth->execute; @@ -288,6 +301,7 @@ if ($isbn) { $itemdata.="$barcode$title$author$itemnotes\n"; } + if ($itemdata) { print << "EOF";
@@ -304,10 +318,11 @@ if ($isbn) { EOF } - my $sth=$dbh->prepare("select max(barcode) from items"); - $sth->execute; - my ($maxbarcode) = $sth->fetchrow; - $maxbarcode++; +# my $sth=$dbh->prepare("select max(barcode) from items"); +# $sth->execute; +# my ($maxbarcode) = $sth->fetchrow; +# $maxbarcode++; +# print STDERR "MaxBarcode: $maxbarcode \n"; print << "EOF";

Section Three: Specific Item Information

@@ -316,7 +331,8 @@ EOF -
BARCODE + +
BARCODE Home Branch: -
BARCODE Home Branch:
BARCODE +Home Branch: