From e19484b597893dda782e7fa36c1c25d9a131b8a6 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Thu, 23 May 2024 14:27:32 +0200 Subject: [PATCH] versandpaket paketmarke calculate weight of versandpaket --- www/lib/class.versanddienstleister.php | 12 ++++-------- www/pages/lieferschein.php | 5 ++++- www/pages/versandpakete.php | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 28db5bd2..1cd85bd8 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -162,13 +162,7 @@ abstract class Versanddienstleister AND r.status != 'storniert' ORDER BY lp.sort"; $ret['positions'] = $this->app->DB->SelectArr($sql) ?? []; - - if ($sid === "lieferschein") { - $standardkg = $this->app->erp->VersandartMindestgewicht($lieferscheinId); - } else { - $standardkg = $this->app->erp->VersandartMindestgewicht(); - } - $ret['weight'] = $standardkg; + return $ret; } @@ -370,9 +364,11 @@ abstract class Versanddienstleister return true; } - public function Paketmarke(string $target, string $docType, int $docId, $versandpaket = null): void + public function Paketmarke(string $target, string $docType, int $docId, $gewicht = 0, $versandpaket = null): void { $address = $this->GetAdressdaten($docId, $docType); + $address['weight'] = $gewicht; + if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) { $json = json_decode(file_get_contents('php://input')); $ret = []; diff --git a/www/pages/lieferschein.php b/www/pages/lieferschein.php index 23779527..f13c2cbc 100644 --- a/www/pages/lieferschein.php +++ b/www/pages/lieferschein.php @@ -575,7 +575,10 @@ class Lieferschein extends GenLieferschein return; } $versandmodul = $this->app->erp->LoadVersandModul($result['modul'], $result['id']); - $versandmodul->Paketmarke('TAB1', 'lieferschein', $id); + + $gewicht = $this->app->erp->VersandartMindestgewicht($id, 'lieferschein'); + + $versandmodul->Paketmarke('TAB1', docType: 'lieferschein', docId: $id, gewicht: $gewicht); $this->app->Tpl->Parse('PAGE',"tabview.tpl"); } diff --git a/www/pages/versandpakete.php b/www/pages/versandpakete.php index e4a0c268..791fedf0 100644 --- a/www/pages/versandpakete.php +++ b/www/pages/versandpakete.php @@ -1176,7 +1176,22 @@ class Versandpakete { } $lieferschein = $this->app->DB->SelectRow("SELECT * FROM (".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") temp WHERE versandpaket = ".$id." LIMIT 1"); $versandmodul = $this->app->erp->LoadVersandModul($versandart['modul'], $versandart['id']); - $versandmodul->Paketmarke('TAB1', 'lieferschein', $lieferschein['lieferschein'], $id); + + $sql = " + SELECT + SUM(COALESCE(a.gewicht,0)*vlp.menge) + FROM + artikel a + INNER JOIN lieferschein_position lp ON + a.id = lp.artikel + INNER JOIN + versandpaket_lieferschein_position vlp ON + vlp.lieferschein_position = lp.id + WHERE vlp.versandpaket = ".$id." + "; + + $gewicht = $this->app->DB->Select($sql); + $versandmodul->Paketmarke('TAB1', docType: 'lieferschein', docId: $lieferschein['lieferschein'], versandpaket: $id, gewicht: $gewicht); $this->app->Tpl->Parse('PAGE',"tabview.tpl"); }