Bugzilla – Attachment 4256 Details for
Bug 5680
When deleting an order, delete attached items, and if applicable biblio
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
this one is ok
0001-PATCH-Bug-5680-Order-cancelling-improvement-delete-a.patch (text/plain), 6.44 KB, created by
Christophe Croullebois
on 2011-05-25 07:51:23 UTC
(
hide
)
Description:
this one is ok
Filename:
MIME Type:
Creator:
Christophe Croullebois
Created:
2011-05-25 07:51:23 UTC
Size:
6.44 KB
patch
obsolete
>From dc5d11c3694eb10a128983b79c21816002038b50 Mon Sep 17 00:00:00 2001 >From: Christophe Croullebois <christophe.croullebois@biblibre.com> >Date: Tue, 24 May 2011 16:39:42 +0200 >Subject: [PATCH 1/1] [PATCH] Bug 5680: Order cancelling improvement : delete attached items & biblio if avalaible > >- all items attached to the order are deleted >- if there is no more items, and if the biblio is not in other orders then the biblio is proposed to deletion >Now whe have 2 links : delete order and delete order and biblio, the second one appears only if the deletion is possible. >--- > C4/Acquisition.pm | 2 + > C4/Biblio.pm | 25 +++++++++++++++++++- > acqui/addorder.pl | 4 +++ > acqui/basket.pl | 10 +++++-- > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 12 ++++++++- > 5 files changed, 48 insertions(+), 5 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index e431bd2..2e5f4bc 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1223,6 +1223,8 @@ sub DelOrder { > my $sth = $dbh->prepare($query); > $sth->execute( $bibnum, $ordernumber ); > $sth->finish; >+ my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); >+ C4::Items::DelItem( $dbh, $bibnum, $_ ) for @itemnumbers; > } > > =head2 FUNCTIONS ABOUT PARCELS >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index c9590c2..5b918e1 100755 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -89,8 +89,8 @@ BEGIN { > &GetMarcFromKohaField > &GetFrameworkCode > &TransformKohaToMarc >- > &CountItemsIssued >+ &CountBiblioInOrders > ); > > # To modify something >@@ -3630,6 +3630,29 @@ 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); >+} >+ > 1; > > __END__ >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index 44623ec..b8d0e21 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -190,6 +190,7 @@ my $user = $input->remote_user; > # create if $quantity>=0 and $existing='no' > # modify if $quantity>=0 and $existing='yes' > # delete if $quantity has been set to 0 by the librarian >+# delete biblio if delbiblio has been set to 1 by the librarian > my $bibitemnum; > if ( $orderinfo->{quantity} ne '0' ) { > #TODO:check to see if biblio exists >@@ -270,6 +271,9 @@ if ( $orderinfo->{quantity} ne '0' ) { > else { # qty=0, delete the line > my $biblionumber = $input->param('biblionumber'); > DelOrder( $biblionumber, $$orderinfo{ordernumber} ); >+ if ($orderinfo->{delbiblio} == 1){ >+ DelBiblio($biblionumber) if (C4::Items::GetItemsCount($biblionumber) == 0 && CountBiblioInOrders($biblionumber) <= 1); >+ } > } > my $basketno=$$orderinfo{basketno}; > my $booksellerid=$$orderinfo{booksellerid}; >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 0261e86..99956cf 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -28,12 +28,12 @@ use C4::Output; > use CGI; > use C4::Acquisition; > use C4::Budgets; >- > use C4::Bookseller qw( GetBookSellerFromId); > use C4::Dates qw/format_date/; > use C4::Debug; >- >+use C4::Biblio; > use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket >+use C4::Items; > =head1 NAME > > basket.pl >@@ -253,7 +253,11 @@ if ( $op eq 'delete_confirm' ) { > # FIXME: what about the "actual cost" field? > $qty_total += $qty; > my %line = %{ $order }; >- >+ my $biblionumber = $order->{'biblionumber'}; >+ my $countbiblio = CountBiblioInOrders($biblionumber); >+ my $ordernumber = $order->{'ordernumber'}; >+ # if the biblio is not in other orders and if there is no items elsewhere we can show the link "Delete order and Biblio" see bug 5680 >+ $line{can_del_bib} = 1 if $countbiblio <= 1 && GetItemsCount($biblionumber) == scalar GetItemnumbersFromOrder( $ordernumber ); > $line{order_received} = ( $qty == $order->{'quantityreceived'} ); > $line{basketno} = $basketno; > $line{budget_name} = $budget->{budget_name}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index d34e3d5..c1e574a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -39,6 +39,13 @@ > window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber; > } > } >+ >+ function confirm_delete_biblio(ordernumber, biblionumber) { >+ var is_confirmed = confirm(_('Are you sure you want to delete this order with his biblio ?')); >+ if (is_confirmed) { >+ window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber+"&delbiblio=1"; >+ } >+ } > > //]]> > </script> >@@ -278,9 +285,12 @@ > <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber %]&booksellerid=[% booksellerid %]&basketno=[% basketno %]">Modify</a> > </td> > <td> >- <a href="javascript:confirm_delete_item([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete</a> >+ <a href="javascript:confirm_delete_item([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order</a><br> >+ [% IF ( books_loo.can_del_bib ) %] >+ <a href="javascript:confirm_delete_biblio([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order and Biblio</a> > </td> > [% END %] >+ [% END %] > [% END %] > </tr> > [% END %] >-- >1.7.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5680
:
3047
|
4255
|
4256
|
4480
|
5813
|
5814
|
5816
|
5904
|
5914
|
5915
|
5916
|
5964
|
5965