Browse Source

More work on the addbooks scripts, committing on behalf of Roger

Need testing before use in a production environment
3.0.x
rangi 23 years ago
parent
commit
23af68684c
  1. 39
      acqui.simple/addbooks.pl
  2. 32
      acqui.simple/addbookslccn.pl

39
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
<tr><td align=right>Notes</td><td colspan=3><textarea name=notes rows=4 cols=50
wrap=physical></textarea></td></tr>
</table>
<input type=submit value="Add New Bibliography Item">
</center>
@ -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.="<tr><td align=center>$barcode</td><td><u>$title</u></td><td>$author</td><td>$itemnotes</td></tr>\n";
}
if ($itemdata) {
print << "EOF";
<center>
@ -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";
<center>
<h2>Section Three: Specific Item Information</h2>
@ -316,7 +331,8 @@ EOF
<input type=hidden name=biblionumber value=$biblionumber>
<input type=hidden name=biblioitemnumber value=$biblioitemnumber>
<table>
<tr><td>BARCODE</td><td><input name=barcode size=10 value=$maxbarcode>
<!-- tr><td>BARCODE</td><td><input name=barcode size=10 value=\$maxbarcode -->
<tr><td>BARCODE</td><td><input name=barcode size=10 value=$biblionumber>
Home Branch: <select name=homebranch>
EOF
@ -382,9 +398,6 @@ print endmenu();
print endpage();
sub sectioninfo {
print << "EOF";
<center>

32
acqui.simple/addbookslccn.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 $lccn=$input->param('lccn');
my $q_lccn=$dbh->quote($lccn);
my $biblioitemnumber;
@ -196,6 +202,7 @@ sub newbiblioitem {
$sth->execute;
($biblioitemnumber) = $sth->fetchrow;
$biblioitemnumber++;
# print STDERR "NEW BiblioItemNumber: $biblioitemnumber \n";
($q_lccn='') if ($q_lccn eq 'NULL');
$sth=$dbh->prepare("insert into biblioitems (biblioitemnumber,
biblionumber, volume, number, classification, itemtype, isbn, issn, lccn, dewey, subclass,
@ -266,6 +273,14 @@ sub newitem {
if ($lccn) {
my $sth;
if ($lccn 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 {
@ -298,10 +313,11 @@ if ($lccn) {
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";
print << "EOF";
<center>
<h2>Section Three: Specific Item Information</h2>
@ -310,7 +326,9 @@ EOF
<input type=hidden name=biblionumber value=$biblionumber>
<input type=hidden name=biblioitemnumber value=$biblioitemnumber>
<table>
<tr><td>BARCODE</td><td><input name=barcode size=10 value=$maxbarcode> Home Branch: <select name=homebranch>
<!-- tr><td>BARCODE</td><td><input name=barcode size=10 value=\$maxbarcode -->
<tr><td>BARCODE</td><td><input name=barcode size=10 value=$biblionumber>
Home Branch: <select name=homebranch>
EOF
my $branches=getbranches();
foreach my $key (sort(keys %$branches)) {

Loading…
Cancel
Save