Fixt #2312.
(
'scalar --get_set_init' => [ qw(client user group printer db_cfg is_locked
all_dateformats all_numberformats all_countrycodes all_stylesheets all_menustyles all_clients all_groups all_users all_rights all_printers
- all_dbsources all_unused_dbsources all_accounting_methods all_inventory_systems all_profit_determinations all_charts) ],
+ all_dbsources all_used_dbsources all_accounting_methods all_inventory_systems all_profit_determinations all_charts) ],
);
__PACKAGE__->run_before(\&setup_layout);
sub init_all_numberformats { [ '1,000.00', '1000.00', '1.000,00', '1000,00' ] }
sub init_all_stylesheets { [ qw(lx-office-erp.css Mobile.css kivitendo.css) ] }
sub init_all_dbsources { [ sort User->dbsources($::form) ] }
-sub init_all_unused_dbsources { [ sort User->dbsources_unused($::form) ] }
+sub init_all_used_dbsources { { map { (join(':', $_->dbhost || 'localhost', $_->dbport || 5432, $_->dbname) => $_->name) } @{ $_[0]->all_clients } } }
sub init_all_accounting_methods { [ { id => 'accrual', name => t8('Accrual accounting') }, { id => 'cash', name => t8('Cash accounting') } ] }
sub init_all_inventory_systems { [ { id => 'perpetual', name => t8('Perpetual inventory') }, { id => 'periodic', name => t8('Periodic inventory') } ] }
sub init_all_profit_determinations { [ { id => 'balance', name => t8('Balancing') }, { id => 'income', name => t8('Cash basis accounting') } ] }
$main::lxdebug->leave_sub();
}
-sub dbsources_unused {
- $main::lxdebug->enter_sub();
-
- my ($self, $form) = @_;
-
- my %dbexcl = map { $_->dbname => 1 }
- grep { ($_->dbhost eq $form->{dbhost}) && ($_->dbport eq $form->{dbport}) }
- @{ SL::DB::Manager::AuthClient->get_all };
-
- $form->{only_acc_db} = 1;
-
- $dbexcl{$form->{dbdefault}} = 1;
- $dbexcl{$main::auth->{DB_config}->{db}} = 1;
-
- my @dbunused = grep { !$dbexcl{$_} } dbsources("", $form);
-
- $main::lxdebug->leave_sub();
-
- return @dbunused;
-}
-
sub calc_version {
$main::lxdebug->enter_sub(2);
namespace("kivi").setupLocale({
+"Are you sure?":"Sind Sie sicher?",
"The description is missing.":"Die Beschreibung fehlt.",
"The name is missing.":"Der Name fehlt.",
"The name must only consist of letters, numbers and underscores and start with a letter.":"Der Name darf nur aus Buchstaben (keine Umlaute), Ziffern und Unterstrichen bestehen und muss mit einem Buchstaben beginnen.",
-"The option field is empty.":"Das Optionsfeld ist leer."
+"The option field is empty.":"Das Optionsfeld ist leer.",
+"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?":"Die auswählte Datenbank ist noch für Mandant \"#1\" konfiguriert. Wenn Sie die Datenbank löschen, wird der Mandanten nicht mehr funktionieren, bis er anders konfiguriert wurde. Wollen Sie die Datenbank trotzdem löschen?"
});
'The selected bank account does not exist anymore.' => 'Das ausgewählte Bankkonto existiert nicht mehr.',
'The selected bin does not exist.' => 'Der ausgewählte Lagerplatz existiert nicht.',
'The selected currency' => 'Die ausgewählte Währung',
+ '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?' => 'Die auswählte Datenbank ist noch für Mandant "#1" konfiguriert. Wenn Sie die Datenbank löschen, wird der Mandanten nicht mehr funktionieren, bis er anders konfiguriert wurde. Wollen Sie die Datenbank trotzdem löschen?',
'The selected exports have been closed.' => 'Die ausgewählten Exporte wurden abgeschlossen.',
'The selected warehouse does not exist.' => 'Das ausgewählte Lager existiert nicht.',
'The selected warehouse is empty, or no stocked items where found that match the filter settings.' => 'Das ausgewählte Lager ist leer, oder in ihm wurden keine zu den Sucheinstellungen passenden eingelagerten Artikel gefunden.',
-[%- USE HTML %][%- USE LxERP -%][%- USE L -%]
+[%- USE HTML %][%- USE LxERP -%][%- USE L -%][%- USE JavaScript -%]
[% INCLUDE 'common/flash.html' %]
[% 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, class="initial_focus") %]
+ [% 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 %]