X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FBiblio.pm;h=a112c84757c1a698909862738ff9013047cc3673;hb=5c2def51587c4b2636b5f066306b8bd5dc0e7a7a;hp=752ebe9ec5da4af2c2e5772833a306dbd7bcfe91;hpb=a118102d4e2d7cf6bc1157a560c52fd6deb6f7a7;p=koha_fer diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 752ebe9ec5..a112c84757 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -94,6 +94,9 @@ BEGIN { &PrepHostMarcField &CountItemsIssued + &CountBiblioInOrders + &GetSubscriptionsId + &GetHolds ); # To modify something @@ -386,7 +389,7 @@ sub ModBiblioframework { =head2 DelBiblio - my $error = &DelBiblio($dbh,$biblionumber); + my $error = &DelBiblio($biblionumber); Exported function (core API) for deleting a biblio in koha. Deletes biblio record from Zebra and Koha tables (biblio,biblioitems,items) @@ -1072,9 +1075,9 @@ sub GetMarcBiblio { 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; @@ -2855,7 +2858,7 @@ sub EmbedItemsInMarcBiblio { 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 @@ -3519,9 +3522,12 @@ sub _koha_delete_biblio { $bkup_sth->finish; # delete the biblio - my $del_sth = $dbh->prepare("DELETE FROM biblio WHERE biblionumber=?"); - $del_sth->execute($biblionumber); - $del_sth->finish; + my $sth2 = $dbh->prepare("DELETE FROM biblio WHERE biblionumber=?"); + $sth2->execute($biblionumber); + # update the timestamp (Bugzilla 7146) + $sth2= $dbh->prepare("UPDATE deletedbiblio SET timestamp=NOW() WHERE biblionumber=?"); + $sth2->execute($biblionumber); + $sth2->finish; } $sth->finish; return undef; @@ -3565,9 +3571,12 @@ sub _koha_delete_biblioitems { $bkup_sth->finish; # delete the biblioitem - my $del_sth = $dbh->prepare("DELETE FROM biblioitems WHERE biblioitemnumber=?"); - $del_sth->execute($biblioitemnumber); - $del_sth->finish; + my $sth2 = $dbh->prepare("DELETE FROM biblioitems WHERE biblioitemnumber=?"); + $sth2->execute($biblioitemnumber); + # update the timestamp (Bugzilla 7146) + $sth2= $dbh->prepare("UPDATE deletedbiblioitems SET timestamp=NOW() WHERE biblioitemnumber=?"); + $sth2->execute($biblioitemnumber); + $sth2->finish; } $sth->finish; return undef; @@ -3806,6 +3815,76 @@ sub get_biblio_authorised_values { 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__