Bug 5528: Analytic records support

Display links to parent biblios, show linked items in holdings, allow holds on
linked items. This uses MARC to maintain relationships.

Sponsored by the Mississippi Department of Archives and History and RapidRadio
Solution. Originally developed by Savitra Sirohi and Amit Gupta at OSSLabs, with
UNIMARC support added by Zeno Tajoli. Commits squashed and merge conflicts
resolved by Chris Cormack from Catalyst. Respect for NORMARC and some small
framework portability fixes made by Jared Camins-Esakov of C & P Bibliography
Services.

IMPORTANT NOTE: A bug in the 773 coding for MARC21 was corrected from the
original OSS Labs code. The 773s generated by the pre-release code did not have
the first indicator set to '0', which means that they were not supposed to
display. Going forward, the first indicator will be set correctly, but existing
records created with this code will no longer appear (they appeared before only
due to another bug). To correct this, you could globally (or, to make sure you
only modify records created with the Analytics tool, for records with 773$0)
change the first indicator of the 773 from blank to '0'.

== Background ==
An analytic record for an item is a more detailed, monographic biblio for an
item attached to a serial record .  This is often used for special issues of a
journal that are released as books on their own (assigned an ISBN, as well as an
ISSN/volume/issue).  It is important for researchers to be able to search for
these items both as issues of the serial, and as monographs.  It is equally
important for the library to not have duplicate item records for the item in
question to have to keep synchronized.

== Establishing relationships ==
Analytical records are connected to items belonging to parent or host
bibliographic records. This can be accomplished by:
* From an analytical bibliographic record linking to an host item by providing
  the item barcode as input
* From a host item by using option "analyze", this creates a new empty
  bibliographic record with field 773 (MARC21) populated
* Running a new CLI script that establishes a relationship between the
  analytical record and the host item identified by the barcode in the
  analytical record's 773$o (MARC21)

== Connecting Records ==
The relationships are maintained in the MARC records, we have not used database
tables at all.

== MARC Representation ==
In MARC21/NORMARC we have used:
* 773$9 to store the Koha item number of the host item
* 773$0 to store the Koha biblio number of the host bibliographic record

The above fields are used to display the relationships in various screens in the
OPAC and the staff interface. Additionally, when populating field 773 with host
item's details, we have used following MARC 21 mapping:
* 'a' <= 100/110/111 $a (author main)
* 'b' <= 250$a (edition)
* 'd' <= 260$a, 260$b, 260$c (place, publisher, year)
* 'o' <= barcode
* 't' <= 245$a (title)
* 'w' <= (003)001 --> if no 001 is available, we can populate biblionumber
* 'x' <= 022$a (issn)
* 'z' <= 020$a (isbn)

In UNIMARC, this code uses:
* 461$9 to store the Koha item number of the host item
* 461$0 to store the Koha biblio number of the host bibliographic record

When populating field 461 in UNIMARC, the following mapping is used:
* 't' <= 200$a (title)

== Treatment of Holds ==
A key requirement was to allow holds to be placed on host items from the
analytical record. We have accomplished this by allowing holds on specific
copies only. Biblio level holds are not allowed. This ensures that holds are
placed on specific items that are relevant to the analytical record.

== Deleting host items with linked analytical records ==
As we have not used database tables to maintain relationships, we had to use
search to find out if any linked analytical records are present. If 1 or more
analytical are present, we do not allow deletion of items. This is similar to
what we see when we try to delete authority records.

== Importing analytical records ==
Analytical records can be imported using bulkmarcimport or the GUI tools. The
new CLI script can be executed after the import to establish relationships with
host items. The script will establish relationships using the host item's
barcode, the barcode must be present in 773$o of the analytical record.

== What if there are two or more copies of the host item? ==
The current design will require that there be two host (773) fields, one for
each copy.

== What if there is no barcode available for the host item? ==
It is still possible to establish a relationship, by populating 773$9 with the
host's item number. However the CLI script uses barcode in 773$o to establish
relationships so it won't work where barcodes are unavailable. Also from an
analytical record, it is possible to establish a relationship to a host item by
providing the barcode as input, this option will not be available as well.

Commits that added the following features were squashed by Chris Cormack (this
is not a list of every commit):
* Display links to host records from biblio detail screens
* Support for UNIMARC, respecting the system preference 'marcflavor'
* Support holds from the OPAC
* Ability to link to items belong to host records from a analytical record
* Display items belonging to host records in the moredetail page
* Ability to edit items belonging to host records, also ability to delink from
  them
