From: Martin Helmling mh@waldpark.octosoft.eu Date: Tue, 31 Mar 2015 08:28:22 +0000 (+0200) Subject: Prüfen beim Speichern, ob Dokument geändert wurde. X-Git-Tag: release-3.4.1~649 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d735aab3fc2987d555c63ce0dc8e24626ca30654;p=kivitendo-erp.git Prüfen beim Speichern, ob Dokument geändert wurde. Allgemeine Funktion in Forms zum Lesen und Vergleichen der mtime überall Form variable lastmtime da mtime mehrfach auftaucht Conflicts: templates/webpages/ar/form_header.html templates/webpages/do/form_header.html --- diff --git a/SL/DO.pm b/SL/DO.pm index 6ea31a9be..4cc0f5909 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -685,6 +685,7 @@ sub retrieve { dord.closed, dord.reqdate, dord.department_id, dord.cusordnumber, d.description AS department, dord.language_id, dord.shipto_id, + dord.itime,dord.mtime, dord.globalproject_id, dord.delivered, dord.transaction_description, dord.taxzone_id, dord.taxincluded, dord.payment_id, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency, dord.delivery_term_id, dord.itime::DATE AS insertdate @@ -719,7 +720,8 @@ sub retrieve { } } $sth->finish(); - + $form->{mtime} = $form->{itime} if !$form->{mtime}; + $form->{lastmtime} = $form->{mtime}; $form->{donumber_array} =~ s/\s*$//g; $form->{ordnumber_array} =~ s/ //; $form->{ordnumber_array} =~ s/\s*$//g; diff --git a/SL/Form.pm b/SL/Form.pm index 45662f3b0..81b5370b7 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2603,6 +2603,24 @@ sub all_vc { $main::lxdebug->leave_sub(); } +sub mtime_ischanged { + my ($self, $relation,$option) = @_; + #$main::lxdebug->message(LXDebug->DEBUG2(),"mtime_ischanged from rel=".$relation." id=".$id); + if ( ! $self->{id} ) { return ; } + + my $query = "SELECT mtime, itime FROM ".$relation." WHERE id = ?"; + my $ref = selectfirst_hashref_query($self, $self->get_standard_dbh, $query, $self->{id}); + $ref->{mtime} = $ref->{itime} if !$ref->{mtime}; + #$main::lxdebug->message(LXDebug->DEBUG2(),"my mtime=".$self->{lastmtime}." new mtime=".$ref->{mtime}); + if ($self->{lastmtime} && $self->{lastmtime} ne $ref->{mtime} ) { + my $etxt = $main::locale->text("The document has been changed from other user. Please reopen it in another window and copy the changes to the new window"); + $etxt = $main::locale->text("The document has been changed from other user. No mail was sent. Please reopen it in another window and copy the changes to the new window") + if defined $option && $option eq 'mail'; + $self->error($main::locale->text($etxt)); + ::end_of_request(); + } +} + sub language_payment { $main::lxdebug->enter_sub(); @@ -2754,6 +2772,7 @@ sub create_links { qq|SELECT a.cp_id, a.invnumber, a.transdate, a.${table}_id, a.datepaid, a.duedate, a.ordnumber, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.notes, + a.mtime,a.itime, a.intnotes, a.department_id, a.amount AS oldinvtotal, a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type, a.globalproject_id, ${extra_columns} @@ -2770,7 +2789,8 @@ sub create_links { foreach my $key (keys %$ref) { $self->{$key} = $ref->{$key}; } - + $self->{mtime} = $self->{itime} if ! $self->{mtime}; + $self->{lastmtime} = $self->{mtime}; my $transdate = "current_date"; if ($self->{transdate}) { $transdate = $dbh->quote($self->{transdate}); diff --git a/SL/IC.pm b/SL/IC.pm index 36520b97d..dc86484b3 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -72,6 +72,8 @@ sub get_part { # copy to $form variables map { $form->{$_} = $ref->{$_} } (keys %{$ref}); + $form->{mtime} = $form->{itime} if !$form->{mtime}; + $form->{lastmtime} = $form->{mtime}; $form->{onhand} *= 1; # part or service item diff --git a/SL/IR.pm b/SL/IR.pm index a1cbb4d87..ad28c968b 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -984,12 +984,15 @@ sub retrieve_invoice { $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, orddate, quodate, globalproject_id, ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, + mtime, itime, intnotes, (SELECT cu.name FROM currencies cu WHERE cu.id=ap.currency_id) AS currency, direct_debit, delivery_term_id FROM ap WHERE id = ?|; $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); map { $form->{$_} = $ref->{$_} } keys %$ref; + $form->{mtime} = $form->{itime} if !$form->{mtime}; + $form->{lastmtime} = $form->{mtime}; $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell"); diff --git a/SL/IS.pm b/SL/IS.pm index 88c015d48..62ba10e18 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1892,6 +1892,7 @@ sub retrieve_invoice { a.shippingpoint, a.shipvia, a.notes, a.intnotes, a.taxzone_id, a.duedate, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.shipto_id, a.cp_id, a.employee_id, a.salesman_id, a.payment_id, + a.mtime, a.itime, a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type, a.transaction_description, a.donumber, a.invnumber_for_credit_note, a.marge_total, a.marge_percent, a.direct_debit, a.delivery_term_id, @@ -1903,6 +1904,8 @@ sub retrieve_invoice { WHERE a.id = ?|; $ref = selectfirst_hashref_query($form, $dbh, $query, $id); map { $form->{$_} = $ref->{$_} } keys %{ $ref }; + $form->{mtime} = $form->{itime} if !$form->{mtime}; + $form->{lastmtime} = $form->{mtime}; $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy"); diff --git a/SL/OE.pm b/SL/OE.pm index 9692e48cd..355ccc793 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -919,6 +919,7 @@ sub retrieve { (SELECT cu.name FROM currencies cu WHERE cu.id=o.currency_id) AS currency, e.name AS employee, o.employee_id, o.salesman_id, o.${vc}_id, cv.name AS ${vc}, o.amount AS invtotal, o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber, + o.mtime, o.itime, d.description AS department, o.payment_id, o.language_id, o.taxzone_id, o.delivery_customer_id, o.delivery_vendor_id, o.proforma, o.shipto_id, o.globalproject_id, o.delivered, o.transaction_description, o.delivery_term_id, @@ -946,6 +947,8 @@ sub retrieve { map { $form->{$_} = '' if ($ref->{$_} ne $form->{$_}) } keys %$ref; } } + $form->{mtime} = $form->{itime} if ! $form->{mtime}; + $form->{lastmtime} = $form->{mtime}; # if not given, fill transdate with current_date $form->{transdate} = $form->current_date($myconfig) diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 1d9eac7d7..1070c673b 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -584,6 +584,7 @@ sub post_payment { my $locale = $main::locale; $main::auth->assert('general_ledger'); + $form->mtime_ischanged('ap'); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -632,6 +633,7 @@ sub post { my $locale = $main::locale; $main::auth->assert('general_ledger'); + $form->mtime_ischanged('ap'); my ($inline) = @_; diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index a8bdc566e..28c8efbab 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -616,6 +616,7 @@ sub post_payment { my %myconfig = %main::myconfig; my $locale = $main::locale; + $form->mtime_ischanged('ar'); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); my $invdate = $form->datetonum($form->{transdate}, \%myconfig); @@ -672,6 +673,8 @@ sub post { my ($inline) = @_; + $form->mtime_ischanged('ar'); + my ($datepaid); # check if there is an invoice number, invoice and due date diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index ede2116e6..cf210ce51 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -708,6 +708,8 @@ sub save { my %myconfig = %main::myconfig; my $locale = $main::locale; + $form->mtime_ischanged('delivery_orders'); + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); $form->isblank("transdate", $locale->text('Delivery Order Date missing!')); @@ -785,6 +787,8 @@ sub invoice { my $locale = $main::locale; check_do_access(); + $form->mtime_ischanged('delivery_orders'); + $main::auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit'); $form->{convert_from_do_ids} = $form->{id}; @@ -1010,9 +1014,9 @@ sub e_mail { check_do_access(); - my $form = $main::form; + $::form->mtime_ischanged('delivery_orders','mail'); - $form->{print_and_save} = 1; + $::form->{print_and_save} = 1; my $saved_form = save_form(); diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 1489a024d..332873544 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1883,7 +1883,7 @@ sub save { $lxdebug->enter_sub(); $auth->assert('part_service_assembly_edit'); - + $::form->mtime_ischanged('parts'); my ($parts_id, %newform, $amount, $callback); # check if there is a part number - commented out, cause there is an automatic allocation of numbers diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index f73905d60..6bcba9bdf 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -672,6 +672,7 @@ sub post_payment { $main::auth->assert('vendor_invoice_edit'); + $form->mtime_ischanged('ap') ; $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); for my $i (1 .. $form->{paidaccounts}) { if ($form->{"paid_$i"}) { @@ -731,6 +732,7 @@ sub post { $main::auth->assert('vendor_invoice_edit'); + $form->mtime_ischanged('ap'); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); $form->isblank("invdate", $locale->text('Invoice Date missing!')); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 49b0c1e04..46abc9efd 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -682,6 +682,7 @@ sub post_payment { $main::auth->assert('invoice_edit'); + $form->mtime_ischanged('ar') ; my $invdate = $form->datetonum($form->{invdate}, \%myconfig); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -737,6 +738,7 @@ sub post { my $locale = $main::locale; $main::auth->assert('invoice_edit'); + $form->mtime_ischanged('ar'); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); $form->isblank("invdate", $locale->text('Invoice Date missing!')); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 97494cfb8..ad119c477 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1147,6 +1147,7 @@ sub save_and_close { my $locale = $main::locale; check_oe_access(); + $form->mtime_ischanged('oe'); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -1253,6 +1254,7 @@ sub save { check_oe_access(); + $form->mtime_ischanged('oe'); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -1404,6 +1406,8 @@ sub invoice { check_oe_access(); check_oe_conversion_to_sales_invoice_allowed(); + $form->mtime_ischanged('oe'); + $main::auth->assert($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation' ? 'vendor_invoice_edit' : 'invoice_edit'); $form->{old_salesman_id} = $form->{salesman_id}; @@ -1751,6 +1755,8 @@ sub purchase_order { my $locale = $main::locale; check_oe_access(); + $form->mtime_ischanged('oe'); + $main::auth->assert('purchase_order_edit'); $form->{sales_order_to_purchase_order} = 0; @@ -1788,6 +1794,8 @@ sub sales_order { my $locale = $main::locale; check_oe_access(); + + $form->mtime_ischanged('oe'); $main::auth->assert('sales_order_edit'); if ($form->{type} eq "purchase_order") { @@ -1878,6 +1886,8 @@ sub delivery_order { my $form = $main::form; my %myconfig = %main::myconfig; + $form->mtime_ischanged('oe'); + if ($form->{type} =~ /^sales/) { $main::auth->assert('sales_delivery_order_edit'); @@ -1934,9 +1944,11 @@ sub e_mail { $main::lxdebug->enter_sub(); my $form = $main::form; + my $locale = $main::locale; check_oe_access(); + $form->mtime_ischanged('oe','mail'); $form->{print_and_save} = 1; my $saved_form = save_form(); diff --git a/locale/de/all b/locale/de/all index ef380498e..b5fd4a6cd 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2726,6 +2726,8 @@ $self->{texts} = { 'The discount must be less than 100%.' => 'Der Rabatt muss kleiner als 100% sein.', 'The discount must not be negative.' => 'Der Rabatt darf nicht negativ sein.', 'The discounted amount will be shown in documents.' => 'Der Rabattbetrag wird in Belegen ausgewiesen.', + 'The document has been changed from other user. No mail was sent. Please reopen it in another window and copy the changes to the new window' => 'Die Daten wurden bereits von einem anderen Benutzer verändert. Deshalb ist das Dokument ungültig und es wurde keine E-Mail verschickt. Bitte öffnen Sie das Dokument erneut in einem extra Fenster und übertragen Sie die Daten', + 'The document has been changed from other user. Please reopen it in another window and copy the changes to the new window' => 'Die Daten wurden bereits von einem anderen Benutzer verändert. Deshalb ist das Dokument ungültig. Bitte öffnen Sie das Dokument erneut in einem extra Fenster und übertragen Sie die Daten', 'The document have been sent to \'#1\'.' => 'Das Dokument wurde an \'#1\' geschickt.', 'The documents have been sent to the printer \'#1\'.' => 'Die Dokumente wurden an den Drucker \'#1\' geschickt.', 'The dunning process started' => 'Der Mahnprozess ist gestartet.', diff --git a/templates/webpages/ap/form_header.html b/templates/webpages/ap/form_header.html index 8720c7340..fdcbefab6 100644 --- a/templates/webpages/ap/form_header.html +++ b/templates/webpages/ap/form_header.html @@ -39,6 +39,7 @@ + diff --git a/templates/webpages/ar/form_header.html b/templates/webpages/ar/form_header.html index b4cf07cc2..2c9870fe2 100644 --- a/templates/webpages/ar/form_header.html +++ b/templates/webpages/ar/form_header.html @@ -14,6 +14,7 @@ [% L.hidden_tag('follow_up_trans_type_1', 'ar_transaction') %] [% L.hidden_tag('follow_up_trans_info_1', follow_up_trans_info) %] [% L.hidden_tag('follow_up_rowcount', 1) %] +

