diff --git a/admin/anlage_types.php b/admin/anlage_types.php
index 42bfccc..009a2bd 100644
--- a/admin/anlage_types.php
+++ b/admin/anlage_types.php
@@ -64,6 +64,7 @@ if ($action == 'add') {
$anlageType->allowed_parent_types = preg_replace('/[^A-Z0-9_,]/i', '', GETPOST('allowed_parent_types', 'nohtml'));
$anlageType->can_have_equipment = GETPOSTINT('can_have_equipment');
$anlageType->has_accessories = GETPOSTINT('has_accessories');
+ $anlageType->has_product = GETPOSTINT('has_product');
$anlageType->picto = GETPOST('picto', 'alphanohtml');
$anlageType->color = GETPOST('color', 'alphanohtml');
$anlageType->position = GETPOSTINT('position');
@@ -115,6 +116,7 @@ if ($action == 'update') {
$anlageType->allowed_parent_types = preg_replace('/[^A-Z0-9_,]/i', '', GETPOST('allowed_parent_types', 'nohtml'));
$anlageType->can_have_equipment = GETPOSTINT('can_have_equipment');
$anlageType->has_accessories = GETPOSTINT('has_accessories');
+ $anlageType->has_product = GETPOSTINT('has_product');
$anlageType->picto = GETPOST('picto', 'alphanohtml');
$anlageType->color = GETPOST('color', 'alphanohtml');
$anlageType->position = GETPOSTINT('position');
@@ -169,6 +171,7 @@ if ($action == 'copy' && $typeId > 0) {
$newType->allowed_parent_types = $sourceType->allowed_parent_types;
$newType->can_have_equipment = $sourceType->can_have_equipment;
$newType->has_accessories = $sourceType->has_accessories;
+ $newType->has_product = $sourceType->has_product;
$newType->picto = $sourceType->picto;
$newType->color = $sourceType->color;
$newType->position = $sourceType->position + 1;
@@ -410,6 +413,11 @@ if (in_array($action, array('create', 'edit'))) {
print '
has_accessories ? ' checked' : '').'>';
print ' ('.$langs->trans('HasAccessoriesHelp').') | ';
+ // Produkt-Zuordnung erlauben
+ print '| '.$langs->trans('HasProduct').' | ';
+ print 'has_product ? ' checked' : '').'>';
+ print ' ('.$langs->trans('HasProductHelp').') |
';
+
// Allowed parent types - with multi-select UI
print '| '.$langs->trans('AllowedParentTypes').' | ';
print '';
diff --git a/admin/building_types.php b/admin/building_types.php
old mode 100755
new mode 100644
index 85939af..6e34166
--- a/admin/building_types.php
+++ b/admin/building_types.php
@@ -42,6 +42,7 @@ if ($action == 'add' && $user->admin) {
$buildingType->icon = GETPOST('icon', 'alphanohtml');
$buildingType->color = GETPOST('color', 'alphanohtml');
$buildingType->can_have_children = GETPOSTINT('can_have_children');
+ $buildingType->has_product = GETPOSTINT('has_product');
$buildingType->position = GETPOSTINT('position');
$buildingType->active = GETPOSTINT('active');
@@ -82,6 +83,7 @@ if ($action == 'update' && $user->admin) {
$buildingType->icon = GETPOST('icon', 'alphanohtml');
$buildingType->color = GETPOST('color', 'alphanohtml');
$buildingType->can_have_children = GETPOSTINT('can_have_children');
+ $buildingType->has_product = GETPOSTINT('has_product');
$buildingType->position = GETPOSTINT('position');
$buildingType->active = GETPOSTINT('active');
@@ -222,6 +224,12 @@ if ($action == 'create' || $action == 'edit') {
print 'can_have_children || $action != 'edit' ? ' checked' : '').'>';
print ' |
';
+ // Produkt-Zuordnung erlauben
+ print '| '.$langs->trans('HasProduct').' | ';
+ print 'has_product ? ' checked' : '').'>';
+ print ' ('.$langs->trans('HasProductHelp').')';
+ print ' |
';
+
// Position
print '| '.$langs->trans('Position').' | ';
$defaultPos = $action == 'create' ? $buildingType->getNextPosition() : $buildingType->position;
diff --git a/admin/setup.php b/admin/setup.php
old mode 100755
new mode 100644
index d357c15..4ebd0e3
--- a/admin/setup.php
+++ b/admin/setup.php
@@ -125,6 +125,9 @@ if ($action == 'update') {
// View mode
dolibarr_set_const($db, 'KUNDENKARTE_DEFAULT_VIEW', GETPOST('KUNDENKARTE_DEFAULT_VIEW', 'aZ09'), 'chaine', 0, '', $conf->entity);
+ // Ausgebaute Elemente standardmäßig anzeigen
+ dolibarr_set_const($db, 'KUNDENKARTE_SHOW_DECOMMISSIONED', GETPOSTINT('KUNDENKARTE_SHOW_DECOMMISSIONED'), 'chaine', 0, '', $conf->entity);
+
// Tree display settings
dolibarr_set_const($db, 'KUNDENKARTE_TREE_INFO_DISPLAY', GETPOST('KUNDENKARTE_TREE_INFO_DISPLAY', 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'KUNDENKARTE_TREE_BADGE_COLOR', GETPOST('KUNDENKARTE_TREE_BADGE_COLOR', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
@@ -207,6 +210,14 @@ print $form->selectarray('KUNDENKARTE_DEFAULT_VIEW', $viewModes, getDolGlobalStr
print ' | ';
print '
';
+// Ausgebaute Elemente standardmäßig anzeigen
+print '';
+print '| '.$langs->trans("ShowDecommissionedDefault").' | ';
+print '';
+print $form->selectyesno('KUNDENKARTE_SHOW_DECOMMISSIONED', getDolGlobalInt('KUNDENKARTE_SHOW_DECOMMISSIONED', 0), 1);
+print ' | ';
+print '
';
+
print '';
// Tree Display Settings
diff --git a/class/anlagetype.class.php b/class/anlagetype.class.php
index fd167a2..9498f6e 100644
--- a/class/anlagetype.class.php
+++ b/class/anlagetype.class.php
@@ -27,6 +27,7 @@ class AnlageType extends CommonObject
public $allowed_parent_types;
public $can_have_equipment;
public $has_accessories;
+ public $has_product;
public $picto;
public $color;
@@ -74,7 +75,7 @@ class AnlageType extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
$sql .= "entity, ref, label, label_short, description, fk_system,";
- $sql .= " can_have_children, can_be_nested, allowed_parent_types, can_have_equipment, has_accessories,";
+ $sql .= " can_have_children, can_be_nested, allowed_parent_types, can_have_equipment, has_accessories, has_product,";
$sql .= " picto, color, is_system, position, active,";
$sql .= " date_creation, fk_user_creat";
$sql .= ") VALUES (";
@@ -89,6 +90,7 @@ class AnlageType extends CommonObject
$sql .= ", ".($this->allowed_parent_types ? "'".$this->db->escape($this->allowed_parent_types)."'" : "NULL");
$sql .= ", ".((int) $this->can_have_equipment);
$sql .= ", ".((int) $this->has_accessories);
+ $sql .= ", ".((int) $this->has_product);
$sql .= ", ".($this->picto ? "'".$this->db->escape($this->picto)."'" : "NULL");
$sql .= ", ".($this->color ? "'".$this->db->escape($this->color)."'" : "NULL");
$sql .= ", 0"; // is_system = 0 for user-created
@@ -147,6 +149,7 @@ class AnlageType extends CommonObject
$this->allowed_parent_types = $obj->allowed_parent_types;
$this->can_have_equipment = $obj->can_have_equipment ?? 0;
$this->has_accessories = $obj->has_accessories ?? 0;
+ $this->has_product = $obj->has_product ?? 0;
$this->picto = $obj->picto;
$this->color = $obj->color;
$this->is_system = $obj->is_system;
@@ -194,6 +197,7 @@ class AnlageType extends CommonObject
$sql .= ", allowed_parent_types = ".($this->allowed_parent_types ? "'".$this->db->escape($this->allowed_parent_types)."'" : "NULL");
$sql .= ", can_have_equipment = ".((int) $this->can_have_equipment);
$sql .= ", has_accessories = ".((int) $this->has_accessories);
+ $sql .= ", has_product = ".((int) $this->has_product);
$sql .= ", picto = ".($this->picto ? "'".$this->db->escape($this->picto)."'" : "NULL");
$sql .= ", color = ".($this->color ? "'".$this->db->escape($this->color)."'" : "NULL");
$sql .= ", position = ".((int) $this->position);
@@ -317,7 +321,9 @@ class AnlageType extends CommonObject
$type->allowed_parent_types = $obj->allowed_parent_types;
$type->can_have_equipment = $obj->can_have_equipment ?? 0;
$type->has_accessories = $obj->has_accessories ?? 0;
+ $type->has_product = $obj->has_product ?? 0;
$type->picto = $obj->picto;
+ $type->color = $obj->color;
$type->is_system = $obj->is_system;
$type->position = $obj->position;
$type->active = $obj->active;
diff --git a/class/buildingtype.class.php b/class/buildingtype.class.php
old mode 100755
new mode 100644
index ce60fda..afb3688
--- a/class/buildingtype.class.php
+++ b/class/buildingtype.class.php
@@ -33,6 +33,7 @@ class BuildingType extends CommonObject
public $picto;
public $is_system;
public $can_have_children;
+ public $has_product;
public $position;
public $active;
public $date_creation;
@@ -69,7 +70,7 @@ class BuildingType extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
$sql .= "entity, ref, label, label_short, description, fk_parent, level_type,";
- $sql .= "icon, color, picto, is_system, can_have_children, position, active,";
+ $sql .= "icon, color, picto, is_system, can_have_children, has_product, position, active,";
$sql .= "date_creation, fk_user_creat";
$sql .= ") VALUES (";
$sql .= (int)$conf->entity;
@@ -84,6 +85,7 @@ class BuildingType extends CommonObject
$sql .= ", ".($this->picto ? "'".$this->db->escape($this->picto)."'" : "NULL");
$sql .= ", ".(int)($this->is_system ?: 0);
$sql .= ", ".(int)($this->can_have_children !== null ? $this->can_have_children : 1);
+ $sql .= ", ".(int)($this->has_product ?: 0);
$sql .= ", ".(int)($this->position ?: 0);
$sql .= ", ".(int)($this->active !== null ? $this->active : 1);
$sql .= ", '".$this->db->idate($now)."'";
@@ -135,6 +137,7 @@ class BuildingType extends CommonObject
$this->picto = $obj->picto;
$this->is_system = $obj->is_system;
$this->can_have_children = $obj->can_have_children;
+ $this->has_product = $obj->has_product ?? 0;
$this->position = $obj->position;
$this->active = $obj->active;
$this->date_creation = $this->db->jdate($obj->date_creation);
@@ -171,6 +174,7 @@ class BuildingType extends CommonObject
$sql .= ", icon = ".($this->icon ? "'".$this->db->escape($this->icon)."'" : "NULL");
$sql .= ", color = ".($this->color ? "'".$this->db->escape($this->color)."'" : "NULL");
$sql .= ", can_have_children = ".(int)$this->can_have_children;
+ $sql .= ", has_product = ".(int)($this->has_product ?: 0);
$sql .= ", position = ".(int)$this->position;
$sql .= ", active = ".(int)$this->active;
$sql .= ", fk_user_modif = ".(int)$user->id;
@@ -265,6 +269,7 @@ class BuildingType extends CommonObject
$type->picto = $obj->picto;
$type->is_system = $obj->is_system;
$type->can_have_children = $obj->can_have_children;
+ $type->has_product = $obj->has_product ?? 0;
$type->position = $obj->position;
$type->active = $obj->active;
$type->parent_label = $obj->parent_label;
diff --git a/core/modules/modKundenKarte.class.php b/core/modules/modKundenKarte.class.php
index 1810463..6bba0c7 100755
--- a/core/modules/modKundenKarte.class.php
+++ b/core/modules/modKundenKarte.class.php
@@ -76,7 +76,7 @@ class modKundenKarte extends DolibarrModules
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@kundenkarte'
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
- $this->version = '8.5';
+ $this->version = '8.6';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
@@ -656,6 +656,9 @@ class modKundenKarte extends DolibarrModules
// v8.1.0: Werkzeuge & Zubehör
$this->migrate_v810_werkzeuge();
+
+ // v8.6.0: has_product Flag für Typen
+ $this->migrate_v860_has_product();
}
/**
@@ -1022,6 +1025,29 @@ class modKundenKarte extends DolibarrModules
}
}
+ /**
+ * Migration v8.6.0: has_product Flag für Element-Typen und Gebäude-Typen
+ */
+ private function migrate_v860_has_product()
+ {
+ // 1. has_product auf Element-Typ
+ $table = MAIN_DB_PREFIX."kundenkarte_anlage_type";
+ $resql = $this->db->query("SHOW COLUMNS FROM ".$table." LIKE 'has_product'");
+ if (!$resql || $this->db->num_rows($resql) == 0) {
+ $this->db->query("ALTER TABLE ".$table." ADD COLUMN has_product tinyint DEFAULT 0 NOT NULL AFTER has_accessories");
+ }
+
+ // 2. has_product auf Gebäude-Typ
+ $table = MAIN_DB_PREFIX."kundenkarte_building_type";
+ $resql = $this->db->query("SHOW TABLES LIKE '".$this->db->escape($table)."'");
+ if ($resql && $this->db->num_rows($resql) > 0) {
+ $resql2 = $this->db->query("SHOW COLUMNS FROM ".$table." LIKE 'has_product'");
+ if (!$resql2 || $this->db->num_rows($resql2) == 0) {
+ $this->db->query("ALTER TABLE ".$table." ADD COLUMN has_product tinyint DEFAULT 0 NOT NULL AFTER can_have_children");
+ }
+ }
+ }
+
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
diff --git a/langs/de_DE/kundenkarte.lang b/langs/de_DE/kundenkarte.lang
index 0ab3bc8..c77182b 100755
--- a/langs/de_DE/kundenkarte.lang
+++ b/langs/de_DE/kundenkarte.lang
@@ -561,11 +561,14 @@ Decommissioned = Ausgebaut
Decommission = Ausbauen
Recommission = Wieder einbauen
ShowDecommissioned = Ausgebaute Elemente anzeigen
+ShowDecommissionedDefault = Ausgebaute Elemente standardmäßig anzeigen
# Eigener Betrieb & Zubehör
CompanyTools = Mein Betrieb
HasAccessories = Hat Zubehör
HasAccessoriesHelp = Ermöglicht die Zuordnung von Zubehör und Ersatzteilen
+HasProduct = Produkt-Zuordnung
+HasProductHelp = Ermöglicht die Verknüpfung mit einem Dolibarr-Produkt
Accessories = Zubehör / Ersatzteile
NoAccessories = Kein Zubehör zugeordnet
SearchProduct = Produkt suchen
diff --git a/langs/en_US/kundenkarte.lang b/langs/en_US/kundenkarte.lang
index 44aad5a..a0b0fca 100755
--- a/langs/en_US/kundenkarte.lang
+++ b/langs/en_US/kundenkarte.lang
@@ -309,11 +309,14 @@ Decommissioned = Decommissioned
Decommission = Decommission
Recommission = Recommission
ShowDecommissioned = Show decommissioned elements
+ShowDecommissionedDefault = Show decommissioned elements by default
# Own Company & Accessories
CompanyTools = My Company
HasAccessories = Has Accessories
HasAccessoriesHelp = Allows assigning accessories and spare parts
+HasProduct = Product Assignment
+HasProductHelp = Allows linking to a Dolibarr product
Accessories = Accessories / Spare Parts
NoAccessories = No accessories assigned
SearchProduct = Search product
diff --git a/tabs/anlagen.php b/tabs/anlagen.php
index f3d72f9..2bee797 100755
--- a/tabs/anlagen.php
+++ b/tabs/anlagen.php
@@ -510,8 +510,9 @@ if ($isTreeView) {
print '';
- print '