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.

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.

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Owen Leonard 2016-02-11 12:06:39 -05:00 committed by Julian Maurice
parent a2fa4df79d
commit 18820b6c8f
1 changed files with 16 additions and 5 deletions

View File

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