[Koha-cvs] CVS: koha/acqui.simple marcimport.pl,1.7,1.8

Alan Millar amillar at users.sourceforge.net
Tue May 21 08:17:50 CEST 2002


Update of /cvsroot/koha/koha/acqui.simple
In directory usw-pr-cvs1:/tmp/cvs-serv23217

Modified Files:
	marcimport.pl 
Log Message:

Add item using newitem() from C4::Acquisitions.pm


Index: marcimport.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/marcimport.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** marcimport.pl	20 May 2002 04:55:20 -0000	1.7
--- marcimport.pl	21 May 2002 06:17:48 -0000	1.8
***************
*** 396,421 ****
  
  if ($input->param('newitem')) {
      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;
      if ($sth->rows) {
  	print "<font color=red>Barcode '$barcode' has already been assigned.</font><p>\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;
!     }
  }
  
--- 396,425 ----
  
  if ($input->param('newitem')) {
+     use strict;
+     my $error;
      my $barcode=$input->param('barcode');
      my $replacementprice=($input->param('replacementprice') || 0);
! 
!     my $sth=$dbh->prepare("select barcode 
! 	from items 
! 	where barcode=?");
!     $sth->execute($barcode);
      if ($sth->rows) {
  	print "<font color=red>Barcode '$barcode' has already been assigned.</font><p>\n";
      } else {
! 	   # 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 "<font color=red>Error: $error </font><p>\n";
!             } # if error
!     } # if barcode exists
  }
  





More information about the Koha-cvs mailing list