From: Sven Schöling Date: Fri, 22 Feb 2008 13:57:12 +0000 (+0000) Subject: Weitere, nicht ganz so behutsame Codesaeuberungen. X-Git-Tag: release-2.6.0beta1~218 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d7420ba874019aa197b978a738f89a15bfec08a7;p=kivitendo-erp.git Weitere, nicht ganz so behutsame Codesaeuberungen. --- diff --git a/SL/Form.pm b/SL/Form.pm index a6ce5afc3..ab4d1796b 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -3223,4 +3223,25 @@ sub all_years { $main::lxdebug->leave_sub(); } +sub backup_vars { + $main::lxdebug->enter_sub(); + my $self = shift; + my @vars = @_; + + map { $self->{_VAR_BACKUP}->{$_} = $self->{$_} if $self->{$_} } @vars; + + $main::lxdebug->leave_sub(); +} + +sub restore_vars { + $main::lxdebug->enter_sub(); + + my $self = shift; + my @vars = @_; + + map { $self->{$_} = $self->{_VAR_BACKUP}->{$_} if $self->{_VAR_BACKUP}->{$_} } @vars; + + $main::lxdebug->leave_sub(); +} + 1; diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 95376da61..254d90d5c 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -200,45 +200,27 @@ sub order_links { # if multiple rowcounts (== collective order) then check if the # there were more than one customer (in that case OE::retrieve removes # the content from the field) - if ( $form->{rowcount} && $form->{type} eq 'sales_order' - && defined $form->{customer} && $form->{customer} eq '') { - $form->error($locale->text('Collective Orders only work for orders from one customer!')); - } + $form->error($locale->text('Collective Orders only work for orders from one customer!')) + if $form->{rowcount} && $form->{type} eq 'sales_order' + && defined $form->{customer} && $form->{customer} eq ''); $form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"}; - $payment_id = $form->{payment_id} if $form->{payment_id}; - $language_id = $form->{language_id} if $form->{language_id}; - $taxzone_id = $form->{taxzone_id} if $form->{taxzone_id}; - $salesman_id = $form->{salesman_id} if $editing; - $taxincluded = $form->{taxincluded}; - $cp_id = $form->{cp_id}; - $intnotes = $form->{intnotes}; + $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes)); $form->{shipto} = 1 if $form->{id}; # get customer / vendor IR->get_vendor(\%myconfig, \%$form) if $form->{type} =~ /(purchase_order|request_quotation)/; IS->get_customer(\%myconfig, \%$form) if $form->{type} =~ /sales_(order|quotation)/; - $form->{cp_id} = $cp_id; - $form->{payment_id} = $payment_id if $payment_id; - $form->{language_id} = $language_id if $language_id; - $form->{taxzone_id} = $taxzone_id if $taxzone_id; - $form->{intnotes} = $intnotes if $intnotes; - $form->{taxincluded} = $taxincluded if $form->{id}; - $form->{salesman_id} = $salesman_id if $editing; + $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id)); + $form->restore_vars(qw(taxincluded)) if $form->{id}; + $form->restore_vars(qw(salesman_id)) if $editing; $form->{forex} = $form->{exchangerate}; $form->{employee} = "$form->{employee}--$form->{employee_id}"; - # build vendor/customer drop down - ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} }; - $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - - if (@{ $form->{"all_$form->{vc}"} }) { - map { $_->{name} = $form->quote($_->{name}) } @{ $form->{"all_$form->{vc}"} }; - $form->{ $form->{vc} } = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - $form->{"select$form->{vc}"} = join "\n", map "", @{ $form->{"all_$form->{vc}"} }; - } + # build vendor/customer drop down comatibility... don't ask + $form->{"old$form->{vc}"} = $form->{"select$form->{vc}"} = 1; # departments if (@{ $form->{all_departments} }) { @@ -254,15 +236,14 @@ sub prepare_order { check_oe_access(); - $form->{formname} = $form->{type} unless $form->{formname}; + $form->{formname} ||= $form->{type}; - my $i = 0; foreach $ref (@{ $form->{form_details} }) { - $form->{rowcount} = ++$i; - map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref}; + $form->{rowcount}++; + map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{$ref}; } for my $i (1 .. $form->{rowcount}) { - $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"}; + $form->{"reqdate_$i"} ||= $form->{"deliverydate_$i"}; $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * ($form->{id} ? 100 : 1)); $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});