commit 1112515fa3c90232a738ee739765d4ae97258f7d
Author: Werner Hahn <wh@futureworldsearch.net>
Date:   Wed Jul 31 15:07:36 2024 +0200

    S:C:DeliveryOrder: Methode zum Schließen "Als geschlossen markieren"
    
        behebt #702
        behebt #694

diff --git a/SL/Controller/DeliveryOrder.pm b/SL/Controller/DeliveryOrder.pm
index 8a6298a84..4931ef57c 100644
--- a/SL/Controller/DeliveryOrder.pm
+++ b/SL/Controller/DeliveryOrder.pm
@@ -271,6 +271,24 @@ sub action_save_as_new {
   $self->action_save();
 }
 
+# close a already saved order (potentially already delivered)
+sub action_close_order {
+  my ($self) = @_;
+
+  $self->order->update_attributes(
+    closed => 1
+  );
+
+  $self->js
+    ->flash("info", t8("The record has been closed."))
+    ->run('kivi.ActionBar.setDisabled', '#save_action',
+          t8('This record has already been closed.'))
+    ->run('kivi.ActionBar.setDisabled', '#save_and_close',
+          t8('This record has already been closed.'))
+    ->html('#data-status-line', delivery_order_status_line($self->order))
+    ->render
+}
+
 # print the order
 #
 # This is called if "print" is pressed in the print dialog.
@@ -1946,9 +1964,10 @@ sub setup_edit_action_bar {
               warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts,
               warn_on_reqdate    => $::instance_conf->get_order_warn_no_deliverydate,
             }],
-          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.')
+          disabled => !$may_edit_create       ? t8('You do not have the permissions to access this function.')
                     : $self->order->delivered ? t8('This record has already been delivered.')
-                    :                        undef,
+                    : $self->order->closed    ? t8('This record has already been closed.')
+                    :                           undef,
         ],
         action => [
           t8('Save and Close'),
@@ -1961,8 +1980,19 @@ sub setup_edit_action_bar {
                 { name => 'back_to_caller', value => 1 },
               ],
             }],
-          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.')
+          disabled => !$may_edit_create       ? t8('You do not have the permissions to access this function.')
                     : $self->order->delivered ? t8('This record has already been delivered.')
+                    : $self->order->closed    ? t8('This record has already been closed.')
+                    :                           undef,
+        ],
+        action => [
+          t8('Mark as closed'),
+          id       => 'close_order',
+          call     => [ 'kivi.DeliveryOrder.close_order' ],
+          confirm  => t8('This will remove the delivery order from showing as open even if contents are not delivered. Proceed?'),
+          disabled => !$may_edit_create    ? t8('You do not have the permissions to access this function.')
+                    : !$self->order->id    ? t8('This object has not been saved yet.')
+                    : $self->order->closed ? t8('This record has already been closed.')
                     :                        undef,
         ],
         action => [
diff --git a/js/kivi.DeliveryOrder.js b/js/kivi.DeliveryOrder.js
index 76a0e322e..ee98ad4b4 100644
--- a/js/kivi.DeliveryOrder.js
+++ b/js/kivi.DeliveryOrder.js
@@ -79,6 +79,20 @@ namespace('kivi.DeliveryOrder', function(ns) {
     $.post("controller.pl", data, kivi.eval_json_result);
   };
 
+  ns.close_order = function() {
+    let data = [];
+    let id = $("#id").val();
+
+    if (!id) {
+      alert(kivi.t8('This object has not been saved yet.'));
+      return;
+    }
+
+    data.push({ name: 'id', value: id });
+    data.push({ name: 'action', value: 'DeliveryOrder/close_order' });
+    $.post("controller.pl", data, kivi.eval_json_result);
+  }
+
   ns.show_print_options = function(params) {
     if (!ns.check_cv()) return;
 
diff --git a/js/locale/de.js b/js/locale/de.js
index b0d9c5046..da74b4a10 100644
--- a/js/locale/de.js
+++ b/js/locale/de.js
@@ -185,6 +185,7 @@ namespace("kivi").setupLocale({
 "There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?":"Einige der Lagerbewegungen sind nicht vollständig und Lagerbewegungen können nachträglich nicht mehr verändert werden. Möchten Sie wirklich fortfahren?",
 "There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.":"Es gibt einen oder mehrere Abschnitte ohne Artikelzuweisung; daher kann der neue Beleg noch nicht erstellt werden.",
 "This field must not be empty.":"Dieses Feld darf nicht leer sein.",
+"This object has not been saved yet.":"Das Objekt wurde noch nicht gespeichert.",
 "This sales order has an active configuration for periodic invoices. If you save then all subsequently created invoices will contain those changes as well, but not those that have already been created. Do you want to continue?":"Dieser Auftrag besitzt eine aktive Konfiguration für wiederkehrende Rechnungen. Wenn Sie jetzt speichern, so werden alle zukünftig hieraus erzeugten Rechnungen die Änderungen enthalten, nicht aber die bereits erzeugten Rechnungen. Möchten Sie speichern?",
 "This vendor has already a booking with this invoice number, do you really want to add the same invoice number again?":"Es gibt für diesen Lieferant schon einen Beleg mit dieser Rechnungsnummer. Möchten Sie wirklich eine weitere Buchung mit derselben Rechnungsnummer hinzufügen?",
 "Thu":"Do",
diff --git a/js/locale/en.js b/js/locale/en.js
index 0d7e746dc..c54db7046 100644
--- a/js/locale/en.js
+++ b/js/locale/en.js
@@ -185,6 +185,7 @@ namespace("kivi").setupLocale({
 "There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?":"",
 "There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.":"",
 "This field must not be empty.":"",
+"This object has not been saved yet.":"",
 "This sales order has an active configuration for periodic invoices. If you save then all subsequently created invoices will contain those changes as well, but not those that have already been created. Do you want to continue?":"",
 "This vendor has already a booking with this invoice number, do you really want to add the same invoice number again?":"",
 "Thu":"",
diff --git a/locale/de/all b/locale/de/all
index 6402dd314..3cbe40b97 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -4247,6 +4247,7 @@ $ ./scripts/installation_check.pl',
   'The reclamation reason has been deleted.' => 'Der Reklamationsgrund wurde gelöscht.',
   'The reclamation reason has been saved.' => 'Der Reklamationsgrund wurde gespeichert.',
   'The reclamation reason is in use and cannot be deleted.' => 'Der Reklamationsgrund ist in Benutzung und kann nicht gelöscht werden.',
+  'The record has been closed.' => 'Dieser Beleg wurde geschlossen.',
   'The record template \'#1\' has been loaded.' => 'Die Belegvorlage »#1« wurde geladen.',
   'The record template \'#1\' has been saved.' => 'Die Belegvorlage »#1« wurde gespeichert.',
   'The report doesn\'t contain entries.' => 'Der Bericht enthält keine Einträge.',
diff --git a/locale/en/all b/locale/en/all
index 52b324301..1658a0463 100755
--- a/locale/en/all
+++ b/locale/en/all
@@ -4245,6 +4245,7 @@ $self->{texts} = {
   'The reclamation reason has been deleted.' => '',
   'The reclamation reason has been saved.' => '',
   'The reclamation reason is in use and cannot be deleted.' => '',
+  'The record has been closed.' => '',
   'The record template \'#1\' has been loaded.' => '',
   'The record template \'#1\' has been saved.' => '',
   'The report doesn\'t contain entries.' => '',
