[Koha-cvs] CVS: koha/acqui.simple addbiblio.pl,1.59,1.60 additem.pl,1.31,1.32

Paul POULAIN tipaul at users.sourceforge.net
Tue Aug 9 16:11:07 CEST 2005


Update of /cvsroot/koha/koha/acqui.simple
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23879/acqui.simple

Modified Files:
	addbiblio.pl additem.pl 
Log Message:
1st commit to go to zebra.
don't update your cvs if you want to have a working head...

this commit contains :
* updater/updatedatabase : get rid with marc_* tables, but DON'T remove them. As a lot of things uses them, it would not be a good idea for instance to drop them. If you really want to play, you can rename them to test head without them but being still able to reintroduce them...
* Biblio.pm : modify MARCgetbiblio to find the raw marc record in biblioitems.marc field, not from marc_subfield_table, modify MARCfindframeworkcode to find frameworkcode in biblio.frameworkcode, modify some other subs to use biblio.biblionumber & get rid of bibid.
* other files : get rid of bibid and use biblionumber instead.

What is broken :
* does not do anything on zebra yet.
* if you rename marc_subfield_table, you can't search anymore.
* you can view a biblio & bibliodetails, go to MARC editor, but NOT save any modif.
* don't try to add a biblio, it would add data poorly... (don't try to delete either, it may work, but that would be a surprise ;-) )

IMPORTANT NOTE : you need MARC::XML package (http://search.cpan.org/~esummers/MARC-XML-0.7/lib/MARC/File/XML.pm), that requires a recent version of MARC::Record
Updatedatabase stores the iso2709 data in biblioitems.marc field & an xml version in biblioitems.marcxml Not sure we will keep it when releasing the stable version, but I think it's a good idea to have something readable in sql, at least for development stage.

Index: addbiblio.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/addbiblio.pl,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -r1.59 -r1.60
*** addbiblio.pl	4 Aug 2005 12:12:13 -0000	1.59
--- addbiblio.pl	9 Aug 2005 14:10:27 -0000	1.60
***************
*** 154,157 ****
--- 154,158 ----
  				-default  => $value,
  				-labels   => \%authorised_lib,
+ 				-override => 1,
  				-size     => 1,
  				-multiple => 0 );
***************
*** 347,351 ****
  my $input = new CGI;
  my $error = $input->param('error');
! my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a modif, not a new biblio.
  my $breedingid = $input->param('breedingid');
  my $z3950 = $input->param('z3950');
--- 348,352 ----
  my $input = new CGI;
  my $error = $input->param('error');
! my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
  my $breedingid = $input->param('breedingid');
  my $z3950 = $input->param('z3950');
***************
*** 353,367 ****
  my $frameworkcode = $input->param('frameworkcode');
  my $dbh = C4::Context->dbh;
- my $bibid;
  
  
! if ($oldbiblionumber) {
! 	$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$oldbiblionumber);
! 	# find framework type
! 	$frameworkcode = &MARCfind_frameworkcode($dbh,$bibid) if ($bibid and not ($frameworkcode));
! }else {
! 	$bibid = $input->param('bibid');
! 	$frameworkcode = &MARCfind_frameworkcode($dbh,$bibid) if ($bibid and not ($frameworkcode));
! }
  $frameworkcode='' if ($frameworkcode eq 'Default');
  my ($template, $loggedinuser, $cookie)
--- 354,360 ----
  my $frameworkcode = $input->param('frameworkcode');
  my $dbh = C4::Context->dbh;
  
  
! $frameworkcode = &MARCfind_frameworkcode($dbh,$biblionumber) if ($biblionumber and not ($frameworkcode));
  $frameworkcode='' if ($frameworkcode eq 'Default');
  my ($template, $loggedinuser, $cookie)
***************
*** 400,404 ****
  my $record=-1;
  my $encoding="";
! $record = MARCgetbiblio($dbh,$bibid) if ($bibid);
  ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
  
--- 393,397 ----
  my $record=-1;
  my $encoding="";
! $record = MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
  ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
  
***************
*** 406,410 ****
  my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
  my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber);
! if ($bibid) {
  	$is_a_modif=1;
  	# if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB.
--- 399,403 ----
  my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
  my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber);
! if ($biblionumber) {
  	$is_a_modif=1;
  	# if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB.
***************
*** 413,417 ****
  	# search biblioitems value
  	my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
! 	$sth->execute($oldbiblionumber);
  	($oldbiblioitemnumber) = $sth->fetchrow;
  }
