From 62726dfdf4f763efa65c25fcfe8658d98649c8a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 13 May 2016 16:48:09 +0200 Subject: [PATCH] Drafts: Ausgelagert in Controller --- SL/Controller/Draft.pm | 187 +++++++++++++++++++++++ SL/Drafts.pm | 151 ------------------ bin/mozilla/ap.pl | 7 +- bin/mozilla/ar.pl | 9 +- bin/mozilla/drafts.pl | 195 ------------------------ bin/mozilla/ir.pl | 6 +- bin/mozilla/is.pl | 9 +- bin/mozilla/vk.pl | 1 - js/kivi.Draft.js | 34 +++++ js/locale/de.js | 1 + locale/de/all | 12 +- templates/webpages/ap/form_footer.html | 7 +- templates/webpages/ar/form_footer.html | 10 +- templates/webpages/drafts/form.html | 46 ++++++ templates/webpages/drafts/save_new.html | 28 ---- templates/webpages/ir/form_footer.html | 2 +- templates/webpages/is/form_footer.html | 5 +- 17 files changed, 295 insertions(+), 415 deletions(-) create mode 100644 SL/Controller/Draft.pm delete mode 100644 SL/Drafts.pm delete mode 100644 bin/mozilla/drafts.pl create mode 100644 js/kivi.Draft.js create mode 100644 templates/webpages/drafts/form.html delete mode 100644 templates/webpages/drafts/save_new.html diff --git a/SL/Controller/Draft.pm b/SL/Controller/Draft.pm new file mode 100644 index 000000000..33da3bd1a --- /dev/null +++ b/SL/Controller/Draft.pm @@ -0,0 +1,187 @@ +package SL::Controller::Draft; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::Helper::Flash qw(flash); +use SL::Locale::String qw(t8); +use SL::Request; +use SL::DB::Draft; +use SL::DBUtils qw(selectall_hashref_query); +use YAML; +use List::Util qw(max); + +use Rose::Object::MakeMethods::Generic ( + scalar => [ qw() ], + 'scalar --get_set_init' => [ qw(module submodule draft) ], +); + +__PACKAGE__->run_before('check_auth'); + +my %allowed_modules = map { $_ => "bin/mozilla/$_.pl" } qw(is ir ar ap); + +# +# actions +# + +sub action_draft_dialog { + my ($self) = @_; + $self->js + ->dialog->open({ + html => $self->dialog_html, + id => 'save_draft', + dialog => { + title => t8('Drafts'), + }, + }) + ->render; +} + +sub action_save { + my ($self) = @_; + + my $id = $::form->{id}; + my $description = $::form->{description} or die 'need description'; + my $form = $self->_build_form; + + my $draft = SL::DB::Manager::Draft->find_by_or_create(id => $id); + + $draft->id($self->module . '-' . $self->submodule . '-' . Common::unique_id()) unless $draft->id; + + $draft->assign_attributes( + module => $self->module, + submodule => $self->submodule, + description => $description, + form => YAML::Dump($form), + employee_id => SL::DB::Manager::Employee->current->id, + ); + + $self->draft($draft); + + if (!$draft->save) { + flash('error', t8('There was an error saving the draft')); + $self->js + ->html('#save_draft', $self->dialog_html) + ->render; + } else { + $self->js + ->flash('info', t8("Draft saved.")) + ->dialog->close('#save_draft') + ->render; + } +} + +sub action_load { + my ($self) = @_; + + if (!$allowed_modules{ $self->draft->module }) { + $::form->error(t8('Unknown module: #1', $self->draft->module)); + } else { + package main; + require $allowed_modules{ $self->draft->module }; + } + + my $new_form = YAML::Load($self->draft->form); + $::form->{$_} = $new_form->{$_} for keys %$new_form; + $::form->{"draft_$_"} = $self->draft->$_ for qw(id description); + + $::form->{script} = $self->draft->module . '.pl'; + ::update(); +} + +sub action_delete { + my ($self) = @_; + + $self->module($self->draft->module); + $self->submodule($self->draft->submodule); + + if (!$self->draft->delete) { + flash('error', t8('There was an error deleting the draft')); + $self->js + ->html('#save_draft', $self->dialog_html) + ->render; + } else { + flash('info', t8('Draft deleted')); + + $self->js + ->html('#save_draft', $self->dialog_html) + ->render; + } +} + +# +# helpers +# + +sub _build_form { + my $last_index = max map { /form\[(\d+)\]/ ? $1 : 0 } keys %$::form; + my $new_form = {}; + + for my $i (0..$last_index) { + SL::Request::_store_value($new_form, $::form->{"form[$i][name]"}, $::form->{"form[$i][value]"}); + } + + return $new_form; +} + +sub draft_list { + my ($self) = @_; + + my $result = selectall_hashref_query($::form, $::form->get_standard_dbh, <module, $self->submodule); + SELECT d.*, date(d.itime) AS date, e.name AS employee_name + FROM drafts d + LEFT JOIN employee e ON d.employee_id = e.id + WHERE (d.module = ?) AND (d.submodule = ?) + ORDER BY d.itime +SQL +} + +sub dialog_html { + my ($self) = @_; + + $self->render('drafts/form', { layout => 0, output => 0 }, + drafts_list => $self->draft_list + ) +} + +sub init_module { + $::form->{module} or die 'need module'; +} + +sub init_submodule { + $::form->{submodule} or die 'need submodule'; +} + +sub init_draft { + SL::DB::Manager::Draft->find_by(id => $::form->{id}) or die t8('Could not load this draft'); +} + +sub check_auth { + $::auth->assert('vendor_invoice_edit | invoice_edit | general_ledger'); +} + +1; + +__END__ + +=encoding utf-8 + +=head1 NAME + +SL::Controller::Draft + +=head1 DESCRIPTION + +Encapsulates the old draft mechanism. Use and improvement are discuraged as +long as the storage is not upgrade safe. + +=head1 TODO + + - optional popup on entry + +=head1 AUTHOR + +Sven Schöling Es.schoeling@linet-services.deE + +=cut diff --git a/SL/Drafts.pm b/SL/Drafts.pm deleted file mode 100644 index e5242aa4d..000000000 --- a/SL/Drafts.pm +++ /dev/null @@ -1,151 +0,0 @@ -#====================================================================== -# LX-Office ERP -# -#====================================================================== -# -# Saving and loading drafts -# -#====================================================================== - -package Drafts; - -use YAML; - -use SL::Common; -use SL::DBUtils; - -use strict; - -sub get_module { - $main::lxdebug->enter_sub(); - - my ($self, $form) = @_; - - my ($module, $submodule); - - $module = $form->{"script"}; - $module =~ s/\.pl$//; - if (grep({ $module eq $_ } qw(is ir ar ap))) { - $submodule = "invoice"; - } else { - $submodule = "unknown"; - } - - $main::lxdebug->leave_sub(); - - return ($module, $submodule); -} - -my @dont_save = qw(login password action); - -sub dont_save { - return @dont_save; -} - -sub save { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form, $draft_id, $draft_description) = @_; - - my ($dbh, $sth, $query, %saved, $dumped); - - $dbh = $form->get_standard_dbh; - $dbh->begin_work; - - my ($module, $submodule) = $self->get_module($form); - - $query = "SELECT COUNT(*) FROM drafts WHERE id = ?"; - my ($res) = selectrow_query($form, $dbh, $query, $draft_id); - - if (!$res) { - $draft_id = $module . "-" . $submodule . "-" . Common::unique_id(); - $query = "INSERT INTO drafts (id, module, submodule) VALUES (?, ?, ?)"; - do_query($form, $dbh, $query, $draft_id, $module, $submodule); - } - - map({ $saved{$_} = $form->{$_}; - delete($form->{$_}); } @dont_save); - - $dumped = YAML::Dump($form); - map({ $form->{$_} = $saved{$_}; } @dont_save); - - $query = - qq|UPDATE drafts SET description = ?, form = ?, employee_id = | . - qq| (SELECT id FROM employee WHERE login = ?) | . - qq|WHERE id = ?|; - - do_query($form, $dbh, $query, $draft_description, $dumped, $::myconfig{login}, $draft_id); - - $dbh->commit(); - - $form->{draft_id} = $draft_id; - $form->{draft_description} = $draft_description; - - $main::lxdebug->leave_sub(); -} - -sub load { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form, $draft_id) = @_; - - my ($dbh, $sth, $query, @values); - - $dbh = $form->get_standard_dbh; - - $query = qq|SELECT id, description, form FROM drafts WHERE id = ?|; - - $sth = prepare_execute_query($form, $dbh, $query, $draft_id); - - if (my $ref = $sth->fetchrow_hashref()) { - @values = ($ref->{form}, $ref->{id}, $ref->{description}); - } - $sth->finish(); - - $main::lxdebug->leave_sub(); - - return @values; -} - -sub remove { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form, @draft_ids) = @_; - - return $main::lxdebug->leave_sub() unless (@draft_ids); - - my ($dbh, $sth, $query); - - $dbh = $form->get_standard_dbh; - - $query = qq|DELETE FROM drafts WHERE id IN (| . join(", ", map { "?" } @draft_ids) . qq|)|; - do_query($form, $dbh, $query, @draft_ids); - - $dbh->commit; - - $main::lxdebug->leave_sub(); -} - -sub list { - $::lxdebug->enter_sub; - - my $self = shift; - my $myconfig = shift || \%::myconfig; - my $form = shift || $::form; - my $dbh = $form->get_standard_dbh; - - my @list = selectall_hashref_query($form, $dbh, <get_module($form)); - SELECT d.id, d.description, d.itime::timestamp(0) AS itime, - e.name AS employee_name - FROM drafts d - LEFT JOIN employee e ON d.employee_id = e.id - WHERE (d.module = ?) AND (d.submodule = ?) - ORDER BY d.itime -SQL - - $::lxdebug->leave_sub; - - return @list; -} - -1; diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index dd9a46dd1..25ee60262 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -46,7 +46,6 @@ use SL::DB::PurchaseInvoice; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; -require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; use strict; @@ -91,11 +90,9 @@ sub add { $main::auth->assert('general_ledger'); - return $main::lxdebug->leave_sub() if (load_draft_maybe()); - $form->{title} = "Add"; - $form->{callback} = "ap.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; + $form->{callback} = "ap.pl?action=add" unless $form->{callback}; AP->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; @@ -326,6 +323,7 @@ sub form_header { $form->{javascript} .= qq||; $form->{javascript} .= qq||; $form->{javascript} .= qq||; + $form->{javascript} .= qq||; $form->header(); @@ -714,7 +712,6 @@ sub post { $form->save_history; } # /saving the history - remove_draft() if $form->{remove_draft}; # Dieser Text wird niemals ausgegeben: Probleme beim redirect? $form->redirect($locale->text('Transaction posted!')) unless $inline; } else { diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 8a0d780e3..c141270f6 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -45,7 +45,6 @@ use SL::ReportGenerator; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; -require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; use strict; @@ -87,8 +86,6 @@ sub add { my $form = $main::form; my %myconfig = %main::myconfig; - return $main::lxdebug->leave_sub() if (load_draft_maybe()); - # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; @@ -98,7 +95,7 @@ sub add { # /saving the history $form->{title} = "Add"; - $form->{callback} = "ar.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; + $form->{callback} = "ar.pl?action=add" unless $form->{callback}; AR->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; @@ -332,7 +329,8 @@ sub form_header { $form->{javascript} .= qq|| . - qq||; + qq|| . + qq||; # $amount = $locale->text('Amount'); # $project = $locale->text('Project'); @@ -740,7 +738,6 @@ sub post { $form->save_history; } # /saving the history - remove_draft() if $form->{remove_draft}; $form->redirect($locale->text('Transaction posted!')) unless $inline; diff --git a/bin/mozilla/drafts.pl b/bin/mozilla/drafts.pl deleted file mode 100644 index 7670c7e5e..000000000 --- a/bin/mozilla/drafts.pl +++ /dev/null @@ -1,195 +0,0 @@ -#====================================================================== -# LX-Office ERP -# -#====================================================================== -# -# Saving and loading drafts -# -#====================================================================== - -use YAML; - -use SL::Drafts; - -require "bin/mozilla/common.pl"; - -use strict; - -sub save_draft { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - if (!$form->{draft_id} && !$form->{draft_description}) { - restore_form($form->{SAVED_FORM}, 1) if ($form->{SAVED_FORM}); - delete $form->{SAVED_FORM}; - - $form->{SAVED_FORM} = save_form(qw(login password)); - $form->{remove_draft} = 1; - - $form->header(); - print($form->parse_html_template("drafts/save_new")); - - return $main::lxdebug->leave_sub(); - } - - my ($draft_id, $draft_description) = ($form->{draft_id}, $form->{draft_description}); - - restore_form($form->{SAVED_FORM}, 1); - delete $form->{SAVED_FORM}; - - Drafts->save(\%myconfig, $form, $draft_id, $draft_description); - - $form->{saved_message} = $locale->text("Draft saved."); - - update(); - - $main::lxdebug->leave_sub(); -} - -sub remove_draft { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - Drafts->remove(\%myconfig, $form, $form->{draft_id}) if ($form->{draft_id}); - - delete @{$form}{qw(draft_id draft_description)}; - - $main::lxdebug->leave_sub(); -} - -sub load_draft_maybe { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::lxdebug->leave_sub() and return 0 if ($form->{DONT_LOAD_DRAFT}); - - my ($draft_nextsub) = @_; - - my @drafts = Drafts->list(\%myconfig, $form); - - $main::lxdebug->leave_sub() and return 0 unless (@drafts); - - $draft_nextsub = "add" unless ($draft_nextsub); - - delete $form->{action}; - my $saved_form = save_form(qw(login password)); - - $form->header(); - print($form->parse_html_template("drafts/load", - { "DRAFTS" => \@drafts, - "SAVED_FORM" => $saved_form, - "draft_nextsub" => $draft_nextsub })); - - $main::lxdebug->leave_sub(); - - return 1; -} - -sub dont_load_draft { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - - my $draft_nextsub = $form->{draft_nextsub} || "add"; - - restore_form($form->{SAVED_FORM}, 1); - delete $form->{SAVED_FORM}; - - $form->{DONT_LOAD_DRAFT} = 1; - - call_sub($draft_nextsub); - - $main::lxdebug->leave_sub(); -} - -sub load_draft { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - # check and store certain form parameters that might have been passed as get, so we can later overwrite the values from the draft - # the overwrite happens at the end of this function - my @valid_overwrite_vars = qw(remove_draft amount_1 invnumber ordnumber transdate duedate notes datepaid_1 paid_1 callback AP_paid_1 currency); # reference description - my $overwrite_hash; - # my @valid_fields; - foreach ( @valid_overwrite_vars ) { - $overwrite_hash->{$_} = $form->{$_} if exists $form->{$_}; # variant 1 - # push(@valid_fields, $_) if exists $form->{$_}; # variant 2 - }; - - my ($old_form, $id, $description) = Drafts->load(\%myconfig, $form, $form->{id}); - - if ($old_form) { - $old_form = YAML::Load($old_form); - - my %dont_save_vars = map { $_ => 1 } Drafts->dont_save; - my @restore_vars = grep { !$dont_save_vars{$_} } keys %{ $old_form }; - - @{$form}{@restore_vars} = @{$old_form}{@restore_vars}; - - $form->{draft_id} = $id; - $form->{draft_description} = $description; - $form->{remove_draft} = 'checked'; - } - # Ich vergesse bei Rechnungsentwürfe das Rechnungsdatum zu ändern. Dadurch entstehen - # ungültige Belege. Vielleicht geht es anderen ähnlich jan 19.2.2011 - $form->{invdate} = $form->current_date(\%myconfig); # Aktuelles Rechnungsdatum ... - $form->{duedate} = $form->current_date(\%myconfig); # Aktuelles Fälligkeitsdatum ... - - if ( $overwrite_hash ) { - foreach ( keys %$overwrite_hash ) { - $form->{$_} = $overwrite_hash->{$_}; # variante 1 - }; - }; - # @{$form}{@valid_fields} = @{$overwrite_hash}{@valid_fields}; # variante 2 - - update(); - - $main::lxdebug->leave_sub(); -} - -sub delete_drafts { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - my @ids; - foreach (keys %{$form}) { - push @ids, $1 if (/^checked_(.*)/ && $form->{$_}); - } - Drafts->remove(\%myconfig, $form, @ids) if (@ids); - - restore_form($form->{SAVED_FORM}, 1); - delete $form->{SAVED_FORM}; - - add(); - - $main::lxdebug->leave_sub(); -} - -sub draft_action_dispatcher { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my $locale = $main::locale; - - if ($form->{draft_action} eq $locale->text("Skip")) { - dont_load_draft(); - - } elsif ($form->{draft_action} eq $locale->text("Delete drafts")) { - delete_drafts(); - } - - $main::lxdebug->leave_sub(); -} - -1; diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 5b62ea5c4..6973feedb 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -43,7 +43,6 @@ use List::UtilsBy qw(sort_by); require "bin/mozilla/io.pl"; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; -require "bin/mozilla/drafts.pl"; use strict; @@ -63,8 +62,6 @@ sub add { $::form->show_generic_error($::locale->text("You do not have the permissions to access this function.")); } - return $main::lxdebug->leave_sub() if (load_draft_maybe()); - $form->{show_details} = $::myconfig{show_form_details}; $form->{title} = $locale->text('Record Vendor Invoice'); @@ -344,7 +341,7 @@ sub form_header { $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); $form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $TMPL_VAR{payment_terms_obj}; - $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); + $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); $form->header(); @@ -806,7 +803,6 @@ sub post { $form->save_history; } # /saving the history - remove_draft() if $form->{remove_draft}; $form->redirect( $locale->text('Invoice') . " $form->{invnumber} " . $locale->text('posted!')); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 478060cc0..37981eb5d 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -49,7 +49,6 @@ use SL::DB::PaymentTerm; require "bin/mozilla/io.pl"; require "bin/mozilla/arap.pl"; -require "bin/mozilla/drafts.pl"; use strict; @@ -65,8 +64,6 @@ sub add { $main::auth->assert('invoice_edit'); - return $main::lxdebug->leave_sub() if (load_draft_maybe()); - $form->{show_details} = $::myconfig{show_form_details}; if ($form->{type} eq "credit_note") { @@ -396,7 +393,7 @@ sub form_header { ), @custom_hiddens, map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; - $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); + $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); $form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR{payment_terms_obj}; @@ -863,8 +860,6 @@ sub post { } } - remove_draft() if $form->{remove_draft}; - if(!exists $form->{addition}) { $form->{snumbers} = 'invnumber' .'_'. $form->{invnumber}; # ($form->{type} eq 'credit_note' ? 'cnnumber' : 'invnumber') .'_'. $form->{invnumber}; $form->{what_done} = 'invoice'; @@ -1127,7 +1122,7 @@ sub e_mail { sub dispatcher { for my $action (qw( print update ship_to e_mail storno post_payment use_as_new credit_note - delete post order preview post_and_e_mail print_and_post save_draft + delete post order preview post_and_e_mail print_and_post mark_as_paid )) { if ($::form->{"action_$action"}) { diff --git a/bin/mozilla/vk.pl b/bin/mozilla/vk.pl index a6476d9f1..2cbb6afd5 100644 --- a/bin/mozilla/vk.pl +++ b/bin/mozilla/vk.pl @@ -42,7 +42,6 @@ use Data::Dumper; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; -require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; use strict; diff --git a/js/kivi.Draft.js b/js/kivi.Draft.js new file mode 100644 index 000000000..c87a21f0f --- /dev/null +++ b/js/kivi.Draft.js @@ -0,0 +1,34 @@ +namespace('kivi.Draft', function(ns) { + 'use strict'; + + ns.popup = function(module, submodule, id, description) { + $.get('controller.pl', { + action: 'Draft/draft_dialog.js', + module: module, + submodule: submodule, + id: id, + description: description + }, kivi.eval_json_result) + } + + ns.save = function(module, submodule) { + $.post('controller.pl', { + action: 'Draft/save.js', + module: module, + submodule: submodule, + form: $('form').serializeArray(), + id: $('#new_draft_id').val(), + description: $('#new_draft_description').val() + }, kivi.eval_json_result) + } + + ns.delete = function(id) { + if (!confirm(kivi.t8('Do you really want to delete this draft?'))) return; + + $.post('controller.pl', { + action: 'Draft/delete.js', + id: id + }, kivi.eval_json_result) + + } +}); diff --git a/js/locale/de.js b/js/locale/de.js index 1c3fad3f2..316faebfb 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -35,6 +35,7 @@ namespace("kivi").setupLocale({ "Delete text block":"Textblock löschen", "Do you really want do continue?":"Wollen Sie wirklich fortfahren?", "Do you really want to cancel?":"Wollen Sie wirklich abbrechen?", +"Do you really want to delete this draft?":"Wollen Sie diesen Entwurf wirklich löschen?", "Do you really want to revert to this version?":"Wollen Sie wirklich auf diese Version zurücksetzen?", "Do you really want to save?":"Wollen Sie wirklich speichern?", "Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"Soll die Kontonummer \"#1\" zu \"#2\" und den Name \"#3\" zu \"#4\" geändert werden?", diff --git a/locale/de/all b/locale/de/all index be7edb740..393f44126 100755 --- a/locale/de/all +++ b/locale/de/all @@ -617,6 +617,7 @@ $self->{texts} = { 'Could not load employee' => 'Konnte Benutzer nicht laden', 'Could not load this business' => 'Konnte diesen Kunden-/Lieferantentyp nicht laden', 'Could not load this customer' => 'Konnte diesen Kunden nicht laden', + 'Could not load this draft' => 'Dieser Entwurf konnte nicht geladen werden', 'Could not load this vendor' => 'Konnte diesen Lieferanten nicht laden', 'Could not print dunning.' => 'Die Mahnungen konnten nicht gedruckt werden.', 'Could not reconcile chosen elements!' => 'Die gewählten Elemente konnten nicht ausgeglichen werden!', @@ -944,6 +945,7 @@ $self->{texts} = { 'Do you really want to delete AR transaction #1?' => 'Wollen Sie wirklich die Debitorenbuchung #1 löschen?', 'Do you really want to delete GL transaction #1?' => 'Wollen Sie wirklich die Dialogbuchung #1 löschen?', 'Do you really want to delete the selected links?' => 'Wollen Sie wirklich die ausgewählten Verknüpfungen löschen?', + 'Do you really want to delete this draft?' => 'Wollen Sie diesen Entwurf wirklich löschen?', 'Do you really want to delete this invoice?' => 'Wollen Sie diese Rechnung wirklich löschen?', 'Do you really want to delete this object?' => 'Wollen Sie dieses Objekt wirklich löschen?', 'Do you really want to delete this warehouse?' => 'Wollen Sie dieses Lager wirklich löschen?', @@ -970,10 +972,12 @@ $self->{texts} = { 'Download SEPA XML export file' => 'SEPA-XML-Exportdatei herunterladen', 'Download picture' => 'Bild herunterladen', 'Download sample file' => 'Beispieldatei herunterladen', + 'Draft deleted' => 'Entwurf gelöscht', 'Draft for this Letter saved!' => 'Briefentwurf gespeichert!', 'Draft from:' => 'Entwurf vom:', 'Draft saved.' => 'Entwurf gespeichert.', 'Draft suggestions' => 'Entwurfsvorschläge', + 'Drafts' => 'Entwürfe', 'Drawing' => 'Zeichnung', 'Dropdown Limit' => 'Auswahllistenbegrenzung', 'Due' => 'Fällig', @@ -1119,7 +1123,6 @@ $self->{texts} = { 'Enabled Quick Searched' => 'Aktivierte Schnellsuchen', 'Enabled modules' => 'Aktivierte Module', 'End date' => 'Enddatum', - 'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung für diesen Entwurf ein.', 'Enter longdescription' => 'Langtext eingeben', 'Enter the requested execution date or leave empty for the quickest possible execution:' => 'Geben Sie das jeweils gewünschte Ausführungsdatum an, oder lassen Sie das Feld leer für die schnellstmögliche Ausführung:', 'Entries for which automatic conversion failed:' => 'Einträge, für die die automatische Umstellung fehlschlug:', @@ -1610,6 +1613,7 @@ $self->{texts} = { 'List of database upgrades to be applied:' => 'Liste der noch einzuspielenden Datenbankupgrades:', 'List of tax zones' => 'Liste der Steuerzonen', 'List open SEPA exports' => 'Noch nicht ausgeführte SEPA-Exporte anzeigen', + 'Load an existing draft' => 'Einen bestehenden Entwurf laden', 'Load draft' => 'Entwurf laden', 'Load letter draft' => 'Briefentwurf laden', 'Load profile' => 'Profil laden', @@ -2400,6 +2404,7 @@ $self->{texts} = { 'Save and close' => 'Speichern und schließen', 'Save and execute' => 'Speichern und ausführen', 'Save and keep open' => 'Speichern und geöffnet lassen', + 'Save as a new draft.' => 'Als neuen Entwurf speichern', 'Save as new' => 'als neu speichern', 'Save document in WebDAV repository' => 'Dokument in WebDAV-Ablage speichern', 'Save draft' => 'Entwurf speichern', @@ -3033,8 +3038,10 @@ $self->{texts} = { 'There is not enough available of \'#1\' at warehouse \'#2\', bin \'#3\', #4, for the transfer of #5.' => 'Von \'#1\' ist in Lager \'#2\', Lagerplatz \'#3\', #4 nicht genügend eingelagert, um insgesamt #5 auszulagern.', 'There is not enough left of \'#1\' in bin \'#2\' for the removal of #3.' => 'In Lagerplatz \'#2\' ist nicht genug von \'#1\' vorhanden, um #3 zu entnehmen.', 'There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.' => 'Es gibt einen oder mehrere Abschnitte ohne Artikelzuweisung; daher kann der neue Beleg noch nicht erstellt werden.', + 'There was an error deleting the draft' => 'Beim Löschen des Entwurfs ist ein Fehler aufgetretetn', 'There was an error executing the background job.' => 'Bei der Ausführung des Hintergrund-Jobs trat ein Fehler auf.', 'There was an error parsing the csv file: #1 in line #2: #3' => 'Es gab einen Fehler beim Parsen der CSV Datei: "#1" in der Zeile "#2": "#3"', + 'There was an error saving the draft' => 'Beim Speichern des Entwurfs ist ein Fehler aufgetretetn', 'There was an error saving the letter' => 'Ein Fehler ist aufgetreten. Der Brief konnte nicht gespeichert werden.', 'There was an error saving the letter draft' => 'Ein Fehler ist aufgetreten. Der Briefentwurf konnte nicht gespeichert werden.', 'There you can let kivitendo create the basic tables for you, even in an already existing database.' => 'Dort können Sie kivitendo diese grundlegenden Tabellen erstellen lassen, selbst in einer bereits existierenden Datenbank.', @@ -3192,6 +3199,7 @@ $self->{texts} = { 'Unknown Category' => 'Unbekannte Kategorie', 'Unknown Link' => 'Unbekannte Verknüpfung', 'Unknown dependency \'%s\'.' => 'Unbekannte Abhängigkeit \'%s\'.', + 'Unknown module: #1' => 'Unbekanntes Modul #1', 'Unknown problem type.' => 'Unbekannter Problem-Typ', 'Unlock System' => 'System entsperren', 'Unsuccessfully executed:\n' => 'Erfolglos ausgeführt:', @@ -3208,6 +3216,7 @@ $self->{texts} = { 'Update quotation/order' => 'Auftrag/Angebot aktualisieren', 'Update sales order #1' => 'Kundenauftrag #1 aktualisieren', 'Update sales quotation #1' => 'Angebot #1 aktualisieren', + 'Update this draft.' => 'Aktuellen Entwurf speichern', 'Update with section' => 'Mit Abschnitt aktualisieren', 'Updated' => 'Erneuert am', 'Updating existing entry in database' => 'Existierenden Eintrag in Datenbank aktualisieren', @@ -3295,6 +3304,7 @@ $self->{texts} = { 'Warehouses' => 'Lager', 'Warn before saving orders with duplicate parts (new controller only)' => 'Beim Speichern warnen, wenn doppelte Artikel in einem Auftrag sind', 'Warning' => 'Warnung', + 'Warning! Loading a draft will discard unsaved data!' => 'Achtung! Beim Laden eines Entwurfs werden ungespeicherte Daten verworfen!', 'WebDAV' => 'WebDAV', 'WebDAV link' => 'WebDAV-Link', 'WebDAV save documents' => 'Belege in WebDAV-Ablage speichern', diff --git a/templates/webpages/ap/form_footer.html b/templates/webpages/ap/form_footer.html index b7659fc51..14d496629 100644 --- a/templates/webpages/ap/form_footer.html +++ b/templates/webpages/ap/form_footer.html @@ -12,11 +12,6 @@ -[%- IF ( !id && draft_id ) %] - [% L.checkbox_tag('remove_draft', checked=remove_draft, label=LxERP.t8('Remove draft when posting')) %] -
-[%- END %] -
@@ -37,7 +32,7 @@ [%- ELSIF show_post_draft %] - + [% L.button_tag('kivi.Draft.popup("ap", "invoice", "' _ draft_id _ '", "' _ draft_description _ '")', LxERP.t8('Drafts')) %] [%- END %] [%- IF id %] diff --git a/templates/webpages/ar/form_footer.html b/templates/webpages/ar/form_footer.html index 9927cc852..df81ee58c 100644 --- a/templates/webpages/ar/form_footer.html +++ b/templates/webpages/ar/form_footer.html @@ -1,5 +1,6 @@ [% USE LxERP %] [% USE T8 %] +[% USE L %] [% IF ( follow_up_length && follow_up_due_length ) %] [% LxERP.t8('There are #1 unfinished follow-ups of which #2 are due.', follow_up_length , follow_up_due_length) %] @@ -12,13 +13,6 @@
- [% IF ( !id && draft_id ) %] - - - [% END %] - -
- [% IF ( show_storno_button ) %] @@ -41,7 +35,7 @@ [% ELSE %] [% IF ( !is_closed ) %] - + [% L.button_tag('kivi.Draft.popup("ar", "invoice", "' _ draft_id _ '", "' _ draft_description _ '")', LxERP.t8('Drafts')) %] [% END %] [% END %] diff --git a/templates/webpages/drafts/form.html b/templates/webpages/drafts/form.html new file mode 100644 index 000000000..f3cedf8cc --- /dev/null +++ b/templates/webpages/drafts/form.html @@ -0,0 +1,46 @@ +[%- USE T8 %] +[%- USE L %] +[%- USE LxERP %] +[%- USE HTML %] + +[% PROCESS 'common/flash.html' %] + +[%- IF FORM.id %] +

