From: Moritz Bunkus Date: Fri, 20 Jun 2008 10:12:17 +0000 (+0000) Subject: ------------------------------------------------------------------------ X-Git-Tag: release-2.6.0beta1~124 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3c1ceacd69653915e0b44f1700b198d96681f546;p=kivitendo-erp.git ------------------------------------------------------------------------ r7135 | mbunkus | 2008-06-20 10:56:08 +0200 (Fri, 20 Jun 2008) | 1 line Wenn eine Rechnung aus einem oder mehreren Lieferscheinen erstellt wird, so wird beim Buchen der Rechnung automatisch alle Lieferscheine als geschlossen markiert, aus denen die Rechnung erstellt wurde. ------------------------------------------------------------------------ --- diff --git a/SL/DO.pm b/SL/DO.pm index 44050b89b..c844b83e8 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -342,9 +342,9 @@ sub save { # save printed, emailed, queued $form->save_status($dbh); - $self->close_order_if_delivered('do_id' => $form->{id}, - 'type' => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase', - 'dbh' => $dbh,); + $self->mark_order_if_delivered('do_id' => $form->{id}, + 'type' => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase', + 'dbh' => $dbh,); my $rc = $dbh->commit(); @@ -357,7 +357,7 @@ sub save { return $rc; } -sub close_order_if_delivered { +sub mark_order_if_delivered { $main::lxdebug->enter_sub(); my $self = shift; @@ -434,6 +434,33 @@ sub close_order_if_delivered { $main::lxdebug->leave_sub(); } +sub close_orders { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(ids)); + + if (('ARRAY' ne ref $params{ids}) || !scalar @{ $params{ids} }) { + $main::lxdebug->leave_sub(); + return; + } + + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + + my $query = qq|UPDATE delivery_orders SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar(@{ $params{ids} })) . qq|)|; + + do_query($form, $dbh, $query, map { conv_i($_) } @{ $params{ids} }); + + $dbh->commit() unless ($params{dbh}); + + $main::lxdebug->leave_sub(); +} + sub delete { $main::lxdebug->enter_sub(); diff --git a/SL/IR.pm b/SL/IR.pm index 0da055bbb..b8f22cd31 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -37,6 +37,7 @@ package IR; use SL::AM; use SL::Common; use SL::DBUtils; +use SL::DO; use SL::MoreCommon; use List::Util qw(min); @@ -538,8 +539,13 @@ sub post_invoice { Common::webdav_folder($form) if ($main::webdav); - my $rc = 1; + my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids}; + if (scalar @close_do_ids) { + DO->close_orders('dbh' => $dbh, + 'ids' => \@close_do_ids); + } + my $rc = 1; if (!$provided_dbh) { $rc = $dbh->commit(); $dbh->disconnect(); diff --git a/SL/IS.pm b/SL/IS.pm index 8e2514478..ca43fd8ab 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -40,6 +40,7 @@ use SL::AM; use SL::CVar; use SL::Common; use SL::DBUtils; +use SL::DO; use SL::MoreCommon; use Data::Dumper; @@ -969,6 +970,13 @@ 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) { + DO->close_orders('dbh' => $dbh, + 'ids' => \@close_do_ids); + } + my $rc = 1; if (!$provided_dbh) { $dbh->commit(); diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 9cc026ccf..370411d7d 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -648,6 +648,8 @@ 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->{deliverydate} = $form->{transdate}; $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); @@ -740,6 +742,7 @@ 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); diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index c5f6da63a..d5a36ca44 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -806,7 +806,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 8c61d72da..a6cdff236 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -1192,6 +1192,7 @@ 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|