[Koha-cvs] CVS: koha/acqui.simple marcimport.pl,1.6.2.1,1.6.2.2

Alan Millar amillar at users.sourceforge.net
Tue May 28 16:43:48 CEST 2002


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

Modified Files:
      Tag: rel-1-2
	marcimport.pl 
Log Message:
Add item using newitem() from C4::Acquisitions




Index: marcimport.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/marcimport.pl,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -C2 -r1.6.2.1 -r1.6.2.2
*** marcimport.pl	27 May 2002 04:33:05 -0000	1.6.2.1
--- marcimport.pl	28 May 2002 14:43:45 -0000	1.6.2.2
***************
*** 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