]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Prüfen beim Speichern, ob Dokument geändert wurde.
authorMartin Helmling mh@waldpark.octosoft.eu <martin.helmling@octosoft.eu>
Tue, 31 Mar 2015 08:28:22 +0000 (10:28 +0200)
committerJan Büren <jan@kivitendo-premium.de>
Fri, 9 Oct 2015 14:27:32 +0000 (16:27 +0200)
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

20 files changed:
SL/DO.pm
SL/Form.pm
SL/IC.pm
SL/IR.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/ap.pl
bin/mozilla/ar.pl
bin/mozilla/do.pl
bin/mozilla/ic.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl
locale/de/all
templates/webpages/ap/form_header.html
templates/webpages/ar/form_header.html
templates/webpages/do/form_header.html
templates/webpages/ir/form_header.html
templates/webpages/is/form_header.html
templates/webpages/oe/form_header.html

index 6ea31a9be3a519238c666f9b6d202bb6948c10e5..4cc0f59098d2e4adc2e909268b99bc0a1652f046 100644 (file)
--- 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;
index 45662f3b0cbcbba3b1cf343e951ae6c04e2298d2..81b5370b7f579c60877f6ccc98222a99c385fad9 100644 (file)
@@ -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});
index 36520b97dab608dc199210c50ae4efcba6864fa9..dc86484b39f7050e52ffec23f8194fd091d1ae25 100644 (file)
--- 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
index a1cbb4d87e05fda9764ff522fdc629b2a30762ab..ad28c968b240ce72c4cf894cbaa69572f9e31dfa 100644 (file)
--- 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");
 
index 88c015d48a07ac08669f7c9018a33f91ad7237ab..62ba10e18a30e6b490414392305210d8a4fde1fa 100644 (file)
--- 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");
 
index 9692e48cd86f7494c755a82549ea23cb82ebd627..355ccc793cd3b5259019fc46cf92bf0c03ded91a 100644 (file)
--- 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)
index 1d9eac7d791a6035dc68f3dcb1086e69593f9904..1070c673b43cbf957cb530b4262a35da26f6a7a0 100644 (file)
@@ -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) = @_;
 
index a8bdc566efc2193deca214ed2cde54f7ac582846..28c8efbab54d4f6a9a6d062cd63177e0e5db48c8 100644 (file)
@@ -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
index ede2116e6921c6be45f72ab8fbe91ad6923ef24a..cf210ce5199cf82652c381e8d0f372e6a79d2a94 100644 (file)
@@ -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();
 
index 1489a024d3b5b6dd4ad5d554264d4f7060e90989..332873544425497da46a955c37c1f2b2dde64817 100644 (file)
@@ -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
index f73905d60e4d2cf7decb38728de0eea680e63788..6bcba9bdfae55a19f008cf76e4b9957bbe1702a1 100644 (file)
@@ -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!'));
index 49b0c1e04c14fadfab3ed32ed5e90719a2d165b6..46abc9efdc89faced602a0f3b2f257290e6e5792 100644 (file)
@@ -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!'));
index 97494cfb8347c11f951412e0111e2824c939880f..ad119c477af13ae579c47d92dae8d90cba2fa585 100644 (file)
@@ -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();
index ef380498e3a1250719753ef6002731496dc0d498..b5fd4a6cd4862c4f6144dee79cf1bd1fa44fd275 100755 (executable)
@@ -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.',
index 8720c73408a1d092e2a004c09ff6139351c3c0ee..fdcbefab63324979a199dc53e81a0121dd82e125 100644 (file)
@@ -39,6 +39,7 @@
 <input type="hidden" name="creditremaining" value="[% creditremaining | html %]">
 
 <input type="hidden" name="forex" value="[% forex | html %]">
+<input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
 <input type="hidden" name="id" value="[% id | html %]">
 <input type="hidden" name="sort" value="[% sort | html %]">
index b4cf07cc228ee0b8584c0d863eb6b02c5426883c..2c9870fe24cac5b78f79bb421d405b004b5e9628 100644 (file)
@@ -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) %]
+<input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
 <h1>[% title | html %]</h1>
 
index 60059a2f905e793a856bc581b4b19e0523c2fd4b..1fe72248db5c3b5e1d5602174dd14329a9b20ac9 100644 (file)
   <input type="hidden" name="title" value="[% HTML.escape(title) %]">
   <input type="hidden" name="type" value="[% HTML.escape(type) %]">
   <input type="hidden" name="vc" value="[% HTML.escape(vc) %]">
+  <input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
   <p>
    <table width="100%">
index f22d03eb53c6cb2993eac67c01a30f83c13ba281..866bb8fa5c90ffb5723b5fc906112f0d8a9d616c 100644 (file)
@@ -22,6 +22,7 @@
 <input type="hidden" name="follow_up_trans_type_1" value="sales_invoice">
 <input type="hidden" name="follow_up_trans_info_1" value="[% HTML.escape(follow_up_trans_info) %]">
 <input type="hidden" name="follow_up_rowcount" value="1">
+<input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
 [%- INCLUDE 'common/flash.html' %]
 [%- INCLUDE 'generic/set_longdescription.html' %]
index dd711fc19f4aa9d83ad25ed967fd6acc4a1a2e4e..2ccdf5f31bc751b6e07bb99982c40f1a9caad727 100644 (file)
@@ -19,6 +19,7 @@
 <input type="hidden" name="follow_up_trans_type_1" value="sales_invoice">
 <input type="hidden" name="follow_up_trans_info_1" value="[% HTML.escape(follow_up_trans_info) %]">
 <input type="hidden" name="follow_up_rowcount" value="1">
+<input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
 <h1>[% title %]</h1>
 
index 773c0894ab7ec0806bab546de8f80506357f7178..3d1b30729fef5c4b720ae24d967b13b8350aff08 100644 (file)
@@ -25,6 +25,7 @@
     <input type="hidden" name="follow_up_trans_type_1" value="[% HTML.escape(type) %]">
     <input type="hidden" name="follow_up_trans_info_1" value="[% HTML.escape(follow_up_trans_info) %]">
     <input type="hidden" name="follow_up_rowcount" value="1">
+    <input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
     <h1>[% title %]</h1>