From 4cf30123a4e754d49cc900468615eeadcec968aa Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 9 Aug 2005 14:10:27 +0000 Subject: [PATCH] 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. --- C4/Biblio.pm | 116 ++------ ISBDdetail.pl | 9 +- MARCdetail.pl | 14 +- acqui.simple/addbiblio.pl | 46 ++-- acqui.simple/additem.pl | 21 +- detail.pl | 7 +- .../default/en/acqui.simple/addbiblio.tmpl | 10 +- .../default/en/catalogue/ISBDdetail.tmpl | 18 +- .../default/en/catalogue/MARCdetail.tmpl | 18 +- .../default/en/catalogue/detail.tmpl | 4 +- .../default/en/catalogue/moredetail.tmpl | 10 +- updater/updatedatabase | 249 ++++++++++++++++++ 12 files changed, 346 insertions(+), 176 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 36f91f8294..e397854145 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -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 # diff --git a/ISBDdetail.pl b/ISBDdetail.pl index e6b39e1078..831fe63a94 100755 --- a/ISBDdetail.pl +++ b/ISBDdetail.pl @@ -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", diff --git a/MARCdetail.pl b/MARCdetail.pl index ac35da927d..ce83d28c9d 100755 --- a/MARCdetail.pl +++ b/MARCdetail.pl @@ -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, diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 7f218e2d6d..689ec3b555 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -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"; 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, diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index 8c07917d1e..7e144deedc 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -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, diff --git a/detail.pl b/detail.pl index 20978161e9..4e2a8d190c 100755 --- a/detail.pl +++ b/detail.pl @@ -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); diff --git a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl index 56e85a377c..ae3c4c473b 100644 --- a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl @@ -1,13 +1,13 @@
-

Biblionumber : With Framework :

+

Biblionumber : With Framework :

"> - "> - + "> + @@ -56,7 +56,7 @@

You must either :

@@ -515,7 +515,7 @@ function PopupZ3950() { strQuery += "&issn="+document.forms[0].field_value[i].value; } } - newin=window.open("../z3950/search.pl?bibid="+strQuery,"z3950search",'width=800,height=400,toolbar=false,scrollbars=yes'); + newin=window.open("../z3950/search.pl?biblionumber="+strQuery,"z3950search",'width=800,height=400,toolbar=false,scrollbars=yes'); } function Changefwk(FwkList) { var fwk = FwkList.options[FwkList.selectedIndex].value; diff --git a/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl b/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl index 0b0bac0b19..05285282fd 100644 --- a/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl @@ -2,33 +2,33 @@ /includes/marc-editor.css">
diff --git a/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl b/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl index a9a6d99cfb..0de68d09c6 100644 --- a/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl @@ -13,26 +13,26 @@ Duplicate - " class="button catalogue"> + " class="button catalogue"> Edit item delete - " class="button catalogue"> + " class="button catalogue"> Complete - " class="button catalogue"> + " class="button catalogue"> Normal - " class="button catalogue"> + " class="button catalogue"> ISBD ')" class="button catalogue"> Add to shelf - ')" class="button catalogue"> + ')" class="button catalogue"> Print @@ -42,7 +42,7 @@ - " class="button catalogue">Request + " class="button catalogue">Request @@ -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&bibid="; + window.location="acqui.simple/addbiblio.pl?op=delete&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=&frameworkcode="+fwk; + window.location = "MARCdetail.pl?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=&frameworkcode="+fwk+"&op="+op; + window.location = "acqui.simple/addbiblio.pl?biblionumber=&frameworkcode="+fwk+"&op="+op; } diff --git a/koha-tmpl/intranet-tmpl/default/en/catalogue/detail.tmpl b/koha-tmpl/intranet-tmpl/default/en/catalogue/detail.tmpl index 5508124670..f52684f794 100644 --- a/koha-tmpl/intranet-tmpl/default/en/catalogue/detail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/catalogue/detail.tmpl @@ -10,7 +10,7 @@ &op=duplicate" class="button catalogue"> Duplicate - " class="button catalogue"> + " class="button catalogue"> Edit item @@ -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&bibid="; + window.location="acqui.simple/addbiblio.pl?op=delete&biblionumber="; } } diff --git a/koha-tmpl/intranet-tmpl/default/en/catalogue/moredetail.tmpl b/koha-tmpl/intranet-tmpl/default/en/catalogue/moredetail.tmpl index 4de114b815..cd62feb467 100644 --- a/koha-tmpl/intranet-tmpl/default/en/catalogue/moredetail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/catalogue/moredetail.tmpl @@ -4,14 +4,14 @@

- &type=intra"> + &type=intra"> ()

"> - "> + ">

GROUP -

Biblionumber:

Item type:

@@ -32,7 +32,7 @@ //images/fileopen.png"> //images/edittrash.png"> - ">Requests + ">Requests
@@ -58,12 +58,12 @@ Paid for:
Notes:
Renewals:
- &biblio=&invoice=&catview=yes"> + &biblionumber=&invoice=&catview=yes"> Accession Date:
Cancelled: YesNo
&bi=&itm=">Total + href="/cgi-bin/koha/bookcount.pl?&biblionumber=&bi=&itm=">Total Issues:
Group Number:
Biblio number:
diff --git a/updater/updatedatabase b/updater/updatedatabase index de356706d5..886c0183ed 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -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... # -- 2.20.1