From 8690167fdd19ae98035b9a1f6f4b67186081f064 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Fri, 7 Oct 2011 14:45:53 +1300 Subject: [PATCH] Bug 5528 : Merging analy-3.6 to master and squashing Conflicts: installer/data/mysql/updatedatabase.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt kohaversion.pl --- C4/Auth.pm | 1 + C4/Biblio.pm | 125 ++++++++++++++++ C4/Items.pm | 150 +++++++++++++++++--- C4/Reserves.pm | 8 + C4/Search.pm | 42 ++++++ catalogue/detail.pl | 42 +++++- catalogue/moredetail.pl | 18 +++ cataloguing/addbiblio.pl | 18 +++- cataloguing/additem.pl | 54 +++++++ cataloguing/linkitem.pl | 95 ++++++++++++ etc/zebradb/biblios/etc/bib1.att | 2 +- etc/zebradb/ccl.properties | 3 + etc/zebradb/marc_defs/marc21/biblios/record.abs | 3 +- etc/zebradb/marc_defs/unimarc/biblios/record.abs | 3 + .../marc21/mandatory/marc21_framework_DEFAULT.sql | 2 + .../optional/marc21_simple_bib_frameworks.sql | 16 ++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 15 ++ .../prog/en/includes/biblio-view-menu.inc | 1 + .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 2 + .../en/modules/admin/preferences/cataloguing.pref | 6 + .../prog/en/modules/catalogue/detail.tt | 16 ++- .../prog/en/modules/cataloguing/additem.tt | 7 +- .../prog/en/modules/cataloguing/linkitem.tmpl | 57 ++++++++ .../prog/en/modules/cataloguing/linkitem.tt | 57 ++++++++ .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 23 +++ .../prog/en/xslt/MARC21slim2OPACDetail.xsl | 23 +++ misc/migration_tools/create_analytical_rel.pl | 151 ++++++++++++++++++++ opac/opac-detail.pl | 32 ++++- opac/opac-reserve.pl | 36 +++++- reserve/placerequest.pl | 9 ++ reserve/request.pl | 16 ++- 32 files changed, 999 insertions(+), 35 deletions(-) create mode 100755 cataloguing/linkitem.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tt create mode 100755 misc/migration_tools/create_analytical_rel.pl diff --git a/C4/Auth.pm b/C4/Auth.pm index 7211769..ef22a22 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -382,6 +382,7 @@ sub get_template_and_user { virtualshelves => C4::Context->preference("virtualshelves"), StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"), NoZebra => C4::Context->preference('NoZebra'), + EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'), ); } else { diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 915139e..8d65066 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -78,6 +78,7 @@ BEGIN { &GetMarcBiblio &GetMarcAuthors &GetMarcSeries + &GetMarcHosts GetMarcUrls &GetUsedMarcStructure &GetXmlBiblio @@ -90,6 +91,7 @@ BEGIN { &GetMarcFromKohaField &GetFrameworkCode &TransformKohaToMarc + &PrepHostMarcField &CountItemsIssued ); @@ -1760,6 +1762,48 @@ sub GetMarcSeries { return $marcseriessarray; } #end getMARCseriess +=head2 GetMarcHosts + + $marchostsarray = GetMarcHosts($record,$marcflavour); + +Get all host records (773s MARC21, 461 UNIMARC) from the MARC record and returns them in an array. + +=cut + +sub GetMarcHosts { + my ( $record, $marcflavour ) = @_; + my ( $tag,$title_subf,$bibnumber_subf,$itemnumber_subf); + $marcflavour ||="MARC21"; + if ( $marcflavour eq "MARC21" ) { + $tag = "773"; + $title_subf = "t"; + $bibnumber_subf ="0"; + $itemnumber_subf='9'; + } + elsif ($marcflavour eq "UNIMARC") { + $tag = "461"; + $title_subf = "t"; + $bibnumber_subf ="0"; + $itemnumber_subf='9'; + }; + + my @marchosts; + + foreach my $field ( $record->field($tag)) { + + my @fields_loop; + + my $hostbiblionumber = $field->subfield("$bibnumber_subf"); + my $hosttitle = $field->subfield($title_subf); + my $hostitemnumber=$field->subfield($itemnumber_subf); + push @fields_loop, { hostbiblionumber => $hostbiblionumber, hosttitle => $hosttitle, hostitemnumber => $hostitemnumber}; + push @marchosts, { MARCHOSTS_FIELDS_LOOP => \@fields_loop }; + + } + my $marchostsarray = \@marchosts; + return $marchostsarray; +} + =head2 GetFrameworkCode $frameworkcode = GetFrameworkCode( $biblionumber ) @@ -1797,6 +1841,87 @@ sub TransformKohaToMarc { return $record; } +=head2 PrepHostMarcField + + $hostfield = PrepHostMarcField ( $hostbiblionumber,$hostitemnumber,$marcflavour ) + +This function returns a host field populated with data from the host record, the field can then be added to an analytical record + +=cut + +sub PrepHostMarcField { + my ($hostbiblionumber,$hostitemnumber, $marcflavour) = @_; + $marcflavour ||="MARC21"; + + my $hostrecord = GetMarcBiblio($hostbiblionumber); + my $item = C4::Items::GetItem($hostitemnumber); + + my $hostmarcfield; + if ( $marcflavour eq "MARC21" ) { + + #main entry + my $mainentry; + if ($hostrecord->subfield('100','a')){ + $mainentry = $hostrecord->subfield('100','a'); + } elsif ($hostrecord->subfield('110','a')){ + $mainentry = $hostrecord->subfield('110','a'); + } else { + $mainentry = $hostrecord->subfield('111','a'); + } + + # qualification info + my $qualinfo; + if (my $field260 = $hostrecord->field('260')){ + $qualinfo = $field260->as_string( 'abc' ); + } + + + #other fields + my $ed = $hostrecord->subfield('250','a'); + my $barcode = $item->{'barcode'}; + my $title = $hostrecord->subfield('245','a'); + + # record control number, 001 with 003 and prefix + my $recctrlno; + if ($hostrecord->field('001')){ + $recctrlno = $hostrecord->field('001')->data(); + if ($hostrecord->field('003')){ + $recctrlno = '('.$hostrecord->field('003')->data().')'.$recctrlno; + } + } + + # issn/isbn + my $issn = $hostrecord->subfield('022','a'); + my $isbn = $hostrecord->subfield('020','a'); + + + $hostmarcfield = MARC::Field->new( + 773, '', '', + '0' => $hostbiblionumber, + '9' => $hostitemnumber, + 'a' => $mainentry, + 'b' => $ed, + 'd' => $qualinfo, + 'o' => $barcode, + 't' => $title, + 'w' => $recctrlno, + 'x' => $issn, + 'z' => $isbn + ); + }; + if ($marcflavour eq "UNIMARC") { + $hostmarcfield = MARC::Field->new( + 461, '', '', + '0' => $hostbiblionumber, + 't' => $hostrecord->subfield('200','a'), + '9' => $hostitemnumber + ); + }; + + return $hostmarcfield; +} + + =head2 TransformKohaToMarcOneField $record = TransformKohaToMarcOneField( $sth, $record, $kohafieldname, $value, $frameworkcode ); diff --git a/C4/Items.pm b/C4/Items.pm index 2e85130..8cedb09 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -69,7 +69,9 @@ BEGIN { GetItemsByBiblioitemnumber GetItemsInfo GetItemsLocationInfo + GetHostItemsInfo get_itemnumbers_of + get_hostitemnumbers_of GetItemnumberFromBarcode GetBarcodeFromItemnumber GetHiddenItemnumbers @@ -78,6 +80,8 @@ BEGIN { MoveItemFromBiblio GetLatestAcquisitions CartToShelf + + GetAnalyticsCount ); } @@ -1395,6 +1399,46 @@ sub GetItemsLocationInfo { return @results; } +=head2 GetHostItemsInfo + + $hostiteminfo = GetHostItemsInfo($hostfield); + Returns the iteminfo for items linked to records via a host field + +=cut + +sub GetHostItemsInfo { + my ($record) = @_; + my @returnitemsInfo; + + if ( C4::Context->preference('marcflavour') eq 'MARC21'){ + foreach my $hostfield ( $record->field('773') ) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + my @hostitemInfos = GetItemsInfo($hostbiblionumber); + foreach my $hostitemInfo (@hostitemInfos){ + if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ + push (@returnitemsInfo,$hostitemInfo); + last; + } + } + } + } + if ( C4::Context->preference('marcflavour') eq 'UNIMARC'){ + foreach my $hostfield ( $record->field('461') ) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + my @hostitemInfos = GetItemsInfo($hostbiblionumber); + foreach my $hostitemInfo (@hostitemInfos){ + if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ + push (@returnitemsInfo,$hostitemInfo); + last; + } + } + } + } + return @returnitemsInfo; +} + =head2 GetLastAcquisitions @@ -1482,6 +1526,46 @@ sub get_itemnumbers_of { return \%itemnumbers_of; } +=head2 get_hostitemnumbers_of + + my @itemnumbers_of = get_hostitemnumbers_of($biblionumber); + +Given a biblionumber, return the list of corresponding itemnumbers that are linked to it via host fields + +Return a reference on a hash where key is a biblionumber and values are +references on array of itemnumbers. + +=cut + + +sub get_hostitemnumbers_of { + my ($biblionumber) = @_; + my $marcrecord = GetMarcBiblio($biblionumber); + my (@returnhostitemnumbers,$tag, $biblio_s, $item_s); + + my $marcflavor = C4::Context->preference('marcflavour'); + if ($marcflavor eq 'MARC21'){$tag='773';$biblio_s='0';$item_s='9'}; + if ($marcflavor eq 'UNIMARC'){$tag='461';$biblio_s='0';$item_s='9'}; + + foreach my $hostfield ( $marcrecord->field($tag) ) { + my $hostbiblionumber = $hostfield->subfield($biblio_s); + my $linkeditemnumber = $hostfield->subfield($item_s); + my @itemnumbers; + if (my $itemnumbers = get_itemnumbers_of($hostbiblionumber)->{$hostbiblionumber}) + { + @itemnumbers = @$itemnumbers; + } + foreach my $itemnumber (@itemnumbers){ + if ($itemnumber eq $linkeditemnumber){ + push (@returnhostitemnumbers,$itemnumber); + last; + } + } + } + return @returnhostitemnumbers; +} + + =head2 GetItemnumberFromBarcode $result = GetItemnumberFromBarcode($barcode); @@ -2094,35 +2178,35 @@ sub DelItemCheck { my ( $dbh, $biblionumber, $itemnumber ) = @_; my $error; + my $countanalytics=GetAnalyticsCount($itemnumber); + + # check that there is no issue on this item before deletion. my $sth=$dbh->prepare("select * from issues i where i.itemnumber=?"); $sth->execute($itemnumber); my $item = GetItem($itemnumber); - my $onloan = $sth->fetchrow; - if ($onloan) { - $error = "book_on_loan"; + my $onloan=$sth->fetchrow; + + if ($onloan){ + $error = "book_on_loan" } elsif (C4::Context->preference("IndependantBranches") and (C4::Context->userenv->{branch} ne $item->{C4::Context->preference("HomeOrHoldingBranch")||'homebranch'})){ $error = "not_same_branch"; - } - else { - if ($onloan){ - $error = "book_on_loan" - } - else { - # check it doesnt have a waiting reserve - $sth=$dbh->prepare("SELECT * FROM reserves WHERE (found = 'W' or found = 'T') AND itemnumber = ?"); - $sth->execute($itemnumber); - my $reserve=$sth->fetchrow; - if ($reserve) { - $error = "book_reserved"; - } - else { - DelItem($dbh, $biblionumber, $itemnumber); - return 1; - } - } + } + else{ + # check it doesnt have a waiting reserve + $sth=$dbh->prepare("SELECT * FROM reserves WHERE (found = 'W' or found = 'T') AND itemnumber = ?"); + $sth->execute($itemnumber); + my $reserve=$sth->fetchrow; + if ($reserve){ + $error = "book_reserved"; + } elsif ($countanalytics > 0){ + $error = "linked_analytics"; + } else { + DelItem($dbh, $biblionumber, $itemnumber); + return 1; + } } return $error; } @@ -2339,4 +2423,28 @@ sub _parse_unlinked_item_subfields_from_xml { return $unlinked_subfields; } +=head2 GetAnalyticsCount + + $count= &GetAnalyticsCount($itemnumber) + +counts Usage of itemnumber in Analytical bibliorecords. + +=cut + +sub GetAnalyticsCount { + my ($itemnumber) = @_; + if (C4::Context->preference('NoZebra')) { + # Read the index Koha-Auth-Number for this authid and count the lines + my $result = C4::Search::NZanalyse("hi=$itemnumber"); + my @tab = split /;/,$result; + return scalar @tab; + } else { + ### ZOOM search here + my $query; + $query= "hi=".$itemnumber; + my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10); + return ($result); + } +} + 1; diff --git a/C4/Reserves.pm b/C4/Reserves.pm index f83f0ff..63f112e 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -383,6 +383,14 @@ sub CanBookBeReserved{ my ($borrowernumber, $biblionumber) = @_; my @items = GetItemsInfo($biblionumber); + + #get items linked via host records + my $marcrecord= GetMarcBiblio($biblionumber); + my @hostitemInfos = GetHostItemsInfo($marcrecord); + if (@hostitemInfos){ + push (@items,@hostitemInfos); + } + foreach my $item (@items){ return 1 if CanItemBeReserved($borrowernumber, $item->{itemnumber}); } diff --git a/C4/Search.pm b/C4/Search.pm index b9069f5..7a2e397 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1559,6 +1559,48 @@ sub searchResults { # Pull out the items fields my @fields = $marcrecord->field($itemtag); + my $marcflavor = C4::Context->preference("marcflavour"); + # adding linked items that belong to host records + if ($marcflavor eq 'MARC21'){ + foreach my $hostfield ( $marcrecord->field('773')) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + if(!$hostbiblionumber eq undef){ + my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1); + if(!$hostbiblio eq undef){ + my @hostitems = $hostbiblio->field('952'); + foreach my $hostitem (@hostitems){ + if ($hostitem->subfield("9") eq $linkeditemnumber){ + my $linkeditem =$hostitem; + # append linked items if they exist + if (!$linkeditem eq undef){ + push (@fields, $linkeditem);} + } + } + } + } + } + } + if ($marcflavor eq 'UNIMARC'){ + foreach my $hostfield ( $marcrecord->field('461')) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + if(!$hostbiblionumber eq undef){ + my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1); + if(!$hostbiblio eq undef){ + my @hostitems = $hostbiblio->field('995'); + foreach my $hostitem (@hostitems){ + if ($hostitem->subfield("9") eq $linkeditemnumber){ + my $linkeditem =$hostitem; + # append linked items if they exist + if (!$linkeditem eq undef){ + push (@fields, $linkeditem);} + } + } + } + } + } + } # Setting item statuses for display my @available_items_loop; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 8738737..580949d 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -41,9 +41,12 @@ use C4::XSLT; # use Smart::Comments; my $query = CGI->new(); + +my $analyze = $query->param('analyze'); + my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { - template_name => "catalogue/detail.tmpl", + template_name => 'catalogue/detail.tmpl', query => $query, type => "intranet", authnotrequired => 0, @@ -105,6 +108,7 @@ my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); my $marcseriesarray = GetMarcSeries($record,$marcflavour); my $marcurlsarray = GetMarcUrls ($record,$marcflavour); +my $marchostsarray = GetMarcHosts($record,$marcflavour); my $subtitle = GetRecordValue('subtitle', $record, $fw); # Get Branches, Itemtypes and Locations @@ -117,6 +121,16 @@ my @items; for my $itm (@all_items) { push @items, $itm unless ( $itm->{itemlost} && GetHideLostItemsPreference($borrowernumber) && !$showallitems); } + +# flag indicating existence of at least one item linked via a host record +my $hostrecords; +# adding items linked via host biblios +my @hostitems = GetHostItemsInfo($record); +if (@hostitems){ + $hostrecords =1; + push (@items,@hostitems); +} + my $dat = &GetBiblioData($biblionumber); # get count of holds @@ -148,9 +162,9 @@ if ( defined $dat->{'itemtype'} ) { $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); } -$dat->{'count'} = scalar @all_items; -$dat->{'showncount'} = scalar @items; -$dat->{'hiddencount'} = scalar @all_items - scalar @items; +$dat->{'count'} = scalar @all_items + @hostitems; +$dat->{'showncount'} = scalar @items + @hostitems; +$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items; my $shelflocations = GetKohaAuthorisedValues('items.location', $fw); my $collections = GetKohaAuthorisedValues('items.ccode' , $fw); @@ -158,6 +172,8 @@ my (@itemloop, %itemfields); my $norequests = 1; my $authvalcode_items_itemlost = GetAuthValCode('items.itemlost',$fw); my $authvalcode_items_damaged = GetAuthValCode('items.damaged', $fw); + +my $analytics_flag; foreach my $item (@items) { $item->{homebranch} = GetBranchName($item->{homebranch}); @@ -223,6 +239,19 @@ foreach my $item (@items) { $item->{waitingdate} = format_date($wait_hashref->{waitingdate}); } + # item has a host number if its biblio number does not match the current bib + if ($item->{biblionumber} ne $biblionumber){ + $item->{hostbiblionumber} = $item->{biblionumber}; + $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; + } + + #count if item is used in analytical bibliorecords + my $countanalytics= GetAnalyticsCount($item->{itemnumber}); + if ($countanalytics > 0){ + $analytics_flag=1; + $item->{countanalytics} = $countanalytics; + } + push @itemloop, $item; } @@ -234,6 +263,7 @@ $template->param( MARCSERIES => $marcseriesarray, MARCURLS => $marcurlsarray, MARCISBNS => $marcisbnsarray, + MARCHOSTS => $marchostsarray, subtitle => $subtitle, itemdata_ccode => $itemfields{ccode}, itemdata_enumchron => $itemfields{enumchron}, @@ -243,6 +273,8 @@ $template->param( itemdata_itemnotes => $itemfields{itemnotes}, z3950_search_params => C4::Search::z3950_search_args($dat), holdcount => $holdcount, + hostrecords => $hostrecords, + analytics_flag => $analytics_flag, C4::Search::enabled_staff_search_views, ); @@ -284,7 +316,7 @@ foreach ( keys %{$dat} ) { $template->param( itemloop => \@itemloop, biblionumber => $biblionumber, - detailview => 1, + ($analyze? 'analyze':'detailview') =>1, subscriptions => \@subs, subscriptionsnumber => $subscriptionsnumber, subscriptiontitle => $dat->{title}, diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index d285a49..6f6d10d 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -97,6 +97,18 @@ for my $itm (@all_items) { ($itemnumber != $itm->{itemnumber})); } +my $record=GetMarcBiblio($biblionumber); + +my $hostrecords; +# adding items linked via host biblios +my @hostitems = GetHostItemsInfo($record); +if (@hostitems){ + $hostrecords =1; + push (@items,@hostitems); +} + + + my $totalcount=@all_items; my $showncount=@items; my $hiddencount = $totalcount - $showncount; @@ -121,6 +133,12 @@ foreach my $item (@items){ $item->{'datelastseen'} = format_date( $item->{'datelastseen'} ); $item->{'copyvol'} = $item->{'copynumber'}; + # item has a host number if its biblio number does not match the current bib + if ($item->{biblionumber} ne $biblionumber){ + $item->{hostbiblionumber} = $item->{biblionumber}; + $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; + } + my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); $item->{'ordernumber'} = $order->{'ordernumber'}; $item->{'basketno'} = $order->{'basketno'}; diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 29df4a5..ee0662a 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -349,6 +349,10 @@ sub create_input { $value eq '' && !$tdef->{$subfield}->{mandatory} && !$tdef->{mandatory}; + # expand all subfields of 773 if there is a host item provided in the input + $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber')); + + # it's an authorised field if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { $subfield_data{marc_value} = @@ -696,7 +700,7 @@ sub build_tabs ($$$$$) { # always include in the form regardless of the hidden setting - bug 2206 next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop ); - push( + push( @subfields_data, &create_input( $tag, $subfield, '', $index_tag, $tabloop, $record, @@ -834,6 +838,8 @@ my $mode = $input->param('mode'); my $frameworkcode = $input->param('frameworkcode'); my $redirect = $input->param('redirect'); my $dbh = C4::Context->dbh; +my $hostbiblionumber = $input->param('hostbiblionumber'); +my $hostitemnumber = $input->param('hostitemnumber'); my $userflags = 'edit_catalogue'; @@ -904,6 +910,14 @@ if (($biblionumber) && !($breedingid)){ if ($breedingid) { ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ; } +#populate hostfield if hostbiblionumber is available +if ($hostbiblionumber){ + my $marcflavour = C4::Context->preference("marcflavour"); + $record=MARC::Record->new(); + $record->leader(''); + my $field = PrepHostMarcField($hostbiblionumber, $hostitemnumber,$marcflavour); + $record->append_fields($field); +} $is_a_modif = 0; @@ -1055,6 +1069,8 @@ elsif ( $op eq "delete" ) { biblioitemnumtagfield => $biblioitemnumtagfield, biblioitemnumtagsubfield => $biblioitemnumtagsubfield, biblioitemnumber => $biblioitemnumber, + hostbiblionumber => $hostbiblionumber, + hostitemnumber => $hostitemnumber ); } diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 0db2d2d..1ec9163 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -276,6 +276,8 @@ my $error = $input->param('error'); my $biblionumber = $input->param('biblionumber'); my $itemnumber = $input->param('itemnumber'); my $op = $input->param('op'); +my $hostitemnumber = $input->param('hostitemnumber'); +my $marcflavour = C4::Context->preference("marcflavour"); my $frameworkcode = &GetFrameworkCode($biblionumber); @@ -502,6 +504,24 @@ if ($op eq "additem") { $itemnumber=""; } $nextop="additem"; +} elsif ($op eq "delinkitem"){ + if ($marcflavour eq 'MARC21'){ + foreach my $field ($record->field('773')){ + if ($field->subfield('9') eq $hostitemnumber){ + $record->delete_field($field); + last; + } + } + } + if ($marcflavour eq 'UNIMARC'){ + foreach my $field ($record->field('461')){ + if ($field->subfield('9') eq $hostitemnumber){ + $record->delete_field($field); + last; + } + } + } + my $modbibresult = ModBiblio($record, $biblionumber,''); } # @@ -512,6 +532,8 @@ if ($op eq "additem") { # now, build existiing item list my $temp = GetMarcBiblio( $biblionumber ); #my @fields = $record->fields(); + + my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code my @big_array; #---- finds where items.itemnumber is stored @@ -520,6 +542,22 @@ my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebran C4::Biblio::EmbedItemsInMarcBiblio($temp, $biblionumber); my @fields = $temp->fields(); + +my @hostitemnumbers; +foreach my $hostfield ($temp->field('773')){ + if ($hostfield->subfield('0')){ + my $hostrecord = GetMarcBiblio($hostfield->subfield('0'), 1); + foreach my $hostitem ($hostrecord->field('952')){ + if ($hostitem->subfield('9') eq $hostfield->subfield('9')){ + push (@fields, $hostitem); + push (@hostitemnumbers, $hostfield->subfield('9')); + } + } + } +} + + + foreach my $field (@fields) { next if ( $field->tag() < 10 ); @@ -550,6 +588,19 @@ foreach my $field (@fields) { } } $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield); + foreach my $hostitemnumber (@hostitemnumbers){ + if ($this_row{itemnumber} eq $hostitemnumber){ + $this_row{hostitemflag} = 1; + $this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber); + last; + } + } + +# my $countanalytics=GetAnalyticsCount($this_row{itemnumber}); +# if ($countanalytics > 0){ +# $this_row{countanalytics} = $countanalytics; +# } + } if (%this_row) { push(@big_array, \%this_row); @@ -570,6 +621,9 @@ for my $row ( @big_array ) { $row_data{itemnumber} = $row->{itemnumber}; #reporting this_row values $row_data{'nomod'} = $row->{'nomod'}; + $row_data{'hostitemflag'} = $row->{'hostitemflag'}; + $row_data{'hostbiblionumber'} = $row->{'hostbiblionumber'}; +# $row_data{'countanalytics'} = $row->{'countanalytics'}; push(@item_value_loop,\%row_data); } foreach my $subfield_code (sort keys(%witness)) { diff --git a/cataloguing/linkitem.pl b/cataloguing/linkitem.pl new file mode 100755 index 0000000..33a8397 --- /dev/null +++ b/cataloguing/linkitem.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# Link an item belonging to an analytical record, the item barcode needs to be provided +# +# Copyright 2009 BibLibre, 2010 Nucsoft OSS Labs +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Biblio; +use C4::Items; +use C4::Context; +use C4::Koha; +use C4::Branch; + + +my $query = CGI->new; + +my $biblionumber = $query->param('biblionumber'); +my $barcode = $query->param('barcode'); + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "cataloguing/linkitem.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {editcatalogue => 'edit_catalogue'}, + debug => 1, + }); + +my $biblio = GetMarcBiblio($biblionumber); +my $marcflavour = C4::Context->preference("marcflavour"); +$marcflavour ||="MARC21"; +if ($marcflavour eq 'MARC21'){$template->param(bibliotitle => $biblio->subfield('245','a'))}; +if ($marcflavour eq 'UNIMARC'){$template->param(bibliotitle => $biblio->subfield('200','a'))}; + +$template->param(biblionumber => $biblionumber); + +if ($barcode && $biblionumber) { + + # We get the host itemnumber + my $hostitemnumber = GetItemnumberFromBarcode($barcode); + + if ($hostitemnumber) { + my $hostbiblionumber = GetBiblionumberFromItemnumber($hostitemnumber); + + if ($hostbiblionumber) { + my $field = PrepHostMarcField($hostbiblionumber, $hostitemnumber,$marcflavour); + $biblio->append_fields($field); + + my $modresult = ModBiblio($biblio, $biblionumber, ''); + if ($modresult) { + $template->param(success => 1); + } else { + $template->param(error => 1, + errornomodbiblio => 1); + } + } else { + $template->param(error => 1, + errornohostbiblionumber => 1); + } + } else { + $template->param(error => 1, + errornohostitemnumber => 1); + + } + $template->param( + barcode => $barcode, + hostitemnumber => $hostitemnumber, + ); + +} else { + $template->param(missingparameter => 1); + if (!$barcode) { $template->param(missingbarcode => 1); } + if (!$biblionumber) { $template->param(missingbiblionumber => 1); } +} + + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/etc/zebradb/biblios/etc/bib1.att b/etc/zebradb/biblios/etc/bib1.att index c23ca2e..b2c38c4 100644 --- a/etc/zebradb/biblios/etc/bib1.att +++ b/etc/zebradb/biblios/etc/bib1.att @@ -257,6 +257,7 @@ att 8031 itype ## Fixed Fields and other special indexes att 9901 Extent att 8910 Koha-Auth-Number +att 8911 Host-Item-Number # record length according to the leader att 9905 llength att 9902 Summary @@ -290,4 +291,3 @@ att 9013 arp att 9520 Item # Curriculum att 9658 curriculum - diff --git a/etc/zebradb/ccl.properties b/etc/zebradb/ccl.properties index 890b364..e427d5c 100644 --- a/etc/zebradb/ccl.properties +++ b/etc/zebradb/ccl.properties @@ -1064,6 +1064,7 @@ arl 1=9904 r=r #Accelerated Reader Point arp 1=9013 r=r + # Curriculum curriculum 1=9658 @@ -1169,3 +1170,5 @@ ElementSetName exp1,1=12 Item 1=9520 item Item +Host-Item-Number 1=8911 +hi Host-Item-Number diff --git a/etc/zebradb/marc_defs/marc21/biblios/record.abs b/etc/zebradb/marc_defs/marc21/biblios/record.abs index 54e1699..92467ab 100755 --- a/etc/zebradb/marc_defs/marc21/biblios/record.abs +++ b/etc/zebradb/marc_defs/marc21/biblios/record.abs @@ -44,7 +44,7 @@ melm 001 Control-number melm 005 Date/time-last-modified melm 007 Microform-generation:n:range(data,11,1),Material-type,ff7-00:w:range(data,0,1),ff7-01:w:range(data,1,1),ff7-02:w:range(data,2,1),ff7-01-02:w:range(data,0,2) -melm 008 date-entered-on-file:n:range(data,0,5),date-entered-on-file:s:range(data,0,5),pubdate:w:range(data,7,4),pubdate:n:range(data,7,4),pubdate:y:range(data,7,4),pubdate:s:range(data,7,4),pl:w:range(data,15,3),ta:w:range(data,22,1),ff8-23:w:range(data,23,1),ff8-29:w:range(data,29,1),lf:w:range(data,33,1),bio:w:range(data,34,1),ln:w:range(data,35,3),ctype:w:range(data,24,4),Record-source:w:range(data,39,0) +melm 008 date-entered-on-file:n:range(data,0,5),date-entered-on-file:s:range(data,0,5),pubdate:w:range(data,7,4),pubdate:n:range(data,7,4),pubdate:y:range(data,7,4),pubdate:s:range(data,7,4),pl:w:range(data,15,3),ta:w:range(data,22,1),ff8-23:w:range(data,23,1),ff8-29:w:range(data,29,1),lf:w:range(data,33,1),bio:w:range(data,34,1),ln:n:range(data,35,3),ctype:w:range(data,24,4),Record-source:w:range(data,39,0) melm 010 LC-card-number,Identifier-standard melm 011 LC-card-number,Identifier-standard @@ -227,6 +227,7 @@ melm 751 Name-geographic melm 770$w Record-control-number melm 772$w Record-control-number melm 773$a Host-item +melm 773$9 Host-Item-Number melm 773$t Host-item melm 773$w Record-control-number melm 774$w Record-control-number diff --git a/etc/zebradb/marc_defs/unimarc/biblios/record.abs b/etc/zebradb/marc_defs/unimarc/biblios/record.abs index a9e88d5..a30d10f 100644 --- a/etc/zebradb/marc_defs/unimarc/biblios/record.abs +++ b/etc/zebradb/marc_defs/unimarc/biblios/record.abs @@ -235,6 +235,9 @@ melm 441$d pubdate:n melm 445$d pubdate:n melm 461$d pubdate:n +#Linking ids +melm 461$9 Host-Item-Number + # Authorities Title melm 500$9 Koha-Auth-Number,Koha-Auth-Number:n melm 501$9 Koha-Auth-Number,Koha-Auth-Number:n diff --git a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql b/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql index 383a9d9..8e817ff 100644 --- a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql +++ b/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql @@ -2358,10 +2358,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL), diff --git a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql b/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql index 701b1b9..3ecd4fd 100644 --- a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql +++ b/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql @@ -2376,10 +2376,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'BKS', '', '', NULL), @@ -6302,10 +6304,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'CF', '', '', NULL), @@ -10227,10 +10231,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SF', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SR', '', '', NULL), @@ -14152,10 +14158,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'VR', '', '', NULL), @@ -18075,10 +18083,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'AR', '', '', NULL), @@ -21998,10 +22008,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'KT', '', '', NULL), @@ -25922,10 +25934,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'IR', '', '', NULL), @@ -29842,10 +29856,12 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('772', 'x', 'International Standard Serial Number', 'International Standard Serial Number', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('772', 'y', 'CODEN designation', 'CODEN designation', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('772', 'z', 'International Standard Book Number', 'International Standard Book Number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), + ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', '3', 'Materials specified', 'Materials specified', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', '6', 'Linkage', 'Linkage', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', '7', 'Control subfield', 'Control subfield', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), + ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', 'a', 'Main entry heading', 'Main entry heading', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', 'b', 'Edition', 'Edition', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), ('773', 'd', 'Place, publisher, and date of publication', 'Place, publisher, and date of publication', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, 'SER', '', '', NULL), diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 79d4893..72d1441 100755 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -318,3 +318,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6b88c29..c830a4f 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4445,6 +4445,21 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { print "Upgrade to $DBversion done (add OPACResultsSidebar syspref (enh 6165))\n"; SetVersion($DBversion); } + +$DBversion = '3.05.00.XXX'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo');"); + print "Upgrade to $DBversion done (Add EasyAnalyticalRecords syspref)\n"; + SetVersion ($DBversion); +} + +$DBversion = '3.05.00.XXX'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL)"); + $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL)"); + print "Upgrade to $DBversion done (Add 773 subfield 9 and 0 to default framework)\n"; + SetVersion ($DBversion); +} =head1 FUNCTIONS diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 770a3f8..a944dc5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -23,6 +23,7 @@ [% IF ( CAN_user_reserveforothers ) %] [% IF ( holdsview ) %]
  • [% ELSE %]
  • [% END %]Holds
  • [% END %] + [% IF ( EasyAnalyticalRecords ) %][% IF ( analyze ) %]
  • [% ELSE %]
  • [% END %]Analytics
  • [% END %] [% IF ( subscriptionsnumber ) %]
  • Subscription(s)
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 9766494..6c7ffae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -82,6 +82,7 @@ function confirm_items_deletion() { [% IF ( CAN_user_editcatalogue_edit_items ) %]{text: _("New Item"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]#additema" },[% END %] [% IF ( CAN_user_serials_create_subscription ) %] {text: _("New Subscription"), url: "/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=[% biblionumber %]"},[% END %] + [% IF ( EasyAnalyticalRecords ) %][% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{text: _("Analyze items"), url: "/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]&analyze=1" },[% END %][% END %] ]; if(newmenu.length){ new YAHOO.widget.Button({ @@ -97,6 +98,7 @@ function confirm_items_deletion() { [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&frameworkcode=&op=" },[% END %] [% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]" },[% END %] [% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Attach Item"), url: "/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=[% biblionumber %]" },[% END %] + [% IF ( EasyAnalyticalRecords ) %][% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Link to Host Item"), url: "/cgi-bin/koha/cataloguing/linkitem.pl?biblionumber=[% biblionumber %]" },[% END %][% END %] [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&frameworkcode=&op=duplicate" },[% END %] [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace Record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %] [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete Record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 4fc1305..10e1d13 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -12,6 +12,12 @@ Cataloging: yes: "Don't display" no: Display - descriptions of fields and subfields in the MARC editor. + - + - pref: EasyAnalyticalRecords + choices: + yes: Display + no: "Don't Display" + - easy ways to create analytical record relationships Spine Labels: - - When using the quick spine label printer, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 8903ce1..b1e225f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -248,6 +248,9 @@ function verify_images() { [% IF ( itemdata_copynumber ) %]Copy No.[% END %] [% IF ( itemdata_itemnotes ) %]Public notes[% END %] [% IF ( SpineLabelShowPrintOnBibDetails ) %]Spine Label[% END %] + [% IF ( hostrecords ) %]Host Records[% END %] + [% IF ( analyze ) %]Used in[% END %] + [% IF ( analyze ) %][% END %] [% FOREACH itemloo IN itemloop %] @@ -360,8 +363,8 @@ function verify_images() { [% IF ( itemloo.enumchron ) %] [% itemloo.enumchron %][% IF ( itemloo.serialseq ) %] -- [% END %] [% END %] - [% END %] [% itemloo.serialseq %][% IF ( itemloo.publisheddate ) %] ([% itemloo.publisheddate %])[% END %] + [% END %] [% END %] [% IF ( itemdata_uri ) %] [% itemloo.uri %] @@ -373,6 +376,17 @@ function verify_images() { [% IF ( SpineLabelShowPrintOnBibDetails ) %] Print Label [% END %] + [% IF ( hostrecords ) %] + [% IF ( itemloo.hostbiblionumber) %][% itemloo.hosttitle %][% END %] + [% END %] + [% IF ( analyze ) %] + [% IF ( itemloo.countanalytics ) %] + [% itemloo.countanalytics %] analytics + [% END %] + [% END %] + [% IF ( analyze ) %] + Create Analytics + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index efdda6a..673b08b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -190,6 +190,7 @@ function set_to_today(id, force) { [% IF ( book_on_loan ) %]
    Cannot Delete: item is checked out.
    [% END %] [% IF ( book_reserved ) %]
    Cannot Delete: item has a waiting hold.
    [% END %] [% IF ( not_same_branch ) %]
    Cannot Delete: The items do not belong to your branch.
    [% END %] +[% IF ( linked_analytics ) %]
    Cannot Delete: item has linked analytics..
    [% END %]
    [% IF ( item_loop ) %] @@ -205,8 +206,10 @@ function set_to_today(id, force) { [% FOREACH item_loo IN item_loop %] - [% IF ( item_loo.nomod ) %]  [% ELSE %]Edit - Delete[% END %] + [% IF ( item_loo.nomod ) %]  [% ELSE %][% IF ( item_loo.hostitemflag ) %]Edit in Host +Delink +[% ELSE %]Edit + [% IF ( item_loo.countanalytics ) %]view analytics[% ELSE %]Delete[% END %][% END %][% END %] [% FOREACH item_valu IN item_loo.item_value %] [% item_valu.field |html %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl new file mode 100644 index 0000000..2ed9b8e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl @@ -0,0 +1,57 @@ + +Link to host item + + + + + + +
    + + +
    + ERROR: Unable to modify the bibliographic record. + ERROR: Unable to get the biblio number of host item. + ERROR: Unable to get the item number from this barcode. +
    +
    + + " /> +
    + + +
    The item has successfully been linked to .
    +
    + + " /> +
    + + +
    + +
    + +
    Enter biblionumber:
    + +
    + + " /> + + + +
    + +
    Enter item barcode:
    + +
    + + " /> + + + + +
    + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tt new file mode 100644 index 0000000..38114f6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tt @@ -0,0 +1,57 @@ +[% INCLUDE 'doc-head-open.inc' %] +Link to host item +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + +
    + +[% IF ( error ) %] +
    + [% IF ( errornomodbiblio ) %]ERROR: Unable to modify the bibliographic record.[% END %] + [% IF ( errornohostbiblionumber ) %]ERROR: Unable to get the biblio number of host item.[% END %] + [% IF ( errornohostitemnumber ) %]ERROR: Unable to get the item number from this barcode.[% END %] +
    +
    + + +
    +[% ELSE %] + [% IF ( success ) %] +
    The item has successfully been linked to [% bibliotitle |html %].
    +
    + + +
    + [% ELSE %] + [% IF ( missingparameter ) %] +
    + [% IF ( missingbiblionumber ) %] +
    + +
    Enter biblionumber:
    + +
    + [% ELSE %] + + [% END %] + + [% IF ( missingbarcode ) %] +
    + +
    Enter item barcode:
    + +
    + [% ELSE %] + + [% END %] + + + +
    + [% END %] + [% END %] +[% END %] +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index 112a809..17cc8d4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -273,6 +273,29 @@ + + + In: + + + + + /cgi-bin/koha/catalogue/detail.pl?biblionumber= + + + /cgi-bin/koha/catalogue/search.pl?q=Title: + + + + + + + ; + + + + + diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl index 404293f..1e7baa4 100755 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl @@ -330,6 +330,29 @@ + + + In: + + + + + /cgi-bin/koha/catalogue/detail.pl?biblionumber= + + + /cgi-bin/koha/catalogue/search.pl?q=Title: + + + + + + + ; + + + + + diff --git a/misc/migration_tools/create_analytical_rel.pl b/misc/migration_tools/create_analytical_rel.pl new file mode 100755 index 0000000..a3cd4ff --- /dev/null +++ b/misc/migration_tools/create_analytical_rel.pl @@ -0,0 +1,151 @@ +#!/usr/bin/perl + +use strict; +#use warnings; FIXME - Bug 2505 +BEGIN { + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/../kohalib.pl" }; +} + +use C4::Context; +use C4::Biblio; +use C4::Items; +use Getopt::Long; + +$| = 1; + +# command-line parameters +my $want_help = 0; +my $do_update = 0; +my $wherestrings; + +my $result = GetOptions( + 'run-update' => \$do_update, + 'where=s@' => \$wherestrings, + 'h|help' => \$want_help, +); + +if (not $result or $want_help or not $do_update) { + print_usage(); + exit 0; +} + +my $num_bibs_processed = 0; +my $num_bibs_modified = 0; +my $num_nobib_foritemnumber = 0; +my $num_noitem_forbarcode = 0; +my $num_nobarcode_inhostfield =0; +my $num_hostfields_unabletomodify =0; +my $num_bad_bibs = 0; +my $dbh = C4::Context->dbh; +$dbh->{AutoCommit} = 0; + +process_bibs(); +$dbh->commit(); + +exit 0; + +sub process_bibs { + my $sql = "SELECT biblionumber FROM biblio JOIN biblioitems USING (biblionumber)"; + $sql.="WHERE ". join(" AND ",@$wherestrings) if ($wherestrings); + $sql.="ORDER BY biblionumber ASC"; + my $sth = $dbh->prepare($sql); + eval{$sth->execute();}; + if ($@){ die "error $@";}; + while (my ($biblionumber) = $sth->fetchrow_array()) { + $num_bibs_processed++; + process_bib($biblionumber); + + if (($num_bibs_processed % 100) == 0) { + print_progress_and_commit($num_bibs_processed); + } + } + + $dbh->commit; + + print <<_SUMMARY_; + +Create Analytical records relationships report +----------------------------------------------- +Number of bibs checked: $num_bibs_processed +Number of bibs modified: $num_bibs_modified +Number of hostfields with no barcodes: $num_nobarcode_inhostfield +Number of barcodes not found: $num_noitem_forbarcode +Number of hostfields unable to modify: $num_hostfields_unabletomodify +Number of bibs with errors: $num_bad_bibs +_SUMMARY_ +} + +sub process_bib { + my $biblionumber = shift; + + my $bib = GetMarcBiblio($biblionumber); + unless (defined $bib) { + print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n"; + $num_bad_bibs++; + return; + } + #loop through each host field and populate subfield 0 and 9 + foreach my $hostfield ( $bib->field('773') ) { + if(my $barcode = $hostfield->subfield('o')){ + my $itemnumber = GetItemnumberFromBarcode($barcode); + if ($itemnumber ne undef){ + my $bibnumber = GetBiblionumberFromItemnumber($itemnumber); + if ($bibnumber ne undef){ + my $modif; + if ($hostfield->subfield('0') ne $bibnumber){ + $hostfield->update('0', $bibnumber); + $modif = 1; + } + if ($hostfield->subfield('9') ne $itemnumber){ + $hostfield->update('9', $itemnumber); + $modif=1; + } + if ($modif){ + $num_bibs_modified++; + my $modresult = ModBiblio($bib, $biblionumber, ''); + warn "Modifying biblio $biblionumber"; + if (!$modresult){ + warn "Unable to modify biblio $biblionumber with update host field"; + $num_hostfields_unabletomodify++; + } + } + } else { + warn "No biblio record found corressponding to itemnumber $itemnumber"; + $num_nobib_foritemnumber++; + } + } else { + warn "No item record found for barcode $barcode"; + $num_noitem_forbarcode++; + } + } else{ + warn "No barcode in host field for biblionumber $biblionumber"; + $num_nobarcode_inhostfield++; + } + } +} + +sub print_progress_and_commit { + my $recs = shift; + $dbh->commit(); + print "... processed $recs records\n"; +} + +sub print_usage { + print <<_USAGE_; +$0: establish relationship to host items + +Based on barcode in host field populates subfield 0 with host biblionumber and subfield 9 with host itemnumber. + +Subfield 0 and 9 are used in Koha screns to display relationships between analytical records and host bibs and items. + +NOT usable with UNIMARC data. You can use it only if you have tag 461 with also an items id (like barcode or item numbers). In UNIMARC this situation is very rare. If you have data coded in this way, send a mail to koha-dev mailing list and ask for the feature. + +Parameters: + --run-update run the synchronization + --where condition selects the biblios on a criterium (Repeatable) + --help or -h show this message. +_USAGE_ +} diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index e18e046..4516c68 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -86,6 +86,35 @@ if (C4::Context->preference("OPACXSLTDetailsDisplay") ) { $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); # change back when ive fixed request.pl my @all_items = GetItemsInfo( $biblionumber ); + +# adding items linked via host biblios +my $marcflavour = C4::Context->preference("marcflavour"); + +if ($marcflavour eq 'MARC21'){ + foreach my $hostfield ( $record->field('773')) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + my @hostitemInfos = GetItemsInfo($hostbiblionumber); + foreach my $hostitemInfo (@hostitemInfos){ + if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ + push(@all_items, $hostitemInfo); + } + } + } +} +if ($marcflavour eq 'UNIMARC'){ + foreach my $hostfield ( $record->field('461')) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + my @hostitemInfos = GetItemsInfo($hostbiblionumber); + foreach my $hostitemInfo (@hostitemInfos){ + if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ + push(@all_items, $hostitemInfo); + } + } + } +} + my @items; # Getting items to be hidden @@ -217,13 +246,13 @@ for my $itm (@items) { ## get notes and subjects from MARC record my $dbh = C4::Context->dbh; -my $marcflavour = C4::Context->preference("marcflavour"); my $marcnotesarray = GetMarcNotes ($record,$marcflavour); my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour); my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour); my $marcseriesarray = GetMarcSeries ($record,$marcflavour); my $marcurlsarray = GetMarcUrls ($record,$marcflavour); +my $marchostsarray = GetMarcHosts($record,$marcflavour); my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); $template->param( @@ -232,6 +261,7 @@ my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($bib MARCAUTHORS => $marcauthorsarray, MARCSERIES => $marcseriesarray, MARCURLS => $marcurlsarray, + MARCHOSTS => $marchostsarray, norequests => $norequests, RequestOnOpac => C4::Context->preference("RequestOnOpac"), itemdata_ccode => $itemfields{ccode}, diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index ab02afe..7df68c0 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -123,6 +123,20 @@ foreach my $biblioNumber (@biblionumbers) { $biblioDataHash{$biblioNumber} = $biblioData; my @itemInfos = GetItemsInfo($biblioNumber); + + my $marcrecord= GetMarcBiblio($biblioNumber); + + # flag indicating existence of at least one item linked via a host record + my $hostitemsflag; + # adding items linked via host biblios + my @hostitemInfos = GetHostItemsInfo($marcrecord); + if (@hostitemInfos){ + $hostitemsflag =1; + push (@itemInfos,@hostitemInfos); + } + + + $biblioData->{itemInfos} = \@itemInfos; foreach my $itemInfo (@itemInfos) { $itemInfoHash{$itemInfo->{itemnumber}} = $itemInfo; @@ -188,6 +202,14 @@ if ( $query->param('place_reserve') ) { $branch = $borr->{'branchcode'}; } + #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber + if ($itemNum ne '') { + my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum); + if ($hostbiblioNum ne $biblioNum) { + $biblioNum = $hostbiblioNum; + } + } + my $biblioData = $biblioDataHash{$biblioNum}; my $found; @@ -382,6 +404,11 @@ foreach my $biblioNum (@biblionumbers) { my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemNum); my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0); + # the item could be reserved for this borrower vi a host record, flag this + if ($reservedfor eq $borrowernumber){ + $itemLoopIter->{already_reserved} = 1; + } + if ( defined $reservedate ) { $itemLoopIter->{backgroundcolor} = 'reserved'; $itemLoopIter->{reservedate} = format_date($reservedate); @@ -423,6 +450,13 @@ foreach my $biblioNum (@biblionumbers) { $itemLoopIter->{nocancel} = 1; } + # if the items belongs to a host record, show link to host record + if ($itemInfo->{biblionumber} ne $biblioNum){ + $biblioLoopIter{hostitemsflag} = 1; + $itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber}; + $itemLoopIter->{hosttitle} = GetBiblioData($itemInfo->{biblionumber})->{title}; + } + # If there is no loan, return and transfer, we show a checkbox. $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0; @@ -436,7 +470,7 @@ foreach my $biblioNum (@biblionumbers) { $policy_holdallowed = 0; } - if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum)) { + if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) { $itemLoopIter->{available} = 1; $numCopiesAvailable++; } diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index 19d76be..f3e79b3 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -98,6 +98,15 @@ if ($type eq 'str8' && $borrower){ } my $const; + if ($checkitem ne ''){ + my $item = GetItem($checkitem); + if ($item->{'biblionumber'} ne $biblionumber) { + $biblionumber = $item->{'biblionumber'}; + } + } + + + if ($multi_hold) { my $bibinfo = $bibinfos{$biblionumber}; AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',[$biblionumber], diff --git a/reserve/request.pl b/reserve/request.pl index f27e5db..774adef 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -291,7 +291,13 @@ foreach my $biblionumber (@biblionumbers) { if (my $items = get_itemnumbers_of($biblionumber)->{$biblionumber}){ @itemnumbers = @$items; } - else { + my @hostitems = get_hostitemnumbers_of($biblionumber); + if (@hostitems){ + $template->param('hostitemsflag' => 1); + push(@itemnumbers, @hostitems); + } + + if (!@itemnumbers) { $template->param('noitems' => 1); $biblioloopiter{noitems} = 1; } @@ -324,6 +330,9 @@ foreach my $biblionumber (@biblionumbers) { $biblioitem->{description} = $itemtypes->{ $biblioitem->{itemtype} }{description}; + if($biblioitem->{biblioitemnumber} ne $biblionumber){ + $biblioitem->{hostitemsflag}=1; + } $biblioloopiter{description} = $biblioitem->{description}; $biblioloopiter{itypename} = $biblioitem->{description}; $biblioloopiter{imageurl} = @@ -347,6 +356,11 @@ foreach my $biblionumber (@biblionumbers) { $branches->{ $item->{holdingbranch} }{branchname}; } + if($item->{biblionumber} ne $biblionumber){ + $item->{hostitemsflag}=1; + $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; + } + # add information $item->{itemcallnumber} = $item->{itemcallnumber}; -- 1.7.4.1