&GetMarcBiblio
&GetMarcAuthors
&GetMarcSeries
+ GetMarcUrls
&GetUsedMarcStructure
&GetItemsInfo
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
my $error; # for error handling
+
+ # First make sure this biblio has no items attached
+ my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber=?");
+ $sth->execute($biblionumber);
+ if (my $itemnumber = $sth->fetchrow){
+ # Fix this to use a status the template can understand
+ $error .= "This Biblio has items attached, please delete them first before deleting this biblio ";
+ }
- # First make sure there are no items with issues are still attached
- my $sth =
- $dbh->prepare(
- "SELECT itemnumber FROM items WHERE biblionumber=?");
- $sth->execute($biblionumber);
- while ( my $itemnumber = $sth->fetchrow ) {
- my $issues = GetItemIssues($itemnumber);
- foreach my $issue (@$issues) {
- if ( ( $issue->{date_due} )
- && ( $issue->{date_due} ne "Available" ) )
- {
-
-#FIXME: we need a status system in Biblio like in Circ to return standard codes and messages
-# instead of hard-coded strings
- $error .=
-"Item is checked out to a patron -- you must return it before deleting the Biblio";
- }
- }
- }
return $error if $error;
# Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio
# delete this biblioitem
$error = &_koha_delete_biblioitems( $dbh, $biblioitemnumber );
return $error if $error;
-
- # delete items
- my $items_sth =
- $dbh->prepare(
- "SELECT itemnumber FROM items WHERE biblioitemnumber=?");
- $items_sth->execute($biblioitemnumber);
- while ( my $itemnumber = $items_sth->fetchrow ) {
- $error = &_koha_delete_item( $dbh, $itemnumber );
- return $error if $error;
- }
}
&logaction(C4::Context->userenv->{'number'},"CATALOGUING","DELETE",$biblionumber,"")
if C4::Context->preference("CataloguingLog");
sub DelItem {
my ( $biblionumber, $itemnumber ) = @_;
my $dbh = C4::Context->dbh;
+
+ # check the item has no current issues
+
+
&_koha_delete_item( $dbh, $itemnumber );
# get the MARC record
my $record = GetMarcBiblio($biblionumber);
my $dbh = C4::Context->dbh;
my $query = "
- SELECT * , biblioitems.notes AS bnotes, biblio.notes
+ SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes
FROM biblio
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
#'
sub GetBiblioItemData {
- my ($bibitem) = @_;
+ my ($biblioitemnumber) = @_;
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
-"Select *,biblioitems.notes as bnotes from biblioitems, biblio,itemtypes where biblio.biblionumber = biblioitems.biblionumber and biblioitemnumber = ? and biblioitems.itemtype = itemtypes.itemtype"
+ "SELECT *,biblioitems.notes AS bnotes
+ FROM biblioitems,biblio,itemtypes
+ WHERE biblio.biblionumber = biblioitems.biblionumber
+ AND biblioitemnumber = ? "
);
my $data;
-
- $sth->execute($bibitem);
-
+ $sth->execute($biblioitemnumber);
$data = $sth->fetchrow_hashref;
-
$sth->finish;
return ($data);
} # sub &GetBiblioItemData
return \@marcauthors;
}
+=head2 GetMarcUrls
+
+=over 4
+
+$marcurls = GetMarcUrls($record,$marcflavour);
+Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
+Assumes web resources (not uncommon in MARC21 to omit resource type ind)
+
+=back
+
+=cut
+
+sub GetMarcUrls {
+ my ($record, $marcflavour) = @_;
+ my @marcurls;
+ my $marcurl;
+ for my $field ($record->field('856')) {
+ my $url = $field->subfield('u');
+ my @notes;
+ for my $note ( $field->subfield('z')) {
+ push @notes , {note => $note};
+ }
+ $marcurl = { MARCURL => $url,
+ notes => \@notes,
+ };
+ if($marcflavour eq 'MARC21') {
+ my $s3 = $field->subfield('3');
+ my $link = $field->subfield('y');
+ $marcurl->{'linktext'} = $link || $s3 || $url ;;
+ $marcurl->{'part'} = $s3 if($link);
+ $marcurl->{'toc'} = 1 if($s3 =~ /^[Tt]able/) ;
+ } else {
+ $marcurl->{'linktext'} = $url;
+ }
+ push @marcurls, $marcurl;
+ }
+ return \@marcurls;
+} #end GetMarcUrls
+
=head2 GetMarcSeries
=over 4
-$marcseriessarray = GetMarcSeries($record,$marcflavour);
+$marcseriesarray = GetMarcSeries($record,$marcflavour);
Get all series from the MARC record and returns them in an array.
The series are stored in differents places depending on MARC flavour
$sth->finish;
$sth = $dbh->prepare(
"INSERT INTO biblio
- SET biblionumber = ?, title = ?, author = ?, copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, unititle = ?, frameworkcode = ? "
+ SET datecreated=NOW(), biblionumber = ?, title = ?, author = ?, copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, unititle = ?, frameworkcode = ? "
);
$sth->execute(
$biblionumber, $biblio->{'title'},