Bugzilla – Attachment 16009 Details for
Bug 9780
Restrict the right to suppress a record used in some order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PATCH] Bug 9780: Alert librarians if a record is used by orders and prevent its suppression
0005-commit1.patch (text/plain), 10.49 KB, created by
Mathieu Saby
on 2013-03-11 00:14:07 UTC
(
hide
)
Description:
[PATCH] Bug 9780: Alert librarians if a record is used by orders and prevent its suppression
Filename:
MIME Type:
Creator:
Mathieu Saby
Created:
2013-03-11 00:14:07 UTC
Size:
10.49 KB
patch
obsolete
>From b138eb71b9df3305ea40c02076789dcda6def215 Mon Sep 17 00:00:00 2001 >From: Mathieu Saby <mathieu.saby@univ-rennes2.fr> >Date: Mon, 11 Mar 2013 00:51:48 +0100 >Subject: [PATCH] Bug 9780: Alert librarians if a record is used by orders and prevent its suppression > >Before this patch, librarians can delete a record even if it is used in an order. >And if items are not created when ordering, librarians cannot know the record is used in orders. > >This patch adds one sub in Acquisiton.pm : GetOrdersByBiblionumber >It makes changes to detail.pl and detail.tt : >If the record is used by an active order, or a deleted order, Koha will display a warning at the end >of the record, with the number of active order and deleted orders using the record, and the >corresponding basket number. >If the librarian have managing order permission, the basket numbers are clickable. > >It also make changes to cat-toolbar.inc : >It adds 2 new controls when deleting a record : >- librarians cannot suppress it if it is used in an active order >- only librarians with managing order permission can suppress it if it is used in a deleted order > >To test : >1) in basket A, create 2 orders with a single record (with no items attached) >2) in basket B, create 1 order with the same record >3) check that record in catalog (detail.pl page) : you should see a line saying it is used 3 times, in baskets A and B >4) in basket A, suppress one of the order >5) check the catalog again >6) try to suppress the record : it should be impossible >7) suppress the 2 other orders in basket A and B >8) check catalogue : you should see a line saying it is only used in 3 deleted orders >9) try to delete again the record : it should be possible after a confirmation, if you have order managing rights > >--- > C4/Acquisition.pm | 35 +++++++++++- > catalogue/detail.pl | 32 +++++++++++ > .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 19 ++++++- > .../prog/en/modules/catalogue/detail.tt | 59 +++++++++++++++++++- > 4 files changed, 140 insertions(+), 5 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 4a9eae6..f309740 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -53,7 +53,7 @@ BEGIN { > &ModBasketgroup &NewBasketgroup &DelBasketgroup &GetBasketgroup &CloseBasketgroup > &GetBasketgroups &ReOpenBasketgroup > >- &NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders >+ &NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders &GetOrdersByBiblionumber > &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber > &SearchOrder &GetHistory &GetRecentAcqui > &ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber >@@ -903,6 +903,39 @@ sub GetPendingOrders { > > #------------------------------------------------------------# > >+=head3 GetOrdersByBiblionumber >+ >+ @orders = &GetOrdersByBiblionumber($biblionumber); >+ >+Looks up the orders with linked to a specific $biblionumber, including >+cancelled orders and received orders. >+ >+return : >+C<@orders> is an array of references-to-hash, whose keys are the >+fields from the aqorders, biblio, and biblioitems tables in the Koha database. >+ >+=cut >+ >+sub GetOrdersByBiblionumber { >+ my $biblionumber = shift; >+ my $dbh = C4::Context->dbh; >+ my $query =" >+ SELECT biblio.*,biblioitems.*, >+ aqorders.*, >+ aqbudgets.* >+ FROM aqorders >+ LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id >+ LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber >+ LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber >+ WHERE aqorders.biblionumber=? >+ "; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($biblionumber); >+ my $results = $sth->fetchall_arrayref({}); >+ $sth->finish; >+ return @$results; >+} >+ > =head3 GetOrders > > @orders = &GetOrders($basketnumber, $orderby); >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index ec6f6eb..9cbfada 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -41,6 +41,7 @@ use C4::XSLT; > use C4::Images; > use Koha::DateUtils; > use C4::HTML5Media; >+use C4::Acquisition qw(GetOrdersByBiblionumber); > > # use Smart::Comments; > >@@ -398,4 +399,35 @@ if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->pref > my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); > $template->param( holdcount => $holdcount, holds => $holds ); > >+my @allorders_using_biblio = GetOrdersByBiblionumber ($biblionumber); >+my @deletedorders_using_biblio; >+my @orders_using_biblio; >+my @baskets_orders; >+my @baskets_deletedorders; >+ >+foreach my $myorder (@allorders_using_biblio) { >+ my $basket = $myorder->{'basketno'}; >+ if ((defined $myorder->{'datecancellationprinted'}) and ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){ >+ push @deletedorders_using_biblio, $myorder; >+ unless (grep(/^$basket$/, @baskets_deletedorders)){ >+ push @baskets_deletedorders,$myorder->{'basketno'}; >+ } >+ } >+ else { >+ push @orders_using_biblio, $myorder; >+ unless (grep(/^$basket$/, @baskets_orders)){ >+ push @baskets_orders,$myorder->{'basketno'}; >+ } >+ } >+} >+ >+my $count_orders_using_biblio = scalar @orders_using_biblio ; >+$template->param (countorders => $count_orders_using_biblio); >+ >+my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ; >+$template->param (countdeletedorders => $count_deletedorders_using_biblio); >+ >+$template->param (basketsorders => \@baskets_orders); >+$template->param (basketsdeletedorders => \@baskets_deletedorders); >+ > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >index 2dde5ad..3db25c8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -31,12 +31,25 @@ > function confirm_deletion() { > var count = [% count %]; > var holdcount = [% holdcount %]; >- >+ var countorders = [% countorders %]; >+ var countdeletedorders = [% countdeletedorders %]; > var is_confirmed; >+ > if (count > 0){ > is_confirmed = alert( count + " " +_("item(s) are attached to this record.\nYou must delete all items before deleting this record.") ); >- } else if ( holdcount > 0 ) { >- is_confirmed = confirm( holdcount + " " + _("holds(s) for this record \n Are you sure you want to delete this record?.")); >+ } >+ else if (countorders > 0){ >+ is_confirmed = alert( _("You cannot delete this record : it is used in")+" "+ countorders + " " +_("order(s).") ); >+ } >+ else if (countdeletedorders > 0){ >+ [% IF ( CAN_user_acquisition_order_manage ) %] >+ is_confirmed = confirm( countdeletedorders + " " +_("deleted order(s) are using this record.\nAre you sure you want to delete this record?") ); >+ [% ELSE %] >+ is_confirmed = alert( countdeletedorders + " " +_("deleted order(s) are using this record.\nYou need order managing permissions to delete this record.") ); >+ [% END %] >+ } >+ else if ( holdcount > 0 ) { >+ is_confirmed = confirm( holdcount + " " + _("holds(s) for this record.\nAre you sure you want to delete this record?")); > } else { > is_confirmed = confirm(_("Are you sure you want to delete this record?")); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 8f40e31..bbb09b0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -170,7 +170,36 @@ function verify_images() { > > [% IF ( XSLTDetailsDisplay ) %] > [% XSLTBloc %] >- >+ [% IF ( countorders || countdeletedorders ) %] >+ <span class="biblio_in_orders"> >+ <span class="label">Number of order(s) using this title: </span> >+ <span> >+ [% IF ( countorders ) %] >+ [% countorders %] active order(s) in basket(s) >+ [% FOREACH basketo IN basketsorders %] >+ [% IF ( CAN_user_acquisition_order_manage ) %] >+ <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketo %]">#[% basketo %]</a>, >+ [% ELSE %] >+ [% basketo %], >+ [% END %] >+ [% END %] >+ [% END %] >+ [% IF ( countorders && countdeletedorders ) %] >+ and >+ [% END %] >+ [% IF ( countdeletedorders ) %] >+ [% countdeletedorders %] deleted order(s) in basket(s) >+ [% FOREACH basketdo IN basketsdeletedorders %] >+ [% IF ( CAN_user_acquisition_order_manage ) %] >+ <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketdo %]">#[% basketdo %]</a>, >+ [% ELSE %] >+ [% basketdo %], >+ [% END %] >+ [% END %] >+ [% END %] >+ </span> >+ </span> >+ [% END %] > [% IF ( GetShelves ) %] > <span class="results_summary"><span class="label">Lists that include this title: </span> > [% FOREACH GetShelve IN GetShelves %] >@@ -304,6 +333,34 @@ function verify_images() { > [% END %] > </li> > [% END %] >+ <span> </span> >+ [% IF ( countorders || countdeletedorders ) %] >+ <li><strong>Number of order(s) using this title: </strong> >+ [% IF ( countorders ) %] >+ [% countorders %] active order(s) in basket(s) >+ [% FOREACH basketo IN basketsorders %] >+ [% IF ( CAN_user_acquisition_order_manage ) %] >+ <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketo %]">#[% basketo %]</a>, >+ [% ELSE %] >+ [% basketo %], >+ [% END %] >+ [% END %] >+ [% END %] >+ [% IF ( countorders && countdeletedorders ) %] >+ and >+ [% END %] >+ [% IF ( countdeletedorders ) %] >+ [% countdeletedorders %] deleted order(s) in basket(s) >+ [% FOREACH basketdo IN basketsdeletedorders %] >+ [% IF ( CAN_user_acquisition_order_manage ) %] >+ <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketdo %]">#[% basketdo %]</a>, >+ [% ELSE %] >+ [% basketdo %], >+ [% END %] >+ [% END %] >+ [% END %] >+ </li> >+ [% END %] > <!--This grabs all of the lists a bib record appears in --> > [% IF ( GetShelves ) %] > <li><strong>Lists that include this title: </strong> >-- >1.7.9.5 >
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 9780
:
16008
|
16009
|
16161
|
16164
|
16167
|
16233
|
16305
|
16774
|
17390
|
21254
|
22128
|
22168