Bug 15790 - Don't delete a MARC framework if existing records use that framework

If a MARC framework is in use by any records it should not be possible
to delete it. Deleting a framework which is in use will leave the
deleted framework code in those records.

This patch modifies the deletion confirmation dialog so that it will not
let the user confirm the deletion if there are records using it.

Depends on Bug 15785 - Use Font Awesome icons in confirmation dialogs

To test, apply the patch and go to Administration -> MARC frameworks

1. Try to delete a framework which is in use by 1 or more records. The
   resulting confirmation dialog should prevent you from proceeding.
2. Try to delete a framework which is not in use. Test both canceling
   and confirming that deletion to make both function correctly.

Works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
This commit is contained in:
Owen Leonard 2016-02-11 12:06:39 -05:00 committed by Brendan Gallagher
parent 5939c4b233
commit 385380038b
1 changed files with 16 additions and 10 deletions

View File

@ -175,18 +175,24 @@
[% IF op == 'delete_confirm' %]
<div class="dialog alert">
<h3>Delete framework for [% framework.frameworktext %] ([% framework.frameworkcode %])?</h3>
[% IF biblios_use_this_framework %]
<p><strong>This framework is used [% biblios_use_this_framework %] times</strong>.</p>
<h3>This framework cannot be deleted</h3>
<p><strong><span class="ex">[% framework.frameworktext %] ([% framework.frameworkcode %])</span></strong></p>
<p>The framework is used [% biblios_use_this_framework %] times.</p>
<form action="/cgi-bin/koha/admin/biblio_framework.pl" method="get">
<button type="submit"><i class="fa fa-fw fa-arrow-left"></i> Return to frameworks</button>
</form>
[% ELSE %]
<h3>Delete framework for [% framework.frameworktext %] ([% framework.frameworkcode %])?</h3>
<form class="inline" action="/cgi-bin/koha/admin/biblio_framework.pl" method="post">
<input type="hidden" name="op" value="delete_confirmed" />
<input type="hidden" name="frameworkcode" value="[% framework.frameworkcode %]" />
<button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this framework</button>
</form>
<form class="inline" action="/cgi-bin/koha/admin/biblio_framework.pl" method="get">
<button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
</form>
[% END %]
<form class="inline" action="/cgi-bin/koha/admin/biblio_framework.pl" method="post">
<input type="hidden" name="op" value="delete_confirmed" />
<input type="hidden" name="frameworkcode" value="[% framework.frameworkcode %]" />
<button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this framework</button>
</form>
<form class="inline" action="/cgi-bin/koha/admin/biblio_framework.pl" method="get">
<button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
</form>
</div>
[% END %]