From: Moritz Bunkus Date: Tue, 1 Jul 2008 12:25:50 +0000 (+0000) Subject: Beim Umwandeln von Angeboten/Preisanfragen in Aufträge die IDs in record_links speich... X-Git-Tag: release-2.6.0beta1~92 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=94e11003809e9090514026a733e58e72e636a6bb;p=kivitendo-erp.git Beim Umwandeln von Angeboten/Preisanfragen in Aufträge die IDs in record_links speichern. Beim Umwandeln von Aufträgen und Lieferscheinen in Rechnungen die IDs in record_links speichern. --- diff --git a/SL/DO.pm b/SL/DO.pm index eea23724f..3f623ec6d 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -345,7 +345,7 @@ sub save { # Link this delivery order to the quotations it was created from. RecordLinks->create_links('dbh' => $dbh, - 'mode' => 'string', + 'mode' => 'ids', 'from_table' => 'oe', 'from_ids' => $form->{convert_from_oe_ids}, 'to_table' => 'delivery_orders', diff --git a/SL/IR.pm b/SL/IR.pm index b8f22cd31..f3c2674b0 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -539,10 +539,28 @@ sub post_invoice { Common::webdav_folder($form) if ($main::webdav); - my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids}; - if (scalar @close_do_ids) { + # Link this record to the records it was created from. + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => 'oe', + 'from_ids' => $form->{convert_from_oe_ids}, + 'to_table' => 'ap', + 'to_id' => $form->{id}, + ); + delete $form->{convert_from_oe_ids}; + + my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids}; + if (scalar @convert_from_do_ids) { DO->close_orders('dbh' => $dbh, - 'ids' => \@close_do_ids); + 'ids' => \@convert_from_do_ids); + + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => 'delivery_orders', + 'from_ids' => \@convert_from_do_ids, + 'to_table' => 'ap', + 'to_id' => $form->{id}, + ); } my $rc = 1; diff --git a/SL/IS.pm b/SL/IS.pm index ca43fd8ab..c4e2a7fbd 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -970,11 +970,29 @@ sub post_invoice { Common::webdav_folder($form) if ($main::webdav); - my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids}; - - if (scalar @close_do_ids) { + # Link this record to the records it was created from. + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => 'oe', + 'from_ids' => $form->{convert_from_oe_ids}, + 'to_table' => 'ar', + 'to_id' => $form->{id}, + ); + delete $form->{convert_from_oe_ids}; + + my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids}; + + if (scalar @convert_from_do_ids) { DO->close_orders('dbh' => $dbh, - 'ids' => \@close_do_ids); + 'ids' => \@convert_from_do_ids); + + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => 'delivery_orders', + 'from_ids' => \@convert_from_do_ids, + 'to_table' => 'ar', + 'to_id' => $form->{id}, + ); } my $rc = 1; diff --git a/SL/OE.pm b/SL/OE.pm index e279e4a65..3dd83b768 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -465,6 +465,16 @@ sub save { # save printed, emailed, queued $form->save_status($dbh); + # Link this record to the records it was created from. + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => 'oe', + 'from_ids' => $form->{convert_from_oe_ids}, + 'to_table' => 'oe', + 'to_id' => $form->{id}, + ); + delete $form->{convert_from_oe_ids}; + if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) { if ($form->{vc} eq 'customer') { $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0); @@ -600,6 +610,10 @@ sub retrieve { if ($form->{"multi_id_$_"} and $form->{"trans_id_$_"}) } (1 .. $form->{"rowcount"}); + if ($form->{rowcount} && scalar @ids) { + $form->{convert_from_oe_ids} = join ' ', @ids; + } + # if called in multi id mode, and still only got one id, switch back to single id if ($form->{"rowcount"} and $#ids == 0) { $form->{"id"} = $ids[0]; diff --git a/SL/RecordLinks.pm b/SL/RecordLinks.pm index fb451a801..8dfbac61e 100644 --- a/SL/RecordLinks.pm +++ b/SL/RecordLinks.pm @@ -9,7 +9,7 @@ sub create_links { my $self = shift; my %params = @_; - if ($params{mode} && ($params{mode} eq 'string')) { + if ($params{mode} && ($params{mode} eq 'ids')) { Common::check_params_x(\%params, [ qw(from_ids to_ids) ]); } else { @@ -19,9 +19,15 @@ sub create_links { my @links; - if ($params{mode} && ($params{mode} eq 'string')) { + if ($params{mode} && ($params{mode} eq 'ids')) { 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"} ] ); + my %ids; + + if ('ARRAY' eq ref $params{"${from_to}_ids"}) { + $ids{$from_to} = $params{"${from_to}_ids"}; + } else { + $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"); diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 228b8e68d..c88f3b0ec 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -648,17 +648,15 @@ sub invoice { check_do_access(); $auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit'); - $form->{close_do_ids} = $form->{id}; + $form->{convert_from_do_ids} = $form->{id}; + $form->{deliverydate} = $form->{transdate}; + $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); + $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->{deliverydate} = $form->{transdate}; - $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); - $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); - - $form->{id} = ''; - $form->{closed} = 0; $form->{rowcount}--; - $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + delete @{$form}{qw(id closed delivered)}; if ($form->{type} eq 'purchase_delivery_order') { $form->{title} = $locale->text('Add Vendor Invoice'); @@ -742,13 +740,13 @@ sub invoice_multi { 'back_button' => 1); } - $form->{close_do_ids} = join ' ', @do_ids; - $form->{deliverydate} = $form->{transdate}; - $form->{transdate} = $form->current_date(\%myconfig); - $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); - $form->{type} = "invoice"; - $form->{closed} = 0; - $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + $form->{convert_from_do_ids} = join ' ', @do_ids; + $form->{deliverydate} = $form->{transdate}; + $form->{transdate} = $form->current_date(\%myconfig); + $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{type} = "invoice"; + $form->{closed} = 0; + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); my $buysell; if ($form->{type} eq 'purchase_delivery_order') { diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index d5a36ca44..ce28fff92 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -424,7 +424,8 @@ sub form_header { $form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id max_dunning_level dunning_amount vendor_id oldvendor selectvendor taxaccounts - fxgain_accno fxloss_accno taxpart taxservice cursor_fokus), + fxgain_accno fxloss_accno taxpart taxservice cursor_fokus + convert_from_oe_ids convert_from_do_ids), map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} ); print qq|

$form->{saved_message}

| if $form->{saved_message}; @@ -806,7 +807,7 @@ sub form_footer {
-| . $cgi->hidden('-name' => 'close_do_ids', '-default' => [$form->{close_do_ids}]); +|; $invdate = $form->datetonum($form->{invdate}, \%myconfig); $closedto = $form->datetonum($form->{closedto}, \%myconfig); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index a6cdff236..933602fa1 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -614,7 +614,8 @@ sub form_header { creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax - shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus), + shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus + convert_from_do_ids convert_from_oe_ids), map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} ); print qq|