[% 'Update this draft.' | $T8 %]

+[%- ELSE %] +

[% 'Save as a new draft.' | $T8 %]

+[%- END %] + +[% L.hidden_tag('', FORM.id, id='new_draft_id') %] +[% 'Description' | $T8 %]: +[% L.button_tag('kivi.Draft.save("' _ HTML.escape(SELF.module) _ '", "' _ HTML.escape(SELF.submodule) _ '")', LxERP.t8('Save draft')) %] + +[%- IF drafts_list.size %] +

[% 'Load an existing draft' | $T8 %]

+ +

[% 'Warning! Loading a draft will discard unsaved data!' | $T8 %]

+ + + + + + + + +[% FOREACH row = drafts_list %] + + + + + + +[% END %] +
[% 'Date' | $T8 %][% 'Description' | $T8 %][% 'Employee' | $T8 %]
[% row.date | html %] + [%- IF row.id == FORM.id %] + [% row.description | html %] + [%- ELSE %] + [% L.link(SELF.url_for(action='load',id=row.id), row.description) %] + [%- END %] + [% row.employee_name | html %][% L.html_tag('span', LxERP.t8('Delete'), class='cursor-pointer interact', onclick="kivi.Draft.delete('" _ row.id _ "')") %]
+[%- END %] + diff --git a/templates/webpages/drafts/save_new.html b/templates/webpages/drafts/save_new.html deleted file mode 100644 index 3e11d50b5..000000000 --- a/templates/webpages/drafts/save_new.html +++ /dev/null @@ -1,28 +0,0 @@ -[%- USE T8 %] -[%- USE HTML %] -

[% 'Save draft' | $T8 %]

- -
- - - - - - - - - - - - - - - -
[% 'Enter a description for this new draft.' | $T8 %]
- [% 'Description' | $T8 %]: - -
- -
- -
diff --git a/templates/webpages/ir/form_footer.html b/templates/webpages/ir/form_footer.html index e416cf7f6..67a49a5a2 100644 --- a/templates/webpages/ir/form_footer.html +++ b/templates/webpages/ir/form_footer.html @@ -138,7 +138,7 @@ [% UNLESS locked %] [%- END %] - + [% L.button_tag('kivi.Draft.popup("ir", "invoice", "' _ draft_id _ '", "' _ draft_description _ '")', LxERP.t8('Drafts')) %] [% END # id %] [% IF id %] diff --git a/templates/webpages/is/form_footer.html b/templates/webpages/is/form_footer.html index 7262aa407..7980bcac4 100644 --- a/templates/webpages/is/form_footer.html +++ b/templates/webpages/is/form_footer.html @@ -154,6 +154,8 @@

[% print_options %]

+ +
[% IF id %] @@ -187,7 +189,7 @@ - + [% L.button_tag('kivi.Draft.popup("is", "invoice", "' _ draft_id _ '", "' _ draft_description _ '")', LxERP.t8('Drafts')) %] [%- END %] [% END # id %] @@ -202,6 +204,7 @@ [% IF callback %] [% 'back' | $T8 %] [% END %] +
-- 2.20.1