Bugzilla – Attachment 50232 Details for
Bug 15962
Currency deletion doesn't correctly identify currencies in use
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[3.22.x] Bug 15962: Block the currency deletion if used
Bug-15962-Block-the-currency-deletion-if-used.patch (text/plain), 2.93 KB, created by
Julian Maurice
on 2016-04-14 12:41:27 UTC
(
hide
)
Description:
[3.22.x] Bug 15962: Block the currency deletion if used
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2016-04-14 12:41:27 UTC
Size:
2.93 KB
patch
obsolete
>From c20496aea938e1faaa53daff5e2cf3d697b0eac9 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 14 Apr 2016 14:29:38 +0200 >Subject: [PATCH] Bug 15962: Block the currency deletion if used > >A currency should not be deleted if used by a vendor or a basket. > >Test plan: >1/ Add a new currency >2/ Create a vendor using this currency >3/ Create a basket using this currency >4/ Try to delete the currency >5/ Delete the basket >6/ Try to delete the currency >7/ Delete the vendor >8/ Delete the currency > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > admin/currency.pl | 18 ++++++++++-------- > .../intranet-tmpl/prog/en/modules/admin/currency.tt | 11 +++++++++-- > 2 files changed, 19 insertions(+), 10 deletions(-) > >diff --git a/admin/currency.pl b/admin/currency.pl >index f62f761..d0c4be3 100755 >--- a/admin/currency.pl >+++ b/admin/currency.pl >@@ -132,21 +132,23 @@ sub delete_confirm { > my $curr = shift; > > $template->param( delete_confirm => 1 ); >- my $total_row = $dbh->selectrow_hashref( >- 'select count(*) as total from aqbooksellers where currency=?', >- {}, $curr ); >+ my ($nb_of_vendors) = $dbh->selectrow_array(q{ >+ select count(*) from aqbooksellers >+ where listprice = ? or invoiceprice = ? >+ }, {}, $curr, $curr); >+ my ($nb_of_orders) = $dbh->selectrow_array(q{ >+ select count(*) from aqorders >+ where currency = ? >+ }, {}, $curr); > > my $curr_ref = $dbh->selectrow_hashref( > 'select currency,rate from currency where currency=?', > {}, $curr ); > >- if ( $total_row->{total} ) { >- $template->param( totalgtzero => 1 ); >- } >- > $template->param( > rate => $curr_ref->{rate}, >- total => $total_row->{total} >+ nb_of_orders => $nb_of_orders, >+ nb_of_vendors => $nb_of_vendors, > ); > > return; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt >index 6c94bb2..0e204d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt >@@ -125,10 +125,17 @@ > [% END %] > > [% IF ( delete_confirm ) %] >- [% IF ( totalgtzero ) %] >+ [% IF ( nb_of_orders or nb_of_vendors ) %] > <div class="dialog message"> > <h3>Cannot delete currency <span class="ex">'[% searchfield %]'</span></h3> >- <p>This currency is used [% total %] times. Deletion not possible</p> >+ <p> >+ [% IF nb_of_orders %] >+ This currency is used by [% nb_of_orders %] orders. >+ [% ELSIF nb_of_vendors %] >+ This currency is used by [% nb_of_vendors %] vendors. >+ [% END %] >+ Deletion not possible >+ </p> > <form action="[% script_name %]" method="post"> > <input type="submit" value="OK" class="approve" /> > </form> >-- >2.1.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 15962
:
48773
|
48774
|
49047
|
49048
|
49374
|
49375
|
49376
| 50232