Bugzilla – Attachment 16305 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][Revised] Bug 9780: Show if a record is used by orders and prevent its suppression
0005-Bug-9780-Show-if-a-record-is-used-by-orders-and-prev.patch (text/plain), 16.23 KB, created by
Mathieu Saby
on 2013-03-18 19:10:33 UTC
(
hide
)
Description:
[PATCH][Revised] Bug 9780: Show if a record is used by orders and prevent its suppression
Filename:
MIME Type:
Creator:
Mathieu Saby
Created:
2013-03-18 19:10:33 UTC
Size:
16.23 KB
patch
obsolete
>From 3db5380a8500956bbdf8b47ca1b248b36c023d7b 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][Revised] Bug 9780: Show if a record is used by orders and prevent its suppression > >Revised : suppressing tabs, adding 5) and 18) step in test > >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 : >A. test what can do and see a librarian with order managing rights >0) Connect to Koha with a borrower with order managing rights >1) check XSLTDetailsDisplay syspref is disabled >2) in basket A, create 2 orders with a single record >3) in basket B, create 1 order with the same record >4) check that record in catalog (detail.pl page) : you should see a line saying it is used 3 times, in baskets A and B >5) if some items are attached to that record, suppress all items >6) in basket A, suppress one of the 2 orders >7) check the record again : you should see a line saying it is used 2 times in active orders, in baskets A and B, and 1 time in suppressed order in basket A >8) enable XSLTDetailsDisplay syspref >9) check the record again : you should see the same information as 5. >10) each basket number must be a hyperlink. Check if the links are correct >11) try to suppress the record : it should be impossible >12) suppress the 2 other orders in basket A and B >13) check catalogue : you should see a line saying it is only used in 3 deleted orders >14) try to delete again the record : it should be possible after a confirmation > >B. test what can do and see a librarian without order managing rights >15) in basket A, create again 1 order with a single record >16) disconnect yourself and connect to Koha with a borrower without order managing rights >17) check the record in the catalog : you should see information, but without any link to basket A >18) if some items are attached to that record, suppress all items >19) try to suppress the record : it should be impossible (like before) >20) disconnect yourself and connect to Koha with a borrower with order managing rights >21) suppress the order in basket A >22) disconnect yourself and connect to Koha with a borrower without order managing rights >23) check the record again : you should see a line saying it is only used in a deleted order in basket A >24) try to delete the record : it should be impossible, because you don't have order managing rights > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> > >--- > C4/Acquisition.pm | 35 +++++- > catalogue/detail.pl | 32 +++++ > .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 21 +++- > .../prog/en/modules/catalogue/detail.tt | 129 ++++++++++++++------ > 4 files changed, 178 insertions(+), 39 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 4a9eae6..8390670 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..636e0a4 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..32586ae 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){ >+ >+ 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..32acd66 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -136,41 +136,70 @@ function verify_images() { > </div> > > <div id="doc3" class="yui-t2"> >- >-[% IF ( unknownbiblionumber ) %] >- <div class="dialog message">The record you requested does not exist ([% biblionumber %]).</div> >-[% ELSE %] >- <div id="bd"> >- <div id="yui-main"> >- <div class="yui-b"> >- >-[% INCLUDE 'cat-toolbar.inc' %] >- [% IF ( ocoins ) %] >- <!-- COinS / OpenURL --> >- <span class="Z3988" title="[% ocoins %]"></span> >- [% END %] >- >- [% IF ( AmazonCoverImages ) %] >- [% IF ( XSLTDetailsDisplay ) %] >- <div class="yui-gc"> >- <div id="catalogue_detail_biblio" class="yui-u first"> >- [% ELSE %] >- <div class="yui-gb"> >- <div id="catalogue_detail_biblio" class="yui-u first"> >- [% END %] >+ [% IF ( unknownbiblionumber ) %] >+ <div class="dialog message">The record you requested does not exist ([% biblionumber %]).</div> > [% ELSE %] >- [% IF ( XSLTDetailsDisplay ) %] >- <div class="yui-g"> >- <div id="catalogue_detail_biblio"> >- [% ELSE %] >- <div class="yui-g"> >- <div id="catalogue_detail_biblio" class="yui-u first"> >- [% END %] >- [% END %] >- >- [% IF ( XSLTDetailsDisplay ) %] >- [% XSLTBloc %] >- >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ [% INCLUDE 'cat-toolbar.inc' %] >+ [% IF ( ocoins ) %] >+ <!-- COinS / OpenURL --> >+ <span class="Z3988" title="[% ocoins %]"></span> >+ [% END %] >+ [% IF ( AmazonCoverImages ) %] >+ [% IF ( XSLTDetailsDisplay ) %] >+ <div class="yui-gc"> >+ <div id="catalogue_detail_biblio" class="yui-u first"> >+ [% ELSE %] >+ <div class="yui-gb"> >+ <div id="catalogue_detail_biblio" class="yui-u first"> >+ [% END %] >+ [% ELSE %] >+ [% IF ( XSLTDetailsDisplay ) %] >+ <div class="yui-g"> >+ <div id="catalogue_detail_biblio"> >+ [% ELSE %] >+ <div class="yui-g"> >+ <div id="catalogue_detail_biblio" class="yui-u first"> >+ [% END %] >+ [% END %] >+ [% 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> >+ [%- UNLESS loop.last %],[% END %] >+ [% ELSE %] >+ [% basketo %] >+ [%- UNLESS loop.last %],[% END %] >+ [% 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> >+ [%- UNLESS loop.last %],[% END %] >+ [% ELSE %] >+ [% basketdo %] >+ [%- UNLESS loop.last %],[% END %] >+ [% 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,38 @@ 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> >+ [%- UNLESS loop.last %],[% END %] >+ [% ELSE %] >+ [% basketo %] >+ [%- UNLESS loop.last %],[% END %] >+ [% 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> >+ [%- UNLESS loop.last %],[% END %] >+ [% ELSE %] >+ [% basketdo %] >+ [%- UNLESS loop.last %],[% END %] >+ [% 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