$form->{saved_message}

| if $form->{saved_message}; @@ -1192,7 +1193,6 @@ if ($form->{type} eq "credit_note") { $cgi->hidden("-name" => "callback", "-value" => $form->{callback}) . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]) -. $cgi->hidden('-name' => 'close_do_ids', '-default' => [$form->{close_do_ids}]) . qq| diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index a56557d41..bc4cc453a 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -234,7 +234,9 @@ sub order_links { $form->{"select$form->{vc}"} = 1; $form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; } - $form->{"old$form->{vc}"} = $form->{$form->{vc}}; + + $form->{"old$form->{vc}"} = $form->{$form->{vc}}; + $form->{"old$form->{vc}"} .= qq|--$form->{"$form->{vc}_id"}| unless ($form->{"old$form->{vc}"} =~ m/--\d+$/); $lxdebug->leave_sub(); } @@ -1455,15 +1457,14 @@ sub invoice { OE->close_orders(\%myconfig, \%$form); } - $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); - $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{convert_from_oe_ids} = $form->{id}; + $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); + $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{shipto} = 1; + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->{id} = ''; - $form->{closed} = 0; + delete @{$form}{qw(id closed)}; $form->{rowcount}--; - $form->{shipto} = 1; - - $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); if ($form->{type} =~ /_order$/) { $form->{exchangerate} = $exchangerate; @@ -1814,12 +1815,11 @@ sub sales_order { delete($form->{ordnumber}); } - $form->{cp_id} *= 1; - $form->{convert_from_oe_ids} = $form->{id}; + $form->{cp_id} *= 1; - $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; @@ -1835,13 +1835,14 @@ sub poso { $form->{transdate} = $form->current_date(\%myconfig); delete $form->{duedate}; - $form->{closed} = 0; + $form->{convert_from_oe_ids} = $form->{id}; + $form->{closed} = 0; - $form->{old_employee_id} = $form->{employee_id}; - $form->{old_salesman_id} = $form->{salesman_id}; + $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 customer vendor creditlimit creditremaining discount tradediscount oldinvtotal); + map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal 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/oe/form_header_de.html b/templates/webpages/oe/form_header_de.html index c09c8f0b5..064908abc 100644 --- a/templates/webpages/oe/form_header_de.html +++ b/templates/webpages/oe/form_header_de.html @@ -15,6 +15,8 @@ [%- END %] + + diff --git a/templates/webpages/oe/form_header_master.html b/templates/webpages/oe/form_header_master.html index 939915df3..6521c6f84 100644 --- a/templates/webpages/oe/form_header_master.html +++ b/templates/webpages/oe/form_header_master.html @@ -15,6 +15,8 @@ [%- END %] + +