From adb097e128678cfb8e15982d9c63891819c3139a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 10 Feb 2016 10:19:00 +0000 Subject: [PATCH] Bug 9021 [QA Followup] - Add feedback to delete button if provider is being used * Change links to buttons * Add warning class to delete button if provider is being used Signed-off-by: Mark Tompsett Signed-off-by: Jonathan Druart --- Koha/SMS/Provider.pm | 16 ++++++++++ .../prog/en/modules/admin/sms_providers.tt | 34 ++++++++++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Koha/SMS/Provider.pm b/Koha/SMS/Provider.pm index 1aa70dc..cc047dd 100644 --- a/Koha/SMS/Provider.pm +++ b/Koha/SMS/Provider.pm @@ -21,6 +21,8 @@ use Modern::Perl; use Carp; +use Koha::Borrowers; + use base qw(Koha::Object); =head1 NAME @@ -34,6 +36,20 @@ Koha::SMS::Provider - Koha SMS Provider object class =cut +=head3 patrons_using + +my $count = $provider->patrons_using() + +Gives the number of patrons using this provider + +=cut + +sub patrons_using { + my ( $self ) = @_; + + return Koha::Borrowers->search( { sms_provider_id => $self->id } )->count(); +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt index c33f216..706db5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt @@ -60,6 +60,7 @@ function delete_provider( id ) { Name Domain + Patrons     @@ -70,8 +71,23 @@ function delete_provider( id ) { [% p.name %] [% p.domain %] - Edit - Delete + [% p.patrons_using %] + + + Edit + + + + [% IF p.patrons_using %] + + Delete + + [% ELSE %] + + Delete + + [% END %] + [% END %] @@ -83,11 +99,19 @@ function delete_provider( id ) { + + + + - - + + Cancel + - Cancel -- 2.7.0