* Move get host items code into a C4 routine, also calling the new routine in
  related perl scripts
* Move host field population to a C4 routine, all changes in pl files to call
  new routine
* Allow only specific copy holds for analytical records plus changes to use new
  C4 routines
* Support for holds on items linked via host records
* Storing bibnumber and itemnumber in subfields 0 and 9, plus other mapping
  changes
* New command line script that establishes relationships between analytical
  records and host items and bibs. The script looks for host field (MARC21 773)
  in records, and based on barcode in subfield 'o' populates host bibnumber in
  subfield '0' and host itemnumber in subfield '9'. The script can be run after
  an import of analytical records, it can also be run in the crontab to maintain
  the relationships
* Ability to create analytical records from items, to view linked analytics, and
  prevent deletion of items that have linked analytics
* New template for catalogue/detail.pl (NOTE: not a new template file, just a
  new way of displaying analytics), template displays linked analytics and
  allows creation of analytical records
* New zebra index for item number in host fields. This index will be used to
  display links to analytical records from host records
* Display title of host record instead of the phrase host record
* Using detail.tmpl for analytics tab instead of a new template file
* Improved qualification info prepration in Prephostmarcfield
* Check for linked analytics before deleting item
* Display link to host record and more meaningful anchor text for edit item link
* Analytical record: Unimarc index in record.abs and help in
  create_analytical_rel.pl
* Adding a sys pref that controls display of options to create analytical
  relationships
* Add host entry in XSLT stylesheet in staff item detail
* Added host record support to OPAC detail XSLT
* Adding 773$0 and 773$9 to all frameworks
* Adding 773 subfields 0 and 9 to default marc framework via updatedatabase.pl
* Display create analytics and used in links in catalog detail
* Fixed problem where analytical records not showing in OPAC search results
  because GetMarcBiblio now needs a flag to add item records
* Fixed problem where analytics count was set to 1 for all records, not just
  those with analytics
* Fixed catalogue detail page not to show analytics counts if count is 0

Conflicts:
	installer/data/mysql/updatedatabase.pl
	koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
	kohaversion.pl

Co-author: Savitra Sirohi <savitra.sirohi@osslabs.biz>
Co-author: Zeno Tajoli <tajoli@cilea.it>

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Jared Camins-Esakov 2011-10-07 14:45:53 +13:00 committed by Chris Cormack
parent 71defcbc6c
commit f09e2ca27e
31 changed files with 905 additions and 35 deletions

View File

@ -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 {

View File

@ -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" || $marcflavour eq "NORMARC" ) {
$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,86 @@ 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" || $marcflavour eq "NORMARC" ) {
#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', '',
'0' => $hostbiblionumber,
'9' => $hostitemnumber,
'a' => $mainentry,
'b' => $ed,
'd' => $qualinfo,
'o' => $barcode,
't' => $title,
'w' => $recctrlno,
'x' => $issn,
'z' => $isbn
);
} elsif ($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 );

View File

@ -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' ||
C4::Context->preference('marcflavour') eq 'NORMARC'){
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;
}
}
}
} elsif ( 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,53 @@ 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' || $marcflavor eq 'NORMARC') {
$tag='773';
$biblio_s='0';
$item_s='9';
} elsif ($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 +2185,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 +2430,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;

View File

@ -385,6 +385,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});
}

View File

@ -1559,6 +1559,33 @@ 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
my $analyticsfield = '773';
if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
$analyticsfield = '773';
} elsif ($marcflavor eq 'UNIMARC') {
$analyticsfield = '461';
}
foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
my $hostbiblionumber = $hostfield->subfield("0");
my $linkeditemnumber = $hostfield->subfield("9");
if(!$hostbiblionumber eq undef){
my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1);
my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
if(!$hostbiblio eq undef){
my @hostitems = $hostbiblio->field($itemfield);
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;

View File

@ -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},

View File

@ -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'};

View File

@ -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
);
}

View File

