From 8c1d5d7530f3a1c923ee470b7ff31616800a8574 Mon Sep 17 00:00:00 2001 From: "Martin Helmling mh@waldpark.octosoft.eu" Date: Mon, 29 Feb 2016 10:17:12 +0100 Subject: [PATCH] =?utf8?q?4.=20=C3=9Cberarbeitung=20Pr=C3=BCfen=20beim=20S?= =?utf8?q?peichern,=20ob=20Dokument=20ge=C3=A4ndert=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit An einigen Stellen wird nach dem Speichern nicht neu gelesen, sondern die alten Forms-Variablen zum Aufbau der Webseite verwendet, z.B. "Auslagern". Deshalb wird $form->lastmtime nun nach jedem Speichern aktualisiert. --- SL/AP.pm | 7 +++++++ SL/AR.pm | 6 ++++++ SL/DO.pm | 3 +++ SL/Form.pm | 13 +++++++++++++ SL/IC.pm | 4 ++++ SL/IR.pm | 3 ++- SL/IS.pm | 4 ++++ SL/OE.pm | 2 ++ 8 files changed, 41 insertions(+), 1 deletion(-) diff --git a/SL/AP.pm b/SL/AP.pm index f551b34ae..7db5649f6 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -148,6 +148,8 @@ sub post_transaction { $form->{id}); do_query($form, $dbh, $query, @values); + $form->new_lastmtime('ap'); + # add individual transactions for my $i (1 .. $form->{rowcount}) { if ($form->{"amount_$i"} != 0) { @@ -349,6 +351,7 @@ sub post_transaction { if ($payments_only) { $query = qq|UPDATE ap SET paid = ?, datepaid = ? WHERE id = ?|; do_query($form, $dbh, $query, $form->{invpaid}, $form->{invpaid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); + $form->new_lastmtime('ap'); } IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh); @@ -808,6 +811,8 @@ sub storno { $query = qq|UPDATE ap SET paid = amount + paid, storno = 't' WHERE id = ?|; do_query($form, $dbh, $query, $id); + $form->new_lastmtime('ap') if $id == $form->{id}; + # now copy acc_trans entries $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.acc_trans_id|; my $rowref = selectall_hashref_query($form, $dbh, $query, $id); @@ -827,6 +832,8 @@ sub storno { map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id); + $form->new_lastmtime('ap') if $storno_id == $form->{id}; + $dbh->commit; $main::lxdebug->leave_sub(); diff --git a/SL/AR.pm b/SL/AR.pm index 284174396..3362c2e42 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -183,6 +183,8 @@ sub post_transaction { do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); } + $form->new_lastmtime('ar'); + # add paid transactions for my $i (1 .. $form->{paidaccounts}) { @@ -770,6 +772,8 @@ sub storno { $query = qq|UPDATE ar SET paid = amount + paid, storno = 't' WHERE id = ?|; do_query($form, $dbh, $query, $id); + $form->new_lastmtime('ar') if $id == $form->{id}; + # now copy acc_trans entries $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.acc_trans_id|; my $rowref = selectall_hashref_query($form, $dbh, $query, $id); @@ -789,6 +793,8 @@ sub storno { map { IO->set_datepaid(table => 'ar', id => $_, dbh => $dbh) } ($id, $new_id); + $form->new_lastmtime('ar') if $storno_id == $form->{id}; + $dbh->commit; $main::lxdebug->leave_sub(); diff --git a/SL/DO.pm b/SL/DO.pm index 7db091011..3ab2ffa6a 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -477,6 +477,8 @@ SQL conv_i($form->{id})); do_query($form, $dbh, $query, @values); + $form->new_lastmtime('delivery_orders'); + $form->{name} = $form->{ $form->{vc} }; $form->{name} =~ s/--$form->{"$form->{vc}_id"}//; @@ -605,6 +607,7 @@ sub close_orders { do_query($form, $dbh, $query, map { conv_i($_) } @{ $params{ids} }); $dbh->commit() unless ($params{dbh}); + $form->new_lastmtime('delivery_orders'); $main::lxdebug->leave_sub(); } diff --git a/SL/Form.pm b/SL/Form.pm index 610f545eb..cc9881413 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2590,6 +2590,19 @@ sub all_vc { $main::lxdebug->leave_sub(); } +sub new_lastmtime { + my ($self, $table, $option) = @_; + + return unless $self->{id}; + croak ("wrong call, no valid table defined") unless $table =~ /^(oe|ar|ap|delivery_orders|parts)$/; + + my $query = "SELECT mtime, itime FROM " . $table . " WHERE id = ?"; + my $ref = selectfirst_hashref_query($self, $self->get_standard_dbh, $query, $self->{id}); + $ref->{mtime} ||= $ref->{itime}; + $self->{lastmtime} = $ref->{mtime}; + $main::lxdebug->message(LXDebug->DEBUG2(),"new lastmtime=".$self->{lastmtime}); +} + sub mtime_ischanged { my ($self, $table, $option) = @_; diff --git a/SL/IC.pm b/SL/IC.pm index 45604b0c9..d4b341340 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -399,6 +399,8 @@ sub save { ); do_query($form, $dbh, $query, @values); + $form->new_lastmtime('parts'); + # delete translation records do_query($form, $dbh, qq|DELETE FROM translation WHERE parts_id = ?|, conv_i($form->{id})); @@ -570,6 +572,8 @@ sub update_assembly { $qty * ($form->{weight} - $weight), conv_i($id)); do_query($form, $dbh, $query, @values); + $form->new_lastmtime('parts') if $id == $form->{id}; + $main::lxdebug->leave_sub(); } diff --git a/SL/IR.pm b/SL/IR.pm index e2f65753c..ae3e45b09 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -690,7 +690,7 @@ SQL if ($payments_only) { $query = qq|UPDATE ap SET paid = ? WHERE id = ?|; do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); - + $form->new_lastmtime('ap'); if (!$provided_dbh) { $dbh->commit(); $dbh->disconnect(); @@ -745,6 +745,7 @@ SQL do_query($form, $dbh, $query, conv_i($form->{id})); } + $form->new_lastmtime('ap'); $form->{name} = $form->{vendor}; $form->{name} =~ s/--\Q$form->{vendor_id}\E//; diff --git a/SL/IS.pm b/SL/IS.pm index 6e9e96012..7d6413094 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1244,6 +1244,8 @@ SQL $query = qq|UPDATE ar SET paid = ? WHERE id = ?|; do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); + $form->new_lastmtime('ar'); + $dbh->commit if !$provided_dbh; $main::lxdebug->leave_sub(); @@ -1299,6 +1301,8 @@ SQL do_query($form, $dbh, qq|UPDATE ar SET paid = amount WHERE id = ?|, conv_i($form->{"id"})); } + $form->new_lastmtime('ar'); + $form->{name} = $form->{customer}; $form->{name} =~ s/--\Q$form->{customer_id}\E//; diff --git a/SL/OE.pm b/SL/OE.pm index f192c1d10..459944318 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -696,6 +696,8 @@ SQL conv_i($form->{id})); do_query($form, $dbh, $query, @values); + $form->new_lastmtime('oe'); + $form->{ordtotal} = $amount; $form->{name} = $form->{ $form->{vc} }; -- 2.20.1