[% title | html %]

diff --git a/templates/webpages/do/form_header.html b/templates/webpages/do/form_header.html index 60059a2f9..1fe72248d 100644 --- a/templates/webpages/do/form_header.html +++ b/templates/webpages/do/form_header.html @@ -109,6 +109,7 @@ +

diff --git a/templates/webpages/ir/form_header.html b/templates/webpages/ir/form_header.html index f22d03eb5..866bb8fa5 100644 --- a/templates/webpages/ir/form_header.html +++ b/templates/webpages/ir/form_header.html @@ -22,6 +22,7 @@ + [%- INCLUDE 'common/flash.html' %] [%- INCLUDE 'generic/set_longdescription.html' %] diff --git a/templates/webpages/is/form_header.html b/templates/webpages/is/form_header.html index dd711fc19..2ccdf5f31 100644 --- a/templates/webpages/is/form_header.html +++ b/templates/webpages/is/form_header.html @@ -19,6 +19,7 @@ +

[% title %]

diff --git a/templates/webpages/oe/form_header.html b/templates/webpages/oe/form_header.html index 773c0894a..3d1b30729 100644 --- a/templates/webpages/oe/form_header.html +++ b/templates/webpages/oe/form_header.html @@ -25,6 +25,7 @@ +

[% title %]