-[%- USE HTML %][%- USE LxERP -%][%- USE L -%]
+[%- USE HTML %][%- USE LxERP -%][%- USE L -%][%- USE JavaScript -%]
[% INCLUDE 'common/flash.html' %]
<h1>[% HTML.escape(title) %]</h1>
-<p><a href="controller.pl?action=Admin/database_administration">[% LxERP.t8('Back') %]</a></p>
-
<p>
[% LxERP.t8('You can only delete datasets that are not in use.') %]
[% LxERP.t8('If you want to delete such a dataset you have to edit the client(s) that are using the dataset in question and have them use another dataset.') %]
</p>
-[% IF SELF.all_unused_dbsources.size %]
+[% IF SELF.all_dbsources.size %]
<form method="post" action="controller.pl">
<p>
[% LxERP.t8('Please select the dataset you want to delete:') %]
- [% L.select_tag('db', SELF.all_unused_dbsources) %]
+ [% L.select_tag('db', SELF.all_dbsources, class="initial_focus") %]
</p>
[% L.hidden_tag("dbhost", FORM.dbhost) %]
[% L.hidden_tag("action", "Admin/do_delete_dataset") %]
<div>
- [% L.submit_tag('dummy', LxERP.t8('Delete Dataset'), confirm=LxERP.t8('Are you sure?')) %]
+ [% L.submit_tag('dummy', LxERP.t8('Delete Dataset'), id='submit') %]
</div>
</form>
+<script type="text/javascript">
+ <!--
+
+var used_dbsources = {[% FOREACH client = SELF.all_clients %]
+ "[% JavaScript.escape(client.dbhost || 'localhost') %]:[% JavaScript.escape(client.dbport || '5432') %]:[% JavaScript.escape(client.dbname || 'localhost') %]": "[% JavaScript.escape(client.name) %]"[% UNLESS loop.last %],[% END %][% END %]
+};
+
+$(function() {
+ $('#submit').click(function() {
+ var client = used_dbsources[$('#dbhost').val() + ':' + $('#dbport').val() + ':' + $('#db').val()];
+ var question = !client ? kivi.t8('Are you sure?') : kivi.t8('The selected database is still configured for client "#1". If you delete the database that client will stop working until you re-configure it. Do you still want to delete the database?', [ client ]);
+
+ return confirm(question);
+ });
+});
+
+ -->
+</script>
+
[% END %]