From: Moritz Bunkus Date: Tue, 1 Jul 2008 10:14:17 +0000 (+0000) Subject: 1. Variable umbenannt, in der die IDs aus OE zwischengespeichert werden, aus denen... X-Git-Tag: release-2.6.0beta1~93 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=00738f6f4e43355ae9e70cd5350d7c75c1533f5f;p=kivitendo-erp.git 1. Variable umbenannt, in der die IDs aus OE zwischengespeichert werden, aus denen ein Lieferschein erzeugt wurde. 2. Erweiterung von "RecordLinks->create_links()" um einen Modus, um die IDs aus einem String zu erhalten. 3. Bug: Bei Umwandlung von Auftrag in Lieferschein Variable "delivered" leeren, weil ansonsten evtl der noch nicht gespeicherte Liferschein bereits als ausgelagert gilt. --- diff --git a/SL/DO.pm b/SL/DO.pm index 798d19f72..eea23724f 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -344,12 +344,14 @@ sub save { $form->save_status($dbh); # Link this delivery order to the quotations it was created from. - my @oe_ids = grep { $_ } map { $_ * 1 } split m/\s+/, $form->{oe_ids}; - delete $form->{oe_ids}; - if (scalar @oe_ids) { - my @links = map { { 'from_table' => 'oe', 'from_id' => $_, 'to_table' => 'delivery_orders', 'to_id' => $form->{id} } } @oe_ids; - RecordLinks->create_links('dbh' => $dbh, 'links' => \@links); - } + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'string', + 'from_table' => 'oe', + 'from_ids' => $form->{convert_from_oe_ids}, + 'to_table' => 'delivery_orders', + 'to_id' => $form->{id}, + ); + delete $form->{convert_from_oe_ids}; $self->mark_orders_if_delivered('do_id' => $form->{id}, 'type' => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase', diff --git a/SL/RecordLinks.pm b/SL/RecordLinks.pm index eae903e31..fb451a801 100644 --- a/SL/RecordLinks.pm +++ b/SL/RecordLinks.pm @@ -9,9 +9,34 @@ sub create_links { my $self = shift; my %params = @_; - Common::check_params(\%params, qw(links)); + if ($params{mode} && ($params{mode} eq 'string')) { + Common::check_params_x(\%params, [ qw(from_ids to_ids) ]); - if (!scalar @{ $params{links} }) { + } else { + Common::check_params(\%params, qw(links)); + + } + + my @links; + + if ($params{mode} && ($params{mode} eq 'string')) { + my ($from_to, $to_from) = $params{from_ids} ? qw(from to) : qw(to from); + my %ids = ( $from_to => [ grep { $_ } map { $_ * 1 } split m/\s+/, $params{"${from_to}_ids"} ] ); + + if (my $num = scalar @{ $ids{$from_to} }) { + $main::lxdebug->message(0, "3"); + $ids{$to_from} = [ ($params{"${to_from}_id"}) x $num ]; + @links = map { { 'from_table' => $params{from_table}, + 'from_id' => $ids{from}->[$_], + 'to_table' => $params{to_table}, + 'to_id' => $ids{to}->[$_], } } (0 .. $num - 1); + } + + } else { + @links = @{ $params{links} }; + } + + if (!scalar @links) { $main::lxdebug->leave_sub(); return; } @@ -24,7 +49,7 @@ sub create_links { my $query = qq|INSERT INTO record_links (from_table, from_id, to_table, to_id) VALUES (?, ?, ?, ?)|; my $sth = prepare_query($form, $dbh, $query); - foreach my $link (@{ $params{links} }) { + foreach my $link (@links) { next if ('HASH' ne ref $link); next if (!$link->{from_table} || !$link->{from_id} || !$link->{to_table} || !$link->{to_id}); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 6c2569b6f..a56557d41 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1814,12 +1814,12 @@ sub sales_order { delete($form->{ordnumber}); } - $form->{cp_id} *= 1; - $form->{oe_ids} = $form->{id}; + $form->{cp_id} *= 1; + $form->{convert_from_oe_ids} = $form->{id}; - $form->{title} = $locale->text('Add Sales Order'); - $form->{vc} = "customer"; - $form->{type} = "sales_order"; + $form->{title} = $locale->text('Add Sales Order'); + $form->{vc} = "customer"; + $form->{type} = "sales_order"; &poso; @@ -1883,18 +1883,16 @@ sub delivery_order { require "bin/mozilla/do.pl"; - $form->{cp_id} *= 1; - $form->{oe_ids} = $form->{id}; - $form->{transdate} = $form->current_date(\%myconfig); + $form->{cp_id} *= 1; + $form->{convert_from_oe_ids} = $form->{id}; + $form->{transdate} = $form->current_date(\%myconfig); delete $form->{duedate}; - $form->{closed} = 0; - $form->{old_employee_id} = $form->{employee_id}; $form->{old_salesman_id} = $form->{salesman_id}; # reset - map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal); + delete @{$form}{qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal closed delivered)}; for $i (1 .. $form->{rowcount}) { map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor); diff --git a/templates/webpages/do/form_header_de.html b/templates/webpages/do/form_header_de.html index 80417eec5..e2ea492e2 100644 --- a/templates/webpages/do/form_header_de.html +++ b/templates/webpages/do/form_header_de.html @@ -60,6 +60,7 @@ + @@ -71,7 +72,6 @@ - diff --git a/templates/webpages/do/form_header_master.html b/templates/webpages/do/form_header_master.html index d156e5429..1f7b40d84 100644 --- a/templates/webpages/do/form_header_master.html +++ b/templates/webpages/do/form_header_master.html @@ -60,6 +60,7 @@ + @@ -71,7 +72,6 @@ -