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.
This commit is contained in:
tipaul 2005-08-09 14:10:27 +00:00
parent 7c8e0bd653
commit 4cf30123a4
12 changed files with 346 additions and 176 deletions

View file

@ -22,6 +22,7 @@ require Exporter;
use C4::Context;
use C4::Database;
use MARC::Record;
use MARC::File::USMARC;
use vars qw($VERSION @ISA @EXPORT);
@ -477,91 +478,12 @@ sub MARCaddsubfield {
sub MARCgetbiblio {
# Returns MARC::Record of the biblio passed in parameter.
my ( $dbh, $bibid ) = @_;
my $record = MARC::Record->new();
# warn "". $bidid;
my $sth =
$dbh->prepare(
"select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
from marc_subfield_table
where bibid=? order by tag,tagorder,subfieldorder
"
);
my $sth2 =
$dbh->prepare(
"select subfieldvalue from marc_blob_subfield where blobidlink=?");
$sth->execute($bibid);
my $prevtagorder = 1;
my $prevtag = 'XXX';
my $previndicator;
my $field; # for >=10 tags
my $prevvalue; # for <10 tags
while ( my $row = $sth->fetchrow_hashref ) {
if ( $row->{'valuebloblink'} ) { #---- search blob if there is one
$sth2->execute( $row->{'valuebloblink'} );
my $row2 = $sth2->fetchrow_hashref;
$sth2->finish;
$row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
}
if ( $row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag ) {
$previndicator .= " ";
if ( $prevtag < 10 ) {
if ($prevtag ne '000') {
$record->add_fields( ( sprintf "%03s", $prevtag ), $prevvalue ) unless $prevtag eq "XXX"; # ignore the 1st loop
} else {
$record->leader(sprintf("%24s",$prevvalue));
}
}
else {
$record->add_fields($field) unless $prevtag eq "XXX";
}
undef $field;
$prevtagorder = $row->{tagorder};
$prevtag = $row->{tag};
$previndicator = $row->{tag_indicator};
if ( $row->{tag} < 10 ) {
$prevvalue = $row->{subfieldvalue};
}
else {
$field = MARC::Field->new(
( sprintf "%03s", $prevtag ),
substr( $row->{tag_indicator} . ' ', 0, 1 ),
substr( $row->{tag_indicator} . ' ', 1, 1 ),
$row->{'subfieldcode'},
$row->{'subfieldvalue'}
);
}
}
else {
if ( $row->{tag} < 10 ) {
$record->add_fields( ( sprintf "%03s", $row->{tag} ),
$row->{'subfieldvalue'} );
}
else {
$field->add_subfields( $row->{'subfieldcode'},
$row->{'subfieldvalue'} );
}
$prevtag = $row->{tag};
$previndicator = $row->{tag_indicator};
}
}
# the last has not been included inside the loop... do it now !
if ( $prevtag ne "XXX" )
{ # check that we have found something. Otherwise, prevtag is still XXX and we
# must return an empty record, not make MARC::Record fail because we try to
# create a record with XXX as field :-(
if ( $prevtag < 10 ) {
$record->add_fields( $prevtag, $prevvalue );
}
else {
# my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist);
$record->add_fields($field);
}
}
my ( $dbh, $biblionumber ) = @_;
my $sth = $dbh->prepare('select marc from biblioitems where biblionumber=?');
$sth->execute($biblionumber);
my ($marc) = $sth->fetchrow;
my $record = MARC::File::USMARC::decode($marc);
warn "$biblionumber => $marc = ".$record->as_usmarc();
return $record;
}
@ -836,10 +758,10 @@ sub MARCfindsubfieldid {
}
sub MARCfind_frameworkcode {
my ( $dbh, $bibid ) = @_;
my ( $dbh, $biblionumber ) = @_;
my $sth =
$dbh->prepare("select frameworkcode from marc_biblio where bibid=?");
$sth->execute($bibid);
$dbh->prepare("select frameworkcode from biblio where biblionumber=?");
$sth->execute($biblionumber);
my ($frameworkcode) = $sth->fetchrow;
return $frameworkcode;
}
@ -2738,6 +2660,24 @@ Paul POULAIN paul.poulain@free.fr
# $Id$
# $Log$
# Revision 1.123 2005/08/09 14:10:28 tipaul
# 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.
#
# Revision 1.122 2005/08/04 13:27:48 tipaul
# synch'ing 2.2 and head
#

View file

@ -53,14 +53,11 @@ my $query=new CGI;
my $dbh=C4::Context->dbh;
my $biblionumber=$query->param('bib');
my $bibid = $query->param('bibid');
$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
my $biblionumber=$query->param('biblionumber');
my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
my $record =MARCgetbiblio($dbh,$bibid);
my $record =MARCgetbiblio($dbh,$biblionumber);
# open template
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "catalogue/ISBDdetail.tmpl",

View file

@ -64,19 +64,19 @@ my $query=new CGI;
my $dbh=C4::Context->dbh;
my $biblionumber=$query->param('bib');
my $bibid = $query->param('bibid');
# my $bibid = $query->param('bibid');
my $itemtype = $query->param('frameworkcode');
my $popup = $query->param('popup'); # if set to 1, then don't insert links, it's just to show the biblio
$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
$itemtype = &MARCfind_frameworkcode($dbh,$bibid) if not ($itemtype);
# $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
# $biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
$itemtype = &MARCfind_frameworkcode($dbh,$biblionumber) if not ($itemtype);
$itemtype = '' if ($itemtype eq 'Default');
warn "itemtype :".$itemtype;
# warn "itemtype :".$itemtype;
my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
my $record =MARCgetbiblio($dbh,$bibid);
my $record =MARCgetbiblio($dbh,$biblionumber);
# open template
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "catalogue/MARCdetail.tmpl",
@ -225,7 +225,7 @@ my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
$template->param(item_loop => \@item_value_loop,
item_header_loop => \@header_value_loop,
biblionumber => $biblionumber,
bibid => $bibid,
# bibid => $bibid,
biblionumber => $biblionumber,
subscriptionsnumber => $subscriptionsnumber,
popup => $popup,

View file

@ -153,6 +153,7 @@ sub build_authorized_values_list ($$$$$) {
-values => \@authorised_values,
-default => $value,
-labels => \%authorised_lib,
-override => 1,
-size => 1,
-multiple => 0 );
}
@ -346,23 +347,15 @@ sub build_hidden_data () {
#=========================
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 $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');
my $op = $input->param('op');
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 = &MARCfind_frameworkcode($dbh,$biblionumber) if ($biblionumber and not ($frameworkcode));
$frameworkcode='' if ($frameworkcode eq 'Default');
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui.simple/addbiblio.tmpl",
@ -399,20 +392,20 @@ $template->param( framework => $framework);
$tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
my $record=-1;
my $encoding="";
$record = MARCgetbiblio($dbh,$bibid) if ($bibid);
$record = MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
$is_a_modif=0;
my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber);
if ($bibid) {
if ($biblionumber) {
$is_a_modif=1;
# if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB.
($oldbiblionumtagfield,$oldbiblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",$frameworkcode);
($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber",$frameworkcode);
# search biblioitems value
my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
$sth->execute($oldbiblionumber);
$sth->execute($biblionumber);
($oldbiblioitemnumber) = $sth->fetchrow;
}
#------------------------------------------------------------------------------------------------------------------------------
@ -439,30 +432,28 @@ if ($op eq "addbiblio") {
my $oldbibnum;
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"));
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 {
($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode);
($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?bibid=$bibid&frameworkcode=$frameworkcode");
print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
exit;
} else {
# it may be a duplicate, warn the user and do nothing
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
oldbiblionumber => $oldbiblionumber,
bibid => $bibid,
biblionumber => $biblionumber,
oldbiblionumtagfield => $oldbiblionumtagfield,
oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,
oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
oldbiblioitemnumber => $oldbiblioitemnumber,
duplicatebiblionumber => $duplicatebiblionumber,
duplicatebibid => $duplicatebibid,
duplicatetitle => $duplicatetitle,
);
}
@ -487,8 +478,7 @@ if ($op eq "addbiblio") {
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
oldbiblionumber => $oldbiblionumber,
bibid => $bibid,
biblionumber => $biblionumber,
oldbiblionumtagfield => $oldbiblionumtagfield,
oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,
@ -496,8 +486,8 @@ if ($op eq "addbiblio") {
oldbiblioitemnumber => $oldbiblioitemnumber );
} elsif ($op eq "delete") {
#------------------------------------------------------------------------------------------------------------------------------
&NEWdelbiblio($dbh,$bibid);
logaction($loggedinuser,"acqui.simple","del",$bibid,"") if (logstatus);
&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>";
exit;
@ -509,15 +499,13 @@ if ($op eq "addbiblio") {
# as we'll save the biblio as a new one.
if ($op eq "duplicate")
{
$bibid = "";
$oldbiblionumber= "";
$biblionumber= "";
}
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
oldbiblionumber => $oldbiblionumber,
bibid => $bibid,
biblionumber => $biblionumber,
oldbiblionumtagfield => $oldbiblionumtagfield,
oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,

View file

@ -49,18 +49,16 @@ sub find_value {
my $input = new CGI;
my $dbh = C4::Context->dbh;
my $error = $input->param('error');
my $bibid = $input->param('bibid');
my $oldbiblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid);
my $biblionumber = $input->param('biblionumber');
my $op = $input->param('op');
my $itemnum = $input->param('itemnum');
# find itemtype
my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
my $record = MARCgetbiblio($dbh,$bibid);
my $record = MARCgetbiblio($dbh,$biblionumber);
my $oldrecord = MARCmarc2koha($dbh,$record);
my $itemrecord;
my $nextop="additem";
@ -86,7 +84,7 @@ if ($op eq "additem") {
push @errors,"barcode_not_unique" if($exists);
# 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);
my ($biblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$biblionumber) unless ($exists);
if ($exists) {
$nextop = "additem";
$itemrecord = $record;
@ -97,13 +95,13 @@ if ($op eq "additem") {
} elsif ($op eq "edititem") {
#------------------------------------------------------------------------------------------------------------------------------
# retrieve item if exist => then, it's a modif
$itemrecord = MARCgetitem($dbh,$bibid,$itemnum);
$itemrecord = MARCgetitem($dbh,$biblionumber,$itemnum);
$nextop="saveitem";
#------------------------------------------------------------------------------------------------------------------------------
} elsif ($op eq "delitem") {
#------------------------------------------------------------------------------------------------------------------------------
# retrieve item if exist => then, it's a modif
&NEWdelitem($dbh,$bibid,$itemnum);
&NEWdelitem($dbh,$biblionumber,$itemnum);
$nextop="additem";
#------------------------------------------------------------------------------------------------------------------------------
} elsif ($op eq "saveitem") {
@ -123,7 +121,7 @@ if ($op eq "additem") {
my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
# MARC::Record builded => now, record in DB
# warn "R: ".$record->as_formatted;
my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$record,$bibid,$itemnum,0);
my ($biblionumber,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$record,$biblionumber,$itemnum,0);
$itemnum="";
$nextop="additem";
}
@ -230,7 +228,7 @@ foreach my $tag (sort keys %{$tagslib}) {
my $test = (C4::Context->preference("IndependantBranches")) &&
($tag==$branchtagfield) && ($subfield==$branchtagsubfield) &&
(C4::Context->userenv->{flags} != 1) && ($value != C4::Context->userenv->{branch}) ;
print $input->redirect("additem.pl?bibid=$bibid") if ($test);
print $input->redirect("additem.pl?biblionumber=$biblionumber") if ($test);
# search for itemcallnumber if applicable
if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' && C4::Context->preference('itemcallnumber')) {
@ -318,8 +316,7 @@ my ($template, $loggedinuser, $cookie)
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
$template->param(item_loop => \@item_value_loop,
item_header_loop => \@header_value_loop,
bibid => $bibid,
biblionumber =>$oldbiblionumber,
biblionumber =>$biblionumber,
title => $oldrecord->{title},
author => $oldrecord->{author},
item => \@loop_data,

View file

@ -19,7 +19,7 @@ my ($template, $borrowernumber, $cookie)
flagsrequired => {borrow => 1},
});
my $biblionumber=$query->param('bib');
my $biblionumber=$query->param('biblionumber');
$template->param(biblionumber => $biblionumber);
@ -50,10 +50,9 @@ $template->param(norequests => $norequests);
my $marc = C4::Context->preference("marc");
if ($marc eq "yes") {
my $dbh = C4::Context->dbh;
my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
my $marcflavour = C4::Context->preference("marcflavour");
my $marcnotesarray = &getMARCnotes($dbh,$bibid,$marcflavour);
my $marcsubjctsarray = &getMARCsubjects($dbh,$bibid,$marcflavour);
my $marcnotesarray = &getMARCnotes($dbh,$biblionumber,$marcflavour);
my $marcsubjctsarray = &getMARCsubjects($dbh,$biblionumber,$marcflavour);
$template->param(MARCNOTES => $marcnotesarray);
$template->param(MARCSUBJCTS => $marcsubjctsarray);

View file

@ -1,13 +1,13 @@
<!-- TMPL_INCLUDE NAME="marc-top.inc" -->
<div class="tabbed">
<form method="post" name="f">
<h1 class="catalogue">Biblionumber : <!-- TMPL_VAR NAME="oldbiblionumber" --> With Framework :<!--TMPL_VAR Name="framework" --></b></h1>
<h1 class="catalogue">Biblionumber : <!-- TMPL_VAR NAME="biblionumber" --> With Framework :<!--TMPL_VAR Name="framework" --></b></h1>
<p>
<input type="hidden" name="op" value="addbiblio">
<input type="hidden" name="addfield_field">
<input type="hidden" name="frameworkcode" value="<!-- TMPL_VAR NAME="frameworkcode" -->">
<input type="hidden" name="oldbiblionumber" value="<!-- TMPL_VAR NAME="oldbiblionumber" -->">
<!-- TMPL_IF name="bibid" -->
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->">
<!-- TMPL_IF name="biblionumber" -->
<input type="button" value="Save" onclick="Check(this.form)" accesskey="w" class="button catalogue">
<!-- TMPL_ELSE -->
<input type="button" value="Add biblio" onclick="Check(this.form)" accesskey="w" class="button catalogue">
@ -56,7 +56,7 @@
<p>You must either :</p>
<ul>
<p><input type="checkbox" value=1 name="confirm_not_duplicate">confirm it's not a duplicate (and click on Add biblio again)</p>
<p>Go to <a href="additem.pl?bibid=<!-- TMPL_VAR name="duplicatebibid" -->" class="button catalogue">edit items</a> from this duplicate biblio</p>
<p>Go to <a href="additem.pl?biblionumber=<!-- TMPL_VAR name="duplicatebiblionumber" -->" class="button catalogue">edit items</a> from this duplicate biblio</p>
</ul>
</div>
<!-- /TMPL_IF -->
@ -515,7 +515,7 @@ function PopupZ3950() {
strQuery += "&issn="+document.forms[0].field_value[i].value;
}
}
newin=window.open("../z3950/search.pl?bibid=<!-- TMPL_VAR NAME="bibid" -->"+strQuery,"z3950search",'width=800,height=400,toolbar=false,scrollbars=yes');
newin=window.open("../z3950/search.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"+strQuery,"z3950search",'width=800,height=400,toolbar=false,scrollbars=yes');
}
function Changefwk(FwkList) {
var fwk = FwkList.options[FwkList.selectedIndex].value;

View file

@ -2,33 +2,33 @@
<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR NAME="themelang" -->/includes/marc-editor.css">
<div id="mainbloc">
<div id="bibliomenu">
<h1 class="catalogue">MARC biblio : <!-- TMPL_VAR NAME="bibid" --></h1>
<a href="acqui.simple/addbiblio.pl?oldbiblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<h1 class="catalogue">MARC biblio : <!-- TMPL_VAR NAME="biblionumber" --></h1>
<a href="acqui.simple/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
Edit biblio
</a>
<a href="acqui.simple/addbiblio.pl?oldbiblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&op=duplicate" class="button catalogue">
<a href="acqui.simple/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&op=duplicate" class="button catalogue">
Duplicate
</a>
<a href="acqui.simple/additem.pl?bibid=<!-- TMPL_VAR name="bibid"-->" class="button catalogue">
<a href="acqui.simple/additem.pl?biblionumber=<!-- TMPL_VAR name="biblionumber"-->" class="button catalogue">
Edit item
</a>
<a href="javascript:confirm_deletion()" class="button catalogue">
delete
</a>
<a href="MARCdetail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<a href="MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
Complete
</a>
<a href="detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<a href="detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
Normal
</a>
<a href="ISBDdetail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<a href="ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
ISBD
</a>
<a href="javascript:Dopop('bookshelves/addbookbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->')" class="button catalogue">
Add to shelf
</a>
<a href="javascript:Dopop('detailprint.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->')" class="button catalogue">
<a href="javascript:Dopop('detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->')" class="button catalogue">
Print
</a>
<!-- TMPL_IF name="subscriptionsnumber" -->
@ -38,7 +38,7 @@
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="norequests" -->
<!-- TMPL_ELSE -->
<a href="request.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">Request</a>
<a href="request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">Request</a>
<!-- /TMPL_IF -->
</div>

View file

@ -13,26 +13,26 @@
<a href="javascript:Addbiblio('duplicate')" class="button catalogue">
Duplicate
</a>
<a href="acqui.simple/additem.pl?bibid=<!-- TMPL_VAR name="bibid"-->" class="button catalogue">
<a href="acqui.simple/additem.pl?biblionumber=<!-- TMPL_VAR name="biblionumber"-->" class="button catalogue">
Edit item
</a>
<a href="javascript:confirm_deletion()" class="button catalogue">
delete
</a>
<a href="detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<a href="detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
Complete
</a>
<a href="detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<a href="detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
Normal
</a>
<a href="ISBDdetail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
<a href="ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">
ISBD
</a>
<a href="javascript:Dopop('bookshelves/addbookbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->')" class="button catalogue">
Add to shelf
</a>
<a href="javascript:Dopop('detailprint.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->')" class="button catalogue">
<a href="javascript:Dopop('detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->')" class="button catalogue">
Print
</a>
<!-- TMPL_IF name="subscriptionsnumber" -->
@ -42,7 +42,7 @@
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="norequests" -->
<!-- TMPL_ELSE -->
<a href="request.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">Request</a>
<a href="request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="button catalogue">Request</a>
<!-- /TMPL_IF -->
@ -397,7 +397,7 @@ function active(numlayer)
function confirm_deletion() {
var is_confirmed = confirm('Are you sure you want to delete this biblio?');
if (is_confirmed) {
window.location="acqui.simple/addbiblio.pl?op=delete&amp;bibid=<!-- TMPL_VAR NAME="bibid" -->";
window.location="acqui.simple/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
}
}
function Dopop(link) {
@ -405,11 +405,11 @@ function Dopop(link) {
}
function Changefwk(FwkList) {
var fwk = FwkList.options[FwkList.selectedIndex].value;
window.location = "MARCdetail.pl?bib=<!--TMPL_VAR Name="biblionumber"-->&frameworkcode="+fwk;
window.location = "MARCdetail.pl?biblionumber=<!--TMPL_VAR Name="biblionumber"-->&frameworkcode="+fwk;
}
function Addbiblio(op) {
var fwk = document.forms[0].Frameworks.options[document.forms[0].Frameworks.selectedIndex].value;
window.location = "acqui.simple/addbiblio.pl?oldbiblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&frameworkcode="+fwk+"&op="+op;
window.location = "acqui.simple/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&frameworkcode="+fwk+"&op="+op;
}
</script>
</body>

View file

@ -10,7 +10,7 @@
<a href="acqui.simple/addbiblio.pl?oldbiblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&op=duplicate" class="button catalogue">
Duplicate
</a>
<a href="acqui.simple/additem.pl?bibid=<!-- TMPL_VAR name="bibid"-->" class="button catalogue">
<a href="acqui.simple/additem.pl?biblionumber=<!-- TMPL_VAR name="biblionumber"-->" class="button catalogue">
Edit item
</a>
@ -167,7 +167,7 @@ function Dopop(link) {
function confirm_deletion() {
var is_confirmed = confirm('Are you sure you want to delete this biblio?');
if (is_confirmed) {
window.location="acqui.simple/addbiblio.pl?op=delete&amp;bibid=<!-- TMPL_VAR NAME="bibid" -->";
window.location="acqui.simple/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
}
}
</script>

View file

@ -4,14 +4,14 @@
<div id="bloc25">
<!-- TMPL_LOOP NAME="BIBITEM_DATA" -->
<h2 class="catalogue">
<a href="/cgi-bin/koha/detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->&amp;type=intra">
<a href="/cgi-bin/koha/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;type=intra">
<!-- TMPL_VAR NAME="title" --> (<!-- TMPL_VAR NAME="author" -->)
</a>
</h2>
<p>
<form action="/cgi-bin/koha/modbibitem.pl" method="post">
<input type="hidden" name="bibitem" value="<!-- TMPL_VAR NAME="biblioitemnumber" -->">
<input type="hidden" name="biblio" value="<!-- TMPL_VAR NAME="biblionumber" -->">
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->">
<p><!-- TMPL_VAR NAME="biblioitemnumber" --> GROUP - <!-- TMPL_VAR NAME="description" --> </p>
<p><b>Biblionumber:</b> <!-- TMPL_VAR NAME="biblionumber" --></p>
<p><b>Item type:</b> <!-- TMPL_VAR NAME="itemtype" --></p>
@ -32,7 +32,7 @@
</form>
<input type="image" name="submit" VALUE="modify" src="<!-- TMPL_VAR NAME="interface" -->/<!-- TMPL_VAR NAME="theme" -->/images/fileopen.png">
<input type="image" name="delete" VALUE="delete" src="<!-- TMPL_VAR NAME="interface" -->/<!-- TMPL_VAR NAME="theme" -->/images/edittrash.png">
<a class="button" href="/cgi-bin/koha/request.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->">Requests</a>
<a class="button" href="/cgi-bin/koha/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Requests</a>
<!-- /TMPL_LOOP -->
</div>
<!-- TMPL_LOOP NAME="ITEM_DATA" -->
@ -58,12 +58,12 @@
<b>Paid for:</b> <!-- TMPL_VAR NAME="paidfor" --><br>
<b>Notes:</b> <!-- TMPL_VAR NAME="itemnotes" --><br>
<b>Renewals:</b> <!-- TMPL_VAR NAME="renewals" --><br>
<b><a href="/cgi-bin/koha/acqui/acquire.pl?recieve=<!-- TMPL_VAR NAME="ordernumber" -->&amp;biblio=<!-- TMPL_VAR NAME="biblionumber" -->&amp;invoice=<!-- TMPL_VAR NAME="booksellerinvoicenumber" -->&catview=yes">
<b><a href="/cgi-bin/koha/acqui/acquire.pl?recieve=<!-- TMPL_VAR NAME="ordernumber" -->&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;invoice=<!-- TMPL_VAR NAME="booksellerinvoicenumber" -->&catview=yes">
Accession
Date:</a></b> <!-- TMPL_VAR NAME="dateaccessioned" --><br>
<b>Cancelled:</b> <!-- TMPL_IF NAME="wthdrawn" -->Yes<!-- TMPL_ELSE -->No<!-- /TMPL_IF --><br>
<b><a
href="/cgi-bin/koha/bookcount.pl?&amp;bib=<!-- TMPL_VAR NAME="biblionumber" -->&amp;bi=<!-- TMPL_VAR NAME="biblioitemnumber" -->&amp;itm=<!-- TMPL_VAR NAME="itemnumber" -->">Total
href="/cgi-bin/koha/bookcount.pl?&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;bi=<!-- TMPL_VAR NAME="biblioitemnumber" -->&amp;itm=<!-- TMPL_VAR NAME="itemnumber" -->">Total
Issues:</a></b> <!-- TMPL_VAR NAME="issues" --><br>
<b>Group Number:</b> <!-- TMPL_VAR NAME="biblioitemnumber" --> <br>
<b>Biblio number:</b> <!-- TMPL_VAR NAME="biblionumber" --> <br>

View file

@ -20,6 +20,9 @@ use Getopt::Long;
# Koha modules
use C4::Context;
use MARC::Record;
use MARC::File::XML;
# FIXME - The user might be installing a new database, so can't rely
# on /etc/koha.conf anyway.
@ -42,6 +45,7 @@ GetOptions(
);
my $dbh = C4::Context->dbh;
print "connected to your DB. Checking & modifying it\n" unless $silent;
$|=1; # flushes output
#-------------------
# Defines
@ -349,6 +353,70 @@ foreach my $table ( keys %tabledata ) {
}
}
#
# SPECIFIC STUFF
#
#
# create frameworkcode row in biblio table & fill it with marc_biblio.frameworkcode.
#
# 1st, get how many biblio we will have to do...
$sth = $dbh->prepare('select count(*) from marc_biblio');
$sth->execute;
my ($totaltodo) = $sth->fetchrow;
$sth = $dbh->prepare("show columns from biblio");
$sth->execute();
my $definitions;
my $bibliofwexist=0;
while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
$bibliofwexist=1 if $column eq 'frameworkcode';
}
unless ($bibliofwexist) {
print "moving biblioframework to biblio table\n";
$dbh->do('ALTER TABLE `biblio` ADD `frameworkcode` VARCHAR( 4 ) NOT NULL AFTER `biblionumber`');
$sth = $dbh->prepare('select biblionumber,frameworkcode from marc_biblio');
$sth->execute;
my $sth_update = $dbh->prepare('update biblio set frameworkcode=? where biblionumber=?');
my $totaldone=0;
while (my ($biblionumber,$frameworkcode) = $sth->fetchrow) {
$sth_update->execute($frameworkcode,$biblionumber);
$totaldone++;
print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
}
print "\rdone\n";
}
#
# moving MARC data from marc_subfield_table to biblioitems.marc
#
$sth = $dbh->prepare("show columns from biblioitems");
$sth->execute();
my $definitions;
my $marcdone=0;
while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
$marcdone=1 if ($type eq 'blob' && $column eq 'marc') ;
}
unless ($marcdone) {
print "moving MARC record to biblioitems table\n";
# changing marc field type
$dbh->do('ALTER TABLE `biblioitems` CHANGE `marc` `marc` BLOB NULL DEFAULT NULL ');
# adding marc xml, just for convenience
$dbh->do('ALTER TABLE `biblioitems` ADD `marcxml` TEXT NOT NULL');
# moving data from marc_subfield_value to biblio
$sth = $dbh->prepare('select bibid,biblionumber from marc_biblio');
$sth->execute;
my $sth_update = $dbh->prepare('update biblioitems set marc=?, marcxml=? where biblionumber=?');
my $totaldone=0;
while (my ($bibid,$biblionumber) = $sth->fetchrow) {
my $record = MARCgetbiblio($dbh,$bibid);
$sth_update->execute($record->as_usmarc(),$record->as_xml(),$biblionumber);
$totaldone++;
print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
}
print "\rdone\n";
}
# at last, remove useless fields
foreach $table ( keys %uselessfields ) {
my @fields = split /,/,$uselessfields{$table};
@ -375,9 +443,190 @@ foreach $table ( keys %uselessfields ) {
$sth->finish;
#
# those 2 subs are a copy of Biblio.pm, version 2.2.4
# they are useful only once, for moving from 2.2 to 3.0
# the MARCgetbiblio & MARCgetitem subs in Biblio.pm
# are still here, but uses other tables
# (the ones that are filled by updatedatabase !)
#
sub MARCgetbiblio {
# Returns MARC::Record of the biblio passed in parameter.
my ( $dbh, $bibid ) = @_;
my $record = MARC::Record->new();
# warn "". $bidid;
my $sth =
$dbh->prepare(
"select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
from marc_subfield_table
where bibid=? order by tag,tagorder,subfieldorder
"
);
my $sth2 =
$dbh->prepare(
"select subfieldvalue from marc_blob_subfield where blobidlink=?");
$sth->execute($bibid);
my $prevtagorder = 1;
my $prevtag = 'XXX';
my $previndicator;
my $field; # for >=10 tags
my $prevvalue; # for <10 tags
while ( my $row = $sth->fetchrow_hashref ) {
if ( $row->{'valuebloblink'} ) { #---- search blob if there is one
$sth2->execute( $row->{'valuebloblink'} );
my $row2 = $sth2->fetchrow_hashref;
$sth2->finish;
$row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
}
if ( $row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag ) {
$previndicator .= " ";
if ( $prevtag < 10 ) {
if ($prevtag ne '000') {
$record->add_fields( ( sprintf "%03s", $prevtag ), $prevvalue ) unless $prevtag eq "XXX"; # ignore the 1st loop
} else {
$record->leader(sprintf("%24s",$prevvalue));
}
}
else {
$record->add_fields($field) unless $prevtag eq "XXX";
}
undef $field;
$prevtagorder = $row->{tagorder};
$prevtag = $row->{tag};
$previndicator = $row->{tag_indicator};
if ( $row->{tag} < 10 ) {
$prevvalue = $row->{subfieldvalue};
}
else {
$field = MARC::Field->new(
( sprintf "%03s", $prevtag ),
substr( $row->{tag_indicator} . ' ', 0, 1 ),
substr( $row->{tag_indicator} . ' ', 1, 1 ),
$row->{'subfieldcode'},
$row->{'subfieldvalue'}
);
}
}
else {
if ( $row->{tag} < 10 ) {
$record->add_fields( ( sprintf "%03s", $row->{tag} ),
$row->{'subfieldvalue'} );
}
else {
$field->add_subfields( $row->{'subfieldcode'},
$row->{'subfieldvalue'} );
}
$prevtag = $row->{tag};
$previndicator = $row->{tag_indicator};
}
}
# the last has not been included inside the loop... do it now !
if ( $prevtag ne "XXX" )
{ # check that we have found something. Otherwise, prevtag is still XXX and we
# must return an empty record, not make MARC::Record fail because we try to
# create a record with XXX as field :-(
if ( $prevtag < 10 ) {
$record->add_fields( $prevtag, $prevvalue );
}
else {
# my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist);
$record->add_fields($field);
}
}
return $record;
}
sub MARCgetitem {
# Returns MARC::Record of the biblio passed in parameter.
my ( $dbh, $bibid, $itemnumber ) = @_;
my $record = MARC::Record->new();
# search MARC tagorder
my $sth2 =
$dbh->prepare(
"select tagorder from marc_subfield_table,marc_subfield_structure where marc_subfield_table.tag=marc_subfield_structure.tagfield and marc_subfield_table.subfieldcode=marc_subfield_structure.tagsubfield and bibid=? and kohafield='items.itemnumber' and subfieldvalue=?"
);
$sth2->execute( $bibid, $itemnumber );
my ($tagorder) = $sth2->fetchrow_array();
#---- TODO : the leader is missing
my $sth =
$dbh->prepare(
"select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
from marc_subfield_table
where bibid=? and tagorder=? order by subfieldcode,subfieldorder
"
);
$sth2 =
$dbh->prepare(
"select subfieldvalue from marc_blob_subfield where blobidlink=?");
$sth->execute( $bibid, $tagorder );
while ( my $row = $sth->fetchrow_hashref ) {
if ( $row->{'valuebloblink'} ) { #---- search blob if there is one
$sth2->execute( $row->{'valuebloblink'} );
my $row2 = $sth2->fetchrow_hashref;
$sth2->finish;
$row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
}
if ( $record->field( $row->{'tag'} ) ) {
my $field;
#--- this test must stay as this, because of strange behaviour of mySQL/Perl DBI with char var containing a number...
#--- sometimes, eliminates 0 at beginning, sometimes no ;-\\\
if ( length( $row->{'tag'} ) < 3 ) {
$row->{'tag'} = "0" . $row->{'tag'};
}
$field = $record->field( $row->{'tag'} );
if ($field) {
my $x =
$field->add_subfields( $row->{'subfieldcode'},
$row->{'subfieldvalue'} );
$record->delete_field($field);
$record->add_fields($field);
}
}
else {
if ( length( $row->{'tag'} ) < 3 ) {
$row->{'tag'} = "0" . $row->{'tag'};
}
my $temp =
MARC::Field->new( $row->{'tag'}, " ", " ",
$row->{'subfieldcode'} => $row->{'subfieldvalue'} );
$record->add_fields($temp);
}
}
return $record;
}
exit;
# $Log$
# Revision 1.120 2005/08/09 14:10:32 tipaul
# 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.
#
# Revision 1.119 2005/08/04 16:07:58 tipaul
# Synch really broke this script...
#