=head3 items
-my @items = $biblio->items();
my $items = $biblio->items();
-Returns the related Koha::Items object for this biblio in scalar context,
-or list of Koha::Item objects in list context.
+Returns the related Koha::Items object for this biblio
=cut
my $items_rs = $self->_result->items;
- return
- wantarray
- ? Koha::Items->_new_from_dbic($items_rs)->as_list
- : Koha::Items->_new_from_dbic($items_rs);
+ return Koha::Items->_new_from_dbic( $items_rs );
}
=head3 itemtype
my $moveresult = MoveItemFromBiblio( $itemnumber, $frombiblionumber, $biblionumber );
if ($moveresult) {
- $template->param( success => 1 );
+ $template->param(
+ success => 1,
+ from_biblio => scalar Koha::Biblios->find($frombiblionumber),
+ );
}
else {
$template->param(
+[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Cataloging › Attach an item to [% bibliotitle | html %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% ELSE %]
[% IF ( success ) %]
+ [% IF from_biblio.items.count == 0 %]
+ <div class="dialog alert">
+ The record <em>[% from_biblio.title | html %]</em> has [% from_biblio.items.count | html %] attached items.
+ <p>
+ <button id="delete-biblio-btn" data-biblionumber="[% from_biblio.id | html %]"><i id="del-bib-spn" class="fa fa-spinner fa-pulse fa-fw" style="display:none"></i><i class="fa fa-fw fa-trash"></i> Delete record
+ </button>
+ <span id="del-bib-success" style="display:none">Record deleted</span>
+ <span id="del-bib-failure" style="display:none">Attempt to delete record failed.</span>
+ </p>
+ </div>
+ <br/>
+ [% END %]
+
<div class="dialog message">The item has successfully been attached to [% INCLUDE 'biblio-default-view.inc' %]<i>[% bibliotitle | html %]</i></a>.
<p>
[% INCLUDE actions %]
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
</form>
</p>
+
</div>
[% ELSE %]
[% IF ( missingparameter ) %]
</div>
</div>
+[% MACRO jsinclude BLOCK %]
+ <script type="text/javascript">
+ $("#delete-biblio-btn").on("click", function(){
+ if ( confirm(_("Are you sure you want to delete this record?")) ) {
+ let btn = $(this);
+ $("#del-bib-spn").show();
+ let biblionumber = $(this).data('biblionumber');
+ $.ajax({
+ url: '/api/v1/biblios/' + biblionumber,
+ type: 'DELETE',
+ success: function(result) {
+ btn.hide();
+ $('#del-bib-success').show();
+ },
+ error: function(result) {
+ btn.hide();
+ $('#del-bib-failure').show();
+ }
+ });
+ }
+ });
+ </script>
+[% END %]
+
[% INCLUDE 'intranet-bottom.inc' %]