@ -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,20 @@ if ($op eq "additem") {
$itemnumber="";
}
$nextop="additem";
} elsif ($op eq "delinkitem"){
my $analyticfield = '773';
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
$analyticfield = '773';
} elsif ($marcflavour eq 'UNIMARC') {
$analyticfield = '461';
}
foreach my $field ($record->field($analyticfield)){
if ($field->subfield('9') eq $hostitemnumber){
$record->delete_field($field);
last;
}
}
my $modbibresult = ModBiblio($record, $biblionumber,'');
}
#
@ -512,6 +528,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 +538,29 @@ my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebran
C4::Biblio::EmbedItemsInMarcBiblio($temp, $biblionumber);
my @fields = $temp->fields();
my @hostitemnumbers;
my $analyticfield = '773';
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC') {
$analyticfield = '773';
} elsif ($marcflavour eq 'UNIMARC') {
$analyticfield = '461';
}
foreach my $hostfield ($temp->field($analyticfield)){
if ($hostfield->subfield('0')){
my $hostrecord = GetMarcBiblio($hostfield->subfield('0'), 1);
my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostfield->subfield('0')) );
foreach my $hostitem ($hostrecord->field($itemfield)){
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 +591,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 +624,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)) {

98
cataloguing/linkitem.pl Executable file
View File

@ -0,0 +1,98 @@
#!/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' || $marcflavour eq 'NORMARC') {
$template->param(bibliotitle => $biblio->subfield('245','a'));
} elsif ($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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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),

View File

@ -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),

View File

@ -324,3 +324,5 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
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 ('OpacKohaUrl','1',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL);
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');

View File

@ -4444,6 +4444,29 @@ 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)) {
if (C4::Context->preference("marcflavour") eq 'MARC21' ||
C4::Context->preference("marcflavour") eq 'NORMARC'){
$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);
} elsif (C4::Context->preference("marcflavour") eq 'UNIMARC'){
$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 ('461', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL)");
print "Upgrade to $DBversion done (Add 461 subfield 9 to default framework)\n";
SetVersion ($DBversion);
}
}
$DBversion = "3.05.00.012";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {

View File

@ -23,6 +23,7 @@
[% IF ( CAN_user_reserveforothers ) %]
[% IF ( holdsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% IF ( object ) %][% object %][% ELSE %][% biblionumber %][% END %]">Holds</a></li>
[% END %]
[% IF ( EasyAnalyticalRecords ) %][% IF ( analyze ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% IF ( object ) %][% object %]&analyze=1[% ELSE %][% biblionumber %]&analyze=1[% END %]">Analytics</a></li>[% END %]
[% IF ( subscriptionsnumber ) %]<li><a href="/cgi-bin/koha/serials/serials-home.pl?searched=1&amp;biblionumber=[% biblionumber %]">Subscription(s)</a></li>[% END %]
</ul>

View File

@ -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 %]&amp;frameworkcode=&amp;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 %]&amp;frameworkcode=&amp;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 %]

View File

@ -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,

View File

