Langebestand in Lieferantenbestellung hinzugefügt

This commit is contained in:
Eduard Wisch 2025-12-09 14:28:22 +01:00
parent c4e4e74301
commit aee5056361
3 changed files with 32 additions and 11 deletions

View file

@ -1,5 +1,5 @@
# CHANGELOG MODULE SUPPLIERLINK3 FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
1.1
## 1.0
Initial version

View file

@ -409,13 +409,12 @@ class ActionsSupplierLink3 extends CommonHookActions
$line = $parameters['line'];
// Lieferanten-ID aus dem Bestell-Objekt holen, nicht aus der Zeile!
// Lieferanten-ID aus dem Bestell-Objekt holen
if (!empty($object->socid)) {
$fk_supplier = $object->socid;
// Extrafeld-Wert vom Lieferanten laden
$sql = "SELECT shop_url";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_extrafields";
$sql = "SELECT shop_url FROM ".MAIN_DB_PREFIX."societe_extrafields";
$sql .= " WHERE fk_object = ".(int)$fk_supplier;
$resql = $this->db->query($sql);
@ -423,24 +422,45 @@ class ActionsSupplierLink3 extends CommonHookActions
if ($resql && $this->db->num_rows($resql) > 0) {
$obj = $this->db->fetch_object($resql);
// Prüfen ob shop_url gesetzt ist
if (isset($obj->shop_url) && $obj->shop_url !== '' && $obj->shop_url !== null) {
$shop_url = trim($obj->shop_url);
// Nur wenn die URL nicht leer ist
if (!empty($shop_url)) {
// Artikelnummer an die URL anhängen
$full_url = rtrim($shop_url, '/') . '/' . $line->ref_fourn;
// Lagerbestand und Wunschbestand abfragen
$sqlStock = "SELECT stock, desiredstock
FROM ".MAIN_DB_PREFIX."product
WHERE rowid = ".(int)$line->fk_product;
// Link erstellen
$resStock = $this->db->query($sqlStock);
$qtyStock = 0;
$desiredQty = 0;
if ($resStock && $this->db->num_rows($resStock) > 0) {
$objStock = $this->db->fetch_object($resStock);
$qtyStock = (float) $objStock->stock;
$desiredQty = (float) $objStock->desiredstock;
}
// Farbe setzen
$stockColor = 'ffffff';
if ($qtyStock < 1) {
$stockColor = 'red'; // ausverkauft
} elseif ($qtyStock < $desiredQty) {
$stockColor = 'orange'; // kleiner als Wunschbestand
}
// Artikel-Link
$full_url = rtrim($shop_url, '/') . '/' . $line->ref_fourn;
$newref = '<a href="'.$full_url.'" target="_blank" class="classfortooltip" title="'.dol_escape_htmltag('Artikel im Shop ansehen').'">';
$newref .= $line->ref_fourn;
$newref .= ' <span class="fa fa-external-link-alt opacitymedium" style="font-size: 0.8em;"></span>';
$newref .= '</a>';
// Lagerbestand daneben mit Farbe
$newref .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="fas fa-box-open em080 pictofixedwidth" title="Lagerbestand" style="color: '.$stockColor.'"></span><b> <span style="color: '.$stockColor.'">'.$qtyStock.'</span></b>';
$line->ref_fourn = $newref;
}
}
}
@ -448,4 +468,5 @@ class ActionsSupplierLink3 extends CommonHookActions
return 0;
}
}

View file

@ -76,7 +76,7 @@ class modSupplierLink3 extends DolibarrModules
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@supplierlink3'
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
$this->version = '1.1';
$this->version = '1.0';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';