From 393a2a4be67766a0f171f95b9648cb34c7fd03f7 Mon Sep 17 00:00:00 2001 From: data Date: Wed, 17 Dec 2025 10:12:32 +0100 Subject: [PATCH] =?UTF-8?q?Shop=20Url=20in=20Produkt=20Karte=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 2 + class/actions_supplierlink3.class.php | 63 +++++++++++++++++++++++++ core/modules/modSupplierLink3.class.php | 1 + 3 files changed, 66 insertions(+) diff --git a/.idea/.gitignore b/.idea/.gitignore index 13566b8..10a67c7 100755 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -6,3 +6,5 @@ # Datasource local storage ignored files /dataSources/ /dataSources.local.xml +/data_source_mapping.xml +/dataSources.xml diff --git a/class/actions_supplierlink3.class.php b/class/actions_supplierlink3.class.php index dcaa979..67e007c 100755 --- a/class/actions_supplierlink3.class.php +++ b/class/actions_supplierlink3.class.php @@ -511,4 +511,67 @@ class ActionsSupplierLink3 extends CommonHookActions return 0; } + public function formObjectOptions($parameters, &$object, &$action) + { + global $db; + + if (strpos($parameters['context'], 'productcard') === false) { + return 0; + } + + if ($action != 'create' && $action != 'edit') { + + $sql = "SELECT DISTINCT pfp.ref_fourn, pfp.quantity, pfp.price, s.nom, se.shop_url + FROM ".MAIN_DB_PREFIX."product_fournisseur_price pfp + INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = pfp.fk_soc + INNER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object = pfp.fk_soc + WHERE pfp.fk_product = ".(int)$object->id." + AND se.shop_url IS NOT NULL + AND se.shop_url != '' + ORDER BY pfp.price ASC"; + + $resql = $db->query($sql); + $links = array(); + $minPrice = null; + + // Ersten Durchlauf: günstigsten Preis finden + if ($resql) { + $results = array(); + while ($obj = $db->fetch_object($resql)) { + $results[] = $obj; + if ($minPrice === null || $obj->price < $minPrice) { + $minPrice = $obj->price; + } + } + + // Zweiter Durchlauf: Links bauen + foreach ($results as $obj) { + $shortName = explode(' ', $obj->nom)[0]; + $tooltip = ''.$obj->nom.'
Artikel-Nr: '.$obj->ref_fourn.'
Preis: '.round($obj->price,2).' EUR
Mindestmenge: '.$obj->quantity; + + // Günstigster Lieferant wird fett + $displayText = $shortName.' ('.$obj->ref_fourn.')'; + if ($obj->price == $minPrice) { + $displayText = ''.$displayText.''; + } + + $links[] = ''.$displayText.''; + } + } + + if (!empty($links)) { + $linksHtml = implode(' | ', $links); + ?> + + array( 'ordersuppliercard', 'ordercard', + 'productcard', ), 'entity' => '0', ),