From b2180b8bd44bcb51419b1f5f718edab4905468c4 Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Fri, 2 Mar 2012 14:23:17 +0100 Subject: [PATCH] Bug 4969: deletion of suppliers If a vendor/bookseller has no basket/subscription link, it can now be deleted (after a JS confirmation). Signed-off-by: Katrin Fischer Verified that I can only delete vendors without linked orders or subscriptions. Signed-off-by: Paul Poulain --- C4/Bookseller.pm | 3 +++ acqui/supplier.pl | 7 ++++++- .../prog/en/includes/acquisitions-toolbar.inc | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm index 6a91f995e6..f14bd02600 100644 --- a/C4/Bookseller.pm +++ b/C4/Bookseller.pm @@ -84,6 +84,9 @@ sub GetBookSellerFromId { ( $vendor->{basketcount} ) = $dbh->selectrow_array( 'SELECT count(*) FROM aqbasket where booksellerid = ?', {}, $id ); + ( $vendor->{subscriptioncount} ) = $dbh->selectrow_array( + 'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?', + {}, $id ); } return $vendor; } diff --git a/acqui/supplier.pl b/acqui/supplier.pl index 8896b3b442..fdeef06f5b 100755 --- a/acqui/supplier.pl +++ b/acqui/supplier.pl @@ -114,10 +114,15 @@ if ( $op eq 'display' ) { GST => $tax_rate, default_tax => defined($seller_gstrate), basketcount => $supplier->{'basketcount'}, + subscriptioncount => $supplier->{'subscriptioncount'}, contracts => $contracts, ); } elsif ( $op eq 'delete' ) { - DelBookseller($booksellerid); + # no further message needed for the user + # the DELETE button only appears in the template if basketcount == 0 + if ( $supplier->{'basketcount'} == 0 ) { + DelBookseller($booksellerid); + } print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl'); exit; } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc index 37cdf7c182..d8e2c1ef20 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc @@ -16,6 +16,7 @@ new YAHOO.widget.Button("newsupplier"); new YAHOO.widget.Button("newbasket"); new YAHOO.widget.Button("editsupplier"); + new YAHOO.widget.Button("deletesupplier"); new YAHOO.widget.Button("receive"); new YAHOO.widget.Button("newcontract"); new YAHOO.widget.Button("editcontracts"); @@ -46,6 +47,9 @@ [% IF ( booksellerid ) %] [% IF ( CAN_user_acquisition_vendors_manage ) %]
  • Edit
  • + [% UNLESS ( basketcount OR subscriptioncount ) %] +
  • Delete
  • + [% END %]
  • New Contract
  • Contracts
  • [% UNLESS ( basketcount ) %] -- 2.39.5