Bugzilla – Attachment 5813 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]
The lat one
0001-Bug-5680-Order-cancelling-improvement-delete-attache.patch (text/plain), 12.61 KB, created by
Christophe Croullebois
on 2011-10-09 18:54:49 UTC
(
hide
)
Description:
The lat one
Filename:
MIME Type:
Creator:
Christophe Croullebois
Created:
2011-10-09 18:54:49 UTC
Size:
12.61 KB
patch
obsolete
>From fad282dbfc80dd09c87d45cf6b58c127b68d380e 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] 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 and no subscriptions and no holds then the biblio is proposed to deletion >Now whe have 2 links : "delete order" and "delete order and catalog record", the second one appears only if the deletion is possible. >Note that if an hold is related to the item or if the item is unique for the biblio the link "Delete order" is canceled due to hold remaining. >On mouse over explanations are shown with count. >More lines of warnings with count are shown depending of the case. >--- > C4/Acquisition.pm | 5 ++ > C4/Biblio.pm | 74 +++++++++++++++++++- > C4/Items.pm | 29 +++++++- > acqui/addorder.pl | 4 + > acqui/basket.pl | 43 +++++++++--- > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 33 ++++++++- > 6 files changed, 171 insertions(+), 17 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index f682256..4f0daf7 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1221,6 +1221,11 @@ sub DelOrder { > my $sth = $dbh->prepare($query); > $sth->execute( $bibnum, $ordernumber ); > $sth->finish; >+ my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); >+ foreach my $itemnumber (@itemnumbers){ >+ C4::Items::DelItem( $dbh, $bibnum, $itemnumber ); >+ } >+ > } > > =head2 FUNCTIONS ABOUT PARCELS >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 915139e..7c8e027 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -90,8 +90,10 @@ BEGIN { > &GetMarcFromKohaField > &GetFrameworkCode > &TransformKohaToMarc >- > &CountItemsIssued >+ &CountBiblioInOrders >+ &GetSubscriptionsId >+ &GetHolds > ); > > # To modify something >@@ -3681,6 +3683,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__ >diff --git a/C4/Items.pm b/C4/Items.pm >index 2e85130..9469d44 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -68,16 +68,16 @@ BEGIN { > GetItemInfosOf > GetItemsByBiblioitemnumber > GetItemsInfo >- GetItemsLocationInfo >+ GetItemsLocationInfo > get_itemnumbers_of > GetItemnumberFromBarcode > GetBarcodeFromItemnumber >- GetHiddenItemnumbers >- >+ GetHiddenItemnumbers > DelItemCheck > MoveItemFromBiblio > GetLatestAcquisitions > CartToShelf >+ GetItemHolds > ); > } > >@@ -2339,4 +2339,27 @@ sub _parse_unlinked_item_subfields_from_xml { > return $unlinked_subfields; > } > >+=head2 GetItemHolds >+ >+=over 4 >+$holds = &GetItemHolds($biblionumber, $itemnumber); >+ >+=back >+ >+This function return the count of holds with $biblionumber and $itemnumber >+ >+=cut >+ >+sub GetItemHolds { >+ my ($biblionumber, $itemnumber) = @_; >+ my $holds; >+ my $dbh = C4::Context->dbh; >+ my $query = "SELECT count(*) >+ FROM reserves >+ WHERE biblionumber=? AND itemnumber=?"; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($biblionumber, $itemnumber); >+ $holds = $sth->fetchrow; >+ return $holds; >+} > 1; >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index e321d2c..d7f7e96 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 >@@ -271,6 +272,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); >+ } > } > my $basketno=$$orderinfo{basketno}; > my $booksellerid=$$orderinfo{booksellerid}; >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 9377a43..b836280 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 >@@ -259,13 +259,38 @@ if ( $op eq 'delete_confirm' ) { > # FIXME: what about the "actual cost" field? > $qty_total += $qty; > my %line = %{ $order }; >- >- $line{order_received} = ( $qty == $order->{'quantityreceived'} ); >- $line{basketno} = $basketno; >- $line{budget_name} = $budget->{budget_name}; >- $line{rrp} = sprintf( "%.2f", $line{'rrp'} ); >- $line{ecost} = sprintf( "%.2f", $line{'ecost'} ); >- $line{line_total} = sprintf( "%.2f", $line_total ); >+ my $biblionumber = $order->{'biblionumber'}; >+ my $countbiblio = CountBiblioInOrders($biblionumber); >+ my $ordernumber = $order->{'ordernumber'}; >+ my @subscriptions = GetSubscriptionsId ($biblionumber); >+ my $itemcount = GetItemsCount($biblionumber); >+ my $holds = GetHolds ($biblionumber); >+ my @items = GetItemnumbersFromOrder( $ordernumber ); >+ my $itemholds; >+ foreach my $item (@items){ >+ my $nb = GetItemHolds($biblionumber, $item); >+ if ($nb){ >+ $itemholds += $nb; >+ } >+ } >+ # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 >+ $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); >+ $line{items} = ($itemcount) - (scalar @items); >+ $line{left_item} = 1 if $line{items} >= 1; >+ $line{left_biblio} = 1 if $countbiblio > 1; >+ $line{biblios} = $countbiblio - 1; >+ $line{left_subscription} = 1 if scalar @subscriptions >= 1; >+ $line{subscriptions} = scalar @subscriptions; >+ $line{left_holds} = 1 if $holds >= 1; >+ $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); >+ $line{holds} = $holds; >+ $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; >+ $line{order_received} = ( $qty == $order->{'quantityreceived'} ); >+ $line{basketno} = $basketno; >+ $line{budget_name} = $budget->{budget_name}; >+ $line{rrp} = sprintf( "%.2f", $line{'rrp'} ); >+ $line{ecost} = sprintf( "%.2f", $line{'ecost'} ); >+ $line{line_total} = sprintf( "%.2f", $line_total ); > if ($line{uncertainprice}) { > $template->param( uncertainprices => 1 ); > $line{rrp} .= ' (Uncertain)'; >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 2654303..1a48920 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 catalog record and order ?')); >+ if (is_confirmed) { >+ window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber+"&delbiblio=1"; >+ } >+ } > > //]]> > </script> >@@ -277,7 +284,28 @@ > <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> >+ [% IF ( books_loo.left_holds_on_order ) %] >+ <a href="#" class="button" title="Can't delete order, ([% books_loo.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</a><br> >+ [% ELSE %] >+ <a href="javascript:confirm_delete_item([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order</a><br> >+ [% END %] >+ [% IF ( books_loo.can_del_bib ) %] >+ <a href="javascript:confirm_delete_biblio([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order and Catalog record</a><br> >+ [% ELSE %] >+ <a href="#" class="button" title="Can't delete catalog record, see constraints below">Can't delete order and Catalog record</a><br> >+ [% END %] >+ [% IF ( books_loo.left_item ) %] >+ <b title="Can't delete catalog record, ([% books_loo.items %]) items are linked delete items first" >**Left ([% books_loo.items %]) Items**</b><br> >+ [% END %] >+ [% IF ( books_loo.left_biblio ) %] >+ <b title="Can't delete catalog record, it is needed in other orders delete ([% books_loo.biblios %]) orders first">**Left ([% books_loo.biblios %]) orders**</b><br> >+ [% END %] >+ [% IF ( books_loo.left_subscription ) %] >+ <b title="Can't delete catalog record, ([% books_loo.subscriptions %]) subscriptions are linked delete subscriptions first">**Left ([% books_loo.subscriptions %]) subscriptions**</b><br> >+ [% END %] >+ [% IF ( books_loo.left_holds ) %] >+ <b title="Can't delete catalog record nor order, ([% books_loo.holds %]) holds are linked cancel holds first">**Left ([% books_loo.holds %]) holds**</b> >+ [% END %] > </td> > [% END %] > [% END %] >@@ -320,9 +348,6 @@ > </form> > </div> > [% END %] >- >- >- > </div> > </div> > <div class="yui-b"> >-- >1.7.4.1 >
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