&PrepHostMarcField
&CountItemsIssued
+ &CountBiblioInOrders
+ &GetSubscriptionsId
+ &GetHolds
);
# To modify something
}
};
+use Memoize;
+memoize('GetMarcStructure');
+
=head1 NAME
C4::Biblio - cataloging management functions
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; }
return unless $record;
+ C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber);
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems);
- # $record = MARC::Record::new_from_usmarc( $marc) if $marc;
return $record;
} else {
return undef;
=cut
+my $_auth_val;
+
sub GetAuthorisedValueDesc {
my ( $tag, $subfield, $value, $framework, $tagslib, $category, $opac ) = @_;
my $dbh = C4::Context->dbh;
}
if ( $category ne "" ) {
- my $sth = $dbh->prepare( "SELECT lib, lib_opac FROM authorised_values WHERE category = ? AND authorised_value = ?" );
- $sth->execute( $category, $value );
- my $data = $sth->fetchrow_hashref;
+
+ my $data;
+
+ if ( $data = $_auth_val->{$category}->{$value} ) {
+warn "XXX auth_val hit: $category $value\n";
+ } else {
+ my $sth = $dbh->prepare( "SELECT lib, lib_opac FROM authorised_values WHERE category = ? AND authorised_value = ?" );
+ $sth->execute( $category, $value );
+ $_auth_val->{$category}->{$value} = $data = $sth->fetchrow_hashref;
+ }
return ( $opac && $data->{'lib_opac'} ) ? $data->{'lib_opac'} : $data->{'lib'};
} else {
return $value; # if nothing is found return the original value
=cut
+our $_frameworkcode;
+
sub GetFrameworkCode {
my ($biblionumber) = @_;
+
+ my $frameworkcode;
+ if ( $frameworkcode = $_frameworkcode->{$biblionumber} ) {
+warn "# _frameworkcode hit $biblionumber\n";
+ return $frameworkcode;
+ }
+
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT frameworkcode FROM biblio WHERE biblionumber=?");
$sth->execute($biblionumber);
my ($frameworkcode) = $sth->fetchrow;
- return $frameworkcode;
+ return $_frameworkcode->{$biblionumber} = $frameworkcode;
}
=head2 TransformKohaToMarc
my $item_marc = C4::Items::GetMarcItem($biblionumber, $itemnumber);
push @item_fields, $item_marc->field($itemtag);
}
- $marc->insert_fields_ordered(@item_fields);
+ $marc->append_fields(@item_fields);
}
=head1 INTERNAL FUNCTIONS
return $authorised_values;
}
+=head2 CountBiblioInOrders
+
+=over 4
+$count = &CountBiblioInOrders( $biblionumber);
+
+=back
+
+This function return count of biblios in orders with $biblionumber
+
+=cut
+
+sub CountBiblioInOrders {
+ my ($biblionumber) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = "SELECT count(*)
+ FROM aqorders
+ WHERE biblionumber=? AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($biblionumber);
+ my $count = $sth->fetchrow;
+ return ($count);
+}
+
+=head2 GetSubscriptionsId
+
+=over 4
+$subscriptions = &GetSubscriptionsId($biblionumber);
+
+=back
+
+This function return an array of subscriptionid with $biblionumber
+
+=cut
+
+sub GetSubscriptionsId {
+ my ($biblionumber) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = "SELECT subscriptionid
+ FROM subscription
+ WHERE biblionumber=?";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($biblionumber);
+ my @subscriptions = $sth->fetchrow_array;
+ return (@subscriptions);
+}
+
+=head2 GetHolds
+
+=over 4
+$holds = &GetHolds($biblionumber);
+
+=back
+
+This function return the count of holds with $biblionumber
+
+=cut
+
+sub GetHolds {
+ my ($biblionumber) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = "SELECT count(*)
+ FROM reserves
+ WHERE biblionumber=?";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($biblionumber);
+ my $holds = $sth->fetchrow;
+ return ($holds);
+}
+
+
1;
__END__