--- 406,410 ----
  	# search biblioitems value
  	my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
! 	$sth->execute($biblionumber);
  	($oldbiblioitemnumber) = $sth->fetchrow;
  }
***************
*** 440,452 ****
  		my $oldbibitemnum;
  		if ($is_a_modif) {
! 			NEWmodbiblioframework($dbh,$bibid,$frameworkcode);
! 			NEWmodbiblio($dbh,$record,$bibid,$frameworkcode);
! 			logaction($loggedinuser,"acqui.simple","modify",$oldbiblionumber,"record : ".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
  		} else {
! 			($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode);
  			logaction($loggedinuser,"acqui.simple","add",$oldbibnum,"record : ".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
  		}
  	# now, redirect to additem page
! 		print $input->redirect("additem.pl?bibid=$bibid&frameworkcode=$frameworkcode");
  		exit;
  	} else {
--- 433,445 ----
  		my $oldbibitemnum;
  		if ($is_a_modif) {
! 			NEWmodbiblioframework($dbh,$biblionumber,$frameworkcode);
! 			NEWmodbiblio($dbh,$record,$biblionumber,$frameworkcode);
! 			logaction($loggedinuser,"acqui.simple","modify",$biblionumber,"record : ".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
  		} else {
! 			($biblionumber,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode);
  			logaction($loggedinuser,"acqui.simple","add",$oldbibnum,"record : ".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
  		}
  	# now, redirect to additem page
! 		print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
  		exit;
  	} else {
***************
*** 455,460 ****
  		build_hidden_data;
  		$template->param(
! 			oldbiblionumber             => $oldbiblionumber,
! 			bibid                       => $bibid,
  			oldbiblionumtagfield        => $oldbiblionumtagfield,
  			oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
--- 448,452 ----
  		build_hidden_data;
  		$template->param(
! 			biblionumber             => $biblionumber,
  			oldbiblionumtagfield        => $oldbiblionumtagfield,
  			oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
***************
*** 463,467 ****
  			oldbiblioitemnumber         => $oldbiblioitemnumber,
  			duplicatebiblionumber		=> $duplicatebiblionumber,
- 			duplicatebibid				=> $duplicatebibid,
  			duplicatetitle				=> $duplicatetitle,
  			 );
--- 455,458 ----
***************
*** 488,493 ****
  	build_hidden_data;
  	$template->param(
! 		oldbiblionumber             => $oldbiblionumber,
! 		bibid                       => $bibid,
  		oldbiblionumtagfield        => $oldbiblionumtagfield,
  		oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
--- 479,483 ----
  	build_hidden_data;
  	$template->param(
! 		biblionumber             => $biblionumber,
  		oldbiblionumtagfield        => $oldbiblionumtagfield,
  		oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
***************
*** 497,502 ****
  } elsif ($op eq "delete") {
  #------------------------------------------------------------------------------------------------------------------------------
! 	&NEWdelbiblio($dbh,$bibid);
! 	logaction($loggedinuser,"acqui.simple","del",$bibid,"") if (logstatus);
  	
  	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/search.marc/search.pl?type=intranet\"></html>";
--- 487,492 ----
  } elsif ($op eq "delete") {
  #------------------------------------------------------------------------------------------------------------------------------
! 	&NEWdelbiblio($dbh,$biblionumber);
! 	logaction($loggedinuser,"acqui.simple","del",$biblionumber,"") if (logstatus);
  	
  	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/search.marc/search.pl?type=intranet\"></html>";
***************
*** 510,515 ****
  	if ($op eq "duplicate")
  	{
! 		$bibid = "";
! 		$oldbiblionumber= "";
  	}
   
--- 500,504 ----
  	if ($op eq "duplicate")
  	{
! 		$biblionumber= "";
  	}
   
***************
*** 517,522 ****
  	build_hidden_data;
  	$template->param(
! 		oldbiblionumber             => $oldbiblionumber,
! 		bibid                       => $bibid,
  		oldbiblionumtagfield        => $oldbiblionumtagfield,
  		oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
--- 506,510 ----
  	build_hidden_data;
  	$template->param(
! 		biblionumber             => $biblionumber,
  		oldbiblionumtagfield        => $oldbiblionumtagfield,
  		oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,

Index: additem.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/additem.pl,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** additem.pl	4 Aug 2005 12:12:13 -0000	1.31
--- additem.pl	9 Aug 2005 14:10:28 -0000	1.32
***************
*** 50,56 ****
  my $dbh = C4::Context->dbh;
  my $error = $input->param('error');
! my $bibid = $input->param('bibid');
! my $oldbiblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid);
! 
  
  my $op = $input->param('op');
--- 50,54 ----
  my $dbh = C4::Context->dbh;
  my $error = $input->param('error');
! my $biblionumber = $input->param('biblionumber');
  
  my $op = $input->param('op');
***************
*** 58,65 ****
  
  # find itemtype
! my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
  
  my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
! my $record = MARCgetbiblio($dbh,$bibid);
  my $oldrecord = MARCmarc2koha($dbh,$record);
  my $itemrecord;
--- 56,63 ----
  
  # find itemtype
! my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
  
  my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
! my $record = MARCgetbiblio($dbh,$biblionumber);
  my $oldrecord = MARCmarc2koha($dbh,$record);
  my $itemrecord;
***************
*** 87,91 ****
  # MARC::Record builded => now, record in DB
  	# if barcode exists, don't create, but report The problem.
! 	my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid) unless ($exists);
  	if ($exists) {
  		$nextop = "additem";
--- 85,89 ----
  # MARC::Record builded => now, record in DB
  	# if barcode exists, don't create, but report The problem.
! 	my ($biblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$biblionumber) unless ($exists);
  	if ($exists) {
  		$nextop = "additem";
***************
*** 98,102 ****
  #------------------------------------------------------------------------------------------------------------------------------
  # retrieve item if exist => then, it's a modif
! 	$itemrecord = MARCgetitem($dbh,$bibid,$itemnum);
  	$nextop="saveitem";
  #------------------------------------------------------------------------------------------------------------------------------
--- 96,100 ----
  #------------------------------------------------------------------------------------------------------------------------------
  # retrieve item if exist => then, it's a modif
! 	$itemrecord = MARCgetitem($dbh,$biblionumber,$itemnum);
  	$nextop="saveitem";
  #------------------------------------------------------------------------------------------------------------------------------
***************
*** 104,108 ****
  #------------------------------------------------------------------------------------------------------------------------------
  # retrieve item if exist => then, it's a modif
! 	&NEWdelitem($dbh,$bibid,$itemnum);
  	$nextop="additem";
  #------------------------------------------------------------------------------------------------------------------------------
--- 102,106 ----
  #------------------------------------------------------------------------------------------------------------------------------
  # retrieve item if exist => then, it's a modif
! 	&NEWdelitem($dbh,$biblionumber,$itemnum);
  	$nextop="additem";
  #------------------------------------------------------------------------------------------------------------------------------
***************
*** 124,128 ****
  # MARC::Record builded => now, record in DB
  # warn "R: ".$record->as_formatted;
! 	my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$record,$bibid,$itemnum,0);
  	$itemnum="";
  	$nextop="additem";
--- 122,126 ----
  # MARC::Record builded => now, record in DB
  # warn "R: ".$record->as_formatted;
! 	my ($biblionumber,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$record,$biblionumber,$itemnum,0);
  	$itemnum="";
  	$nextop="additem";
***************
*** 231,235 ****
  					($tag==$branchtagfield) && ($subfield==$branchtagsubfield) &&
  					(C4::Context->userenv->{flags} != 1) && ($value != C4::Context->userenv->{branch}) ;
! 		print $input->redirect("additem.pl?bibid=$bibid") if ($test);
  		
  		# search for itemcallnumber if applicable
--- 229,233 ----
  					($tag==$branchtagfield) && ($subfield==$branchtagsubfield) &&
  					(C4::Context->userenv->{flags} != 1) && ($value != C4::Context->userenv->{branch}) ;
! 		print $input->redirect("additem.pl?biblionumber=$biblionumber") if ($test);
  		
  		# search for itemcallnumber if applicable
***************
*** 319,324 ****
  $template->param(item_loop => \@item_value_loop,
  						item_header_loop => \@header_value_loop,
! 						bibid => $bibid,
! 						biblionumber =>$oldbiblionumber,
  						title => $oldrecord->{title},
  						author => $oldrecord->{author},
--- 317,321 ----
  $template->param(item_loop => \@item_value_loop,
  						item_header_loop => \@header_value_loop,
! 						biblionumber =>$biblionumber,
  						title => $oldrecord->{title},
  						author => $oldrecord->{author},





More information about the Koha-cvs mailing list