@ -248,6 +248,9 @@ function verify_images() {
[% IF ( itemdata_copynumber ) %]<th>Copy No.</th>[% END %]
[% IF ( itemdata_itemnotes ) %]<th>Public notes</th>[% END %]
[% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine Label</th>[% END %]
[% IF ( hostrecords ) %]<th>Host Records</th>[% END %]
[% IF ( analyze ) %]<th>Used in</th>[% END %]
[% IF ( analyze ) %]<th></th>[% END %]
</tr>
[% FOREACH itemloo IN itemloop %]
<tr>
@ -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 %]
</td>[% END %]
[% IF ( itemdata_uri ) %]
<td class="uri"><a href="[% itemloo.uri %]">[% itemloo.uri %]</a></td>
@ -373,6 +376,17 @@ function verify_images() {
[% IF ( SpineLabelShowPrintOnBibDetails ) %]
<td><a href="/cgi-bin/koha/labels/spinelabel-print.pl?barcode=[% itemloo.barcode %]" >Print Label</a></td>
[% END %]
[% IF ( hostrecords ) %]
<td>[% IF ( itemloo.hostbiblionumber) %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itemloo.hostbiblionumber %]" >[% itemloo.hosttitle %]</a>[% END %]</td>
[% END %]
[% IF ( analyze ) %]<td>
[% IF ( itemloo.countanalytics ) %]
<a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&q=[% itemloo.itemnumber %]">[% itemloo.countanalytics %] analytics</a>
[% END %]</td>
[% END %]
[% IF ( analyze ) %]
<td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% itemloo.biblionumber %]&hostitemnumber=[% itemloo.itemnumber %]">Create Analytics</a></td>
[% END %]
</tr>
[% END %]

View File

@ -190,6 +190,7 @@ function set_to_today(id, force) {
[% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div>[% END %]
[% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div>[% END %]
[% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: The items do not belong to your branch.</div>[% END %]
[% IF ( linked_analytics ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]&analyze=1">analytics.</a>.</div>[% END %]
<div id="cataloguing_additem_itemlist">
[% IF ( item_loop ) %]
@ -205,8 +206,10 @@ function set_to_today(id, force) {
</tr>
[% FOREACH item_loo IN item_loop %]
<tr id="row[% item_loo.itemnumber %]">
[% IF ( item_loo.nomod ) %] <td colspan="2">&nbsp;</td>[% ELSE %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a></td>
<td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]" onclick="confirm_deletion([% biblionumber %],[% item_loo.itemnumber %]); return false;">Delete</a></td>[% END %]
[% IF ( item_loo.nomod ) %] <td colspan="2">&nbsp;</td>[% ELSE %][% IF ( item_loo.hostitemflag ) %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% item_loo.hostbiblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit in Host</a></td>
<td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblionumber %]&amp;hostitemnumber=[% item_loo.itemnumber %]">Delink</a></td>
[% ELSE %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a></td>
<td>[% IF ( item_loo.countanalytics ) %]<a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&q=% item_loo.itemnumber %]">view analytics</a>[% ELSE %]<a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]" onclick="confirm_deletion([% biblionumber %],[% item_loo.itemnumber %]); return false;">Delete</a>[% END %]</td>[% END %][% END %]
[% FOREACH item_valu IN item_loo.item_value %]
<td>[% item_valu.field |html %]</td>
[% END %]

View File

@ -0,0 +1,57 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Link to host item</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body>
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloging/addbooks.pl">Cataloging</a> &rsaquo; Link a host item to <i>[% bibliotitle |html %]</i></div>
<div id="doc3" class="yui-t2">
[% IF ( error ) %]
<div class="dialog alert">
[% 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 %]
</div>
<form action="/cgi-bin/koha/catalogue/MARCdetail.pl" method="post">
<input type="submit" value="OK" />
<input type="hidden" name="biblionumber" value="[% biblionumber %]" />
</form>
[% ELSE %]
[% IF ( success ) %]
<div class="dialog">The item has successfully been linked to <i>[% bibliotitle |html %]</i>.</div>
<form action="/cgi-bin/koha/catalogue/MARCdetail.pl" method="post">
<input type="submit" value="OK" />
<input type="hidden" name="biblionumber" value="[% biblionumber %]" />
</form>
[% ELSE %]
[% IF ( missingparameter ) %]
<form method="post" action="/cgi-bin/koha/cataloguing/linkitem.pl">
[% IF ( missingbiblionumber ) %]
<fieldset id="biblionumber_fieldset">
<label for="biblionumber_fieldset">Select the biblionumber to link the item to</label>
<div class="hint">Enter biblionumber:</div>
<input type="text" name="biblionumber" id="biblionumber" class="focus" size="14" />
</fieldset>
[% ELSE %]
<input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber %]" />
[% END %]
[% IF ( missingbarcode ) %]
<fieldset id="barcode_fieldset">
<label for="barcode_fieldset">Select the host item to link[% IF ( bibliotitle ) %] to <i>[% bibliotitle |html %]</i>[% END %]</label>
<div class="hint">Enter item barcode:</div>
<input type="text" name="barcode" id="barcode" class="barcode focus" size="14" />
</fieldset>
[% ELSE %]
<input type="hidden" name="barcode" id="barcode" value="[% barcode %]" />
[% END %]
<input type="submit" value="Select" />
</form>
[% END %]
[% END %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -564,6 +564,11 @@
</a>
<xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
</xsl:when>
<xsl:when test="marc:subfield[@code='0']">
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="marc:subfield[@code='0']"/></xsl:attribute>
<xsl:value-of select="$f773"/>
</a>
</xsl:when>
<xsl:otherwise>
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
<xsl:value-of select="$f773"/>

View File

@ -678,6 +678,11 @@
</a>
<xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
</xsl:when>
<xsl:when test="marc:subfield[@code='0']">
<a><xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:subfield[@code='0']"/></xsl:attribute>
<xsl:value-of select="$f773"/>
</a>
</xsl:when>
<xsl:otherwise>
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Title:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
<xsl:value-of select="$f773"/>

View File

@ -0,0 +1,152 @@
#!/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
my $analyticfield = '773';
foreach my $hostfield ( $bib->field($analyticfield) ) {
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_
}

View File

@ -86,6 +86,27 @@ 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");
my $analyticfield = '773';
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
$analyticfield = '773';
} elsif ($marcflavour eq 'UNIMARC') {
$analyticfield = '461';
}
foreach my $hostfield ( $record->field($analyticfield)) {
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 +238,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 +253,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},

View File

@ -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++;
}

View File

@ -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],

View File

@ -292,7 +292,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;
}
@ -325,6 +331,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} =
@ -348,6 +357,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};