restore_form($form->{SAVED_FORM}, 1) if ($form->{SAVED_FORM});
delete $form->{SAVED_FORM};
- $form->{SAVED_FORM} = save_form(qw(stylesheet login password));
+ $form->{SAVED_FORM} = save_form(qw(login password));
$form->{remove_draft} = 1;
$form->header();
$draft_nextsub = "add" unless ($draft_nextsub);
delete $form->{action};
- my $saved_form = save_form(qw(stylesheet login password));
+ my $saved_form = save_form(qw(login password));
$form->header();
print($form->parse_html_template("drafts/load",
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 %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_description} = $description;
$form->{remove_draft} = 'checked';
}
- # Ich vergesse bei Rechnungsentwürfe das Rechnungsdatum zu ändern. Dadurch entstehen
+ # 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();