From b2bf2f14f2d5e6c5047e78f85a3d07a72826bdbe Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Wed, 4 Oct 2023 12:31:02 +0200 Subject: [PATCH] Wareneingang added empty and fill from bestellung --- .../content/wareneingang_paketinhalt.tpl | 2 - www/pages/wareneingang.php | 52 ++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/www/pages/content/wareneingang_paketinhalt.tpl b/www/pages/content/wareneingang_paketinhalt.tpl index 8d00bb78..b984a5de 100644 --- a/www/pages/content/wareneingang_paketinhalt.tpl +++ b/www/pages/content/wareneingang_paketinhalt.tpl @@ -48,14 +48,12 @@ [AFTERMANUELLERFASSEN] [ISLIEFERANTSTART] - [ISLIEFERANTENDE] diff --git a/www/pages/wareneingang.php b/www/pages/wareneingang.php index 4dfe3e59..c3dc9651 100644 --- a/www/pages/wareneingang.php +++ b/www/pages/wareneingang.php @@ -1691,8 +1691,56 @@ class Wareneingang { switch ($submit) { case 'fuellen': + // Get bestellung_position from form + $form_input = $this->app->Secure->GetPOSTArray(); + foreach ($form_input as $key => $menge) { + if ((strpos($key,'menge_') === 0)) { + $bestellposition = substr($key,'6'); + // Remove existing preliminary value + $sql = "DELETE FROM paketdistribution WHERE paketannahme = ".$id." AND bestellung_position = ".$bestellposition." AND vorlaeufig = 1"; + $this->app->DB->Delete($sql); + + // Write paketdistribution + $sql = "INSERT INTO paketdistribution( + id, + bearbeiter, + zeit, + paketannahme, + adresse, + artikel, + menge, + vpe, + etiketten, + bemerkung, + bestellung_position, + vorlaeufig + ) + VALUES( + '', + '" . $this->app->User->GetName() . "', + NOW(), + '$id', + '', + '$artikel', + (SELECT menge-geliefert FROM bestellung_position WHERE id = ".$bestellposition."), + '$vpe', + '', + '$bemerkung', + '$bestellposition', + 1 + )"; + + $this->app->DB->Insert($sql); + + } + } + + break; case 'leeren': + // Remove existing preliminary value + $sql = "DELETE FROM paketdistribution WHERE paketannahme = ".$id." AND vorlaeufig = 1"; + $this->app->DB->Delete($sql); break; case 'manuellerfassen': $this->app->Location->execute('index.php?module=wareneingang&action=manuellerfassen&id=' . $id); @@ -1788,9 +1836,9 @@ class Wareneingang { foreach ($menge_input as $key => $menge) { if ((strpos($key,'menge_') === 0) && ($menge !== '')) { - $bestellposition = substr($key,'6'); - if ($menge > 0) { + $bestellposition = substr($key,'6'); + if ($menge >= 0) { // Allow 0 for reset of saved value // Gather info bestellung $bparr = $this->app->DB->SelectRow("SELECT * FROM bestellung INNER JOIN bestellung_position ON bestellung_position.bestellung = bestellung.id INNER JOIN artikel ON bestellung_position.artikel = artikel.id WHERE bestellung_position.id='$bestellposition' LIMIT 1"); $artikel = $bparr['artikel'];