diff --git a/ChangeLog.md b/ChangeLog.md
index ede6a79..db2787f 100755
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,5 @@
# CHANGELOG MODULE SUPPLIERLINK3 FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
-1.1
+## 1.0
Initial version
diff --git a/class/actions_supplierlink3.class.php b/class/actions_supplierlink3.class.php
index adcb7bd..c65a3d8 100755
--- a/class/actions_supplierlink3.class.php
+++ b/class/actions_supplierlink3.class.php
@@ -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 = '';
$newref .= $line->ref_fourn;
- $newref .= ' ';
$newref .= '';
+ // Lagerbestand daneben mit Farbe
+ $newref .= ' '.$qtyStock.'';
+
$line->ref_fourn = $newref;
+
}
}
}
@@ -448,4 +468,5 @@ class ActionsSupplierLink3 extends CommonHookActions
return 0;
}
+
}
diff --git a/core/modules/modSupplierLink3.class.php b/core/modules/modSupplierLink3.class.php
index 6d8780e..db06d78 100755
--- a/core/modules/modSupplierLink3.class.php
+++ b/core/modules/modSupplierLink3.class.php
@@ -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';