feat: System-Tabs für Mein Betrieb, Produkt/Zubehör für Kunden+Kontakte

- werkzeuge.php: Multi-System mit System-Tabs (nicht mehr nur WERKZEUG)
  - Systeme hinzufügen/entfernen wie bei Kunden-Anlagen
  - Alle URLs mit system-Parameter versehen
  - Steuerungs-Buttons in System-Tab-Wrapper integriert

- tabs/anlagen.php + tabs/contact_anlagen.php:
  - Produkt-Zuordnung im Create/Edit-Formular (Autocomplete)
  - Produkt-Anzeige in der Detailansicht
  - Zubehör-Liste mit Hinzufügen/Löschen
  - Lieferantenbestellung aus Zubehör
  - fk_product in add/update-Actions aufgenommen

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-03-03 20:41:30 +01:00
parent 7a548c87e2
commit 3b9daeb238
3 changed files with 720 additions and 60 deletions

View file

@ -29,6 +29,7 @@ dol_include_once('/kundenkarte/class/anlagefile.class.php');
dol_include_once('/kundenkarte/class/equipmentpanel.class.php'); dol_include_once('/kundenkarte/class/equipmentpanel.class.php');
dol_include_once('/kundenkarte/class/equipmentcarrier.class.php'); dol_include_once('/kundenkarte/class/equipmentcarrier.class.php');
dol_include_once('/kundenkarte/class/equipment.class.php'); dol_include_once('/kundenkarte/class/equipment.class.php');
dol_include_once('/kundenkarte/class/anlageaccessory.class.php');
dol_include_once('/kundenkarte/lib/kundenkarte.lib.php'); dol_include_once('/kundenkarte/lib/kundenkarte.lib.php');
// Load translation files // Load translation files
@ -177,6 +178,7 @@ if ($action == 'add' && $permissiontoadd) {
$anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type'); $anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type');
$anlage->fk_parent = GETPOSTINT('fk_parent'); $anlage->fk_parent = GETPOSTINT('fk_parent');
$anlage->fk_system = $systemId; $anlage->fk_system = $systemId;
$anlage->fk_product = GETPOSTINT('fk_product') > 0 ? GETPOSTINT('fk_product') : null;
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : ''; $anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
$anlage->status = 1; $anlage->status = 1;
@ -219,6 +221,7 @@ if ($action == 'update' && $permissiontoadd) {
$anlage->label = GETPOST('label', 'alphanohtml'); $anlage->label = GETPOST('label', 'alphanohtml');
$anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type'); $anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type');
$anlage->fk_parent = GETPOSTINT('fk_parent'); $anlage->fk_parent = GETPOSTINT('fk_parent');
$anlage->fk_product = GETPOSTINT('fk_product') > 0 ? GETPOSTINT('fk_product') : null;
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : ''; $anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
// Get type - but keep current system for GLOBAL types (buildings) // Get type - but keep current system for GLOBAL types (buildings)
@ -590,6 +593,21 @@ if (empty($customerSystems)) {
print '<tr><td class="titlefield">'.$langs->trans('Type').'</td>'; print '<tr><td class="titlefield">'.$langs->trans('Type').'</td>';
print '<td>'.dol_escape_htmltag($anlage->type_label).'</td></tr>'; print '<td>'.dol_escape_htmltag($anlage->type_label).'</td></tr>';
// Zugeordnetes Produkt
if ($anlage->fk_product > 0) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
if ($product->fetch($anlage->fk_product) > 0) {
print '<tr><td>'.$langs->trans('Product').'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/product/card.php?id='.$product->id.'">'.dol_escape_htmltag($product->ref).'</a>';
print ' - '.dol_escape_htmltag($product->label);
if ($product->price > 0) {
print ' <span class="opacitymedium">('.price($product->price).' €)</span>';
}
print '</td></tr>';
}
}
// Dynamic fields - all fields come from type definition // Dynamic fields - all fields come from type definition
$fieldValues = $anlage->getFieldValues(); $fieldValues = $anlage->getFieldValues();
$typeFieldsList = $type->fetchFields(); $typeFieldsList = $type->fetchFields();
@ -797,6 +815,75 @@ if (empty($customerSystems)) {
</script>'; </script>';
} }
// Zubehör-Bereich (nur wenn Typ has_accessories hat)
if (!empty($type->has_accessories)) {
$accessoryObj = new AnlageAccessory($db);
$accessories = $accessoryObj->fetchAllByAnlage($anlageId);
print '<br><h4><i class="fa fa-puzzle-piece"></i> '.$langs->trans('Accessories').'</h4>';
if (!empty($accessories)) {
print '<div class="div-table-responsive">';
print '<table class="tagtable liste">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans('ProductRef').'</th>';
print '<th>'.$langs->trans('Label').'</th>';
print '<th class="right">'.$langs->trans('Qty').'</th>';
print '<th>'.$langs->trans('Note').'</th>';
if ($permissiontodelete) {
print '<th class="right">'.$langs->trans('Action').'</th>';
}
print '</tr>';
foreach ($accessories as $acc) {
print '<tr>';
print '<td><a href="'.DOL_URL_ROOT.'/product/card.php?id='.$acc->fk_product.'">'.dol_escape_htmltag($acc->product_ref).'</a></td>';
print '<td>'.dol_escape_htmltag($acc->product_label).'</td>';
print '<td class="right">'.$acc->qty.'</td>';
print '<td>'.dol_escape_htmltag($acc->note).'</td>';
if ($permissiontodelete) {
print '<td class="right"><a href="#" class="btn-delete-accessory" data-id="'.$acc->id.'" title="'.$langs->trans('Delete').'"><i class="fa fa-trash"></i></a></td>';
}
print '</tr>';
}
print '</table>';
print '</div>';
} else {
print '<p class="opacitymedium">'.$langs->trans('NoAccessories').'</p>';
}
// Zubehör hinzufügen
if ($permissiontoadd) {
print '<div id="add-accessory-form" style="margin-top:10px;">';
print '<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">';
print '<input type="text" id="accessory_product_search" class="flat minwidth300" placeholder="'.$langs->trans('SearchProduct').'...">';
print '<input type="hidden" id="accessory_product_id" value="">';
print '<input type="number" id="accessory_qty" class="flat" value="1" min="1" style="width:80px;">';
print '<button type="button" id="btn-add-accessory" class="button small" disabled>'.$langs->trans('Add').'</button>';
print '</div>';
print '</div>';
}
// Bestellfunktion
if ($permissiontoadd && !empty($accessories)) {
print '<div style="margin-top:15px;padding:10px;border:1px solid #444;border-radius:4px;">';
print '<h5 style="margin:0 0 10px 0;"><i class="fa fa-shopping-cart"></i> '.$langs->trans('OrderAccessories').'</h5>';
print '<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">';
print '<select id="supplier_select" class="flat minwidth200">';
print '<option value="">'.$langs->trans('SelectSupplier').'</option>';
$sqlSupp = "SELECT s.rowid, s.nom FROM ".MAIN_DB_PREFIX."societe s WHERE s.fournisseur = 1 AND s.status = 1 ORDER BY s.nom";
$resSupp = $db->query($sqlSupp);
if ($resSupp) {
while ($objSupp = $db->fetch_object($resSupp)) {
print '<option value="'.$objSupp->rowid.'">'.dol_escape_htmltag($objSupp->nom).'</option>';
}
}
print '</select>';
print '<button type="button" id="btn-order-accessories" class="button small">'.$langs->trans('CreateSupplierOrder').'</button>';
print '</div>';
print '</div>';
}
}
// Action buttons // Action buttons
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($permissiontoadd) { if ($permissiontoadd) {
@ -929,6 +1016,23 @@ if (empty($customerSystems)) {
printTreeOptions($tree, $selectedParent, $excludeId); printTreeOptions($tree, $selectedParent, $excludeId);
print '</select></td></tr>'; print '</select></td></tr>';
// Produkt-Zuordnung
$productValue = '';
$productId = 0;
if (($isEdit || $isCopy) && $anlage->fk_product > 0) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
if ($product->fetch($anlage->fk_product) > 0) {
$productValue = $product->ref.' - '.$product->label;
$productId = $product->id;
}
}
print '<tr><td>'.$langs->trans('Product').'</td>';
print '<td>';
print '<input type="text" id="product_search" class="flat minwidth300" placeholder="'.$langs->trans('SearchProduct').'..." value="'.dol_escape_htmltag($productValue).'">';
print '<input type="hidden" name="fk_product" id="fk_product" value="'.$productId.'">';
print '</td></tr>';
// Dynamic fields will be inserted here via JavaScript // Dynamic fields will be inserted here via JavaScript
print '<tbody id="dynamic_fields"></tbody>'; print '<tbody id="dynamic_fields"></tbody>';
@ -1122,6 +1226,168 @@ print dol_get_fiche_end();
// Tooltip container // Tooltip container
print '<div id="kundenkarte-tooltip" class="kundenkarte-tooltip"></div>'; print '<div id="kundenkarte-tooltip" class="kundenkarte-tooltip"></div>';
// Produkt-Autocomplete + Zubehör-AJAX (nur wenn Formular oder Detailansicht aktiv)
if (in_array($action, array('create', 'edit', 'copy', 'view'))) {
print '<script>
$(document).ready(function() {
var baseUrl = "'.dol_escape_js(dol_buildpath('/kundenkarte', 1)).'";
// Produkt-Autocomplete
function initProductAutocomplete(inputSelector, hiddenSelector) {
var $input = $(inputSelector);
var $hidden = $(hiddenSelector);
if (!$input.length) return;
var searchTimeout;
$input.on("input", function() {
clearTimeout(searchTimeout);
var term = $(this).val();
if (term.length < 2) {
$hidden.val("");
$(".product-autocomplete-dropdown").remove();
return;
}
searchTimeout = setTimeout(function() {
$.get(baseUrl + "/ajax/equipment.php", {
action: "get_products",
term: term,
token: $("input[name=token]").val() || ""
}, function(data) {
$(".product-autocomplete-dropdown").remove();
if (data.success && data.products && data.products.length > 0) {
var $dropdown = $("<div class=\"product-autocomplete-dropdown\"></div>");
$.each(data.products, function(i, p) {
var label = p.ref + " - " + p.label;
if (p.price > 0) label += " (" + p.price + " \u20ac)";
$dropdown.append(
$("<div class=\"product-autocomplete-item\"></div>")
.text(label)
.data("id", p.id)
.data("ref", p.ref)
.data("label", p.label)
);
});
$input.after($dropdown);
$dropdown.on("click", ".product-autocomplete-item", function() {
$input.val($(this).data("ref") + " - " + $(this).data("label"));
$hidden.val($(this).data("id"));
$dropdown.remove();
if (inputSelector === "#accessory_product_search") {
$("#btn-add-accessory").prop("disabled", false);
}
});
}
});
}, 300);
});
$(document).on("click", function(e) {
if (!$(e.target).closest(inputSelector + ", .product-autocomplete-dropdown").length) {
$(".product-autocomplete-dropdown").remove();
}
});
$input.on("change", function() {
if (!$(this).val()) {
$hidden.val("");
if (inputSelector === "#accessory_product_search") {
$("#btn-add-accessory").prop("disabled", true);
}
}
});
}
initProductAutocomplete("#product_search", "#fk_product");
initProductAutocomplete("#accessory_product_search", "#accessory_product_id");
// Zubehör hinzufügen
$("#btn-add-accessory").on("click", function() {
var productId = $("#accessory_product_id").val();
var qty = $("#accessory_qty").val() || 1;
var anlageId = '.((int) $anlageId).';
if (!productId || !anlageId) return;
$.post(baseUrl + "/ajax/anlage_accessory.php", {
action: "add",
fk_anlage: anlageId,
fk_product: productId,
qty: qty,
token: $("input[name=token]").val() || ""
}).done(function(data) {
if (data.success) { location.reload(); }
else { alert(data.error || "Fehler"); }
});
});
// Zubehör löschen
$(".btn-delete-accessory").on("click", function(e) {
e.preventDefault();
if (!confirm("'.$langs->trans('ConfirmDeleteAccessory').'")) return;
var accId = $(this).data("id");
$.post(baseUrl + "/ajax/anlage_accessory.php", {
action: "delete",
id: accId,
token: $("input[name=token]").val() || ""
}).done(function(data) {
if (data.success) { location.reload(); }
else { alert(data.error || "Fehler"); }
});
});
// Lieferantenbestellung
$("#btn-order-accessories").on("click", function() {
var supplierId = $("#supplier_select").val();
var anlageId = '.((int) $anlageId).';
if (!supplierId) { alert("Bitte Lieferant auswählen"); return; }
var ids = [];
$(".btn-delete-accessory").each(function() { ids.push($(this).data("id")); });
if (ids.length === 0) return;
$.post(baseUrl + "/ajax/anlage_accessory.php", {
action: "order",
fk_anlage: anlageId,
supplier_id: supplierId,
"ids[]": ids,
token: $("input[name=token]").val() || ""
}).done(function(data) {
if (data.success && data.order_id) {
window.location.href = "'.DOL_URL_ROOT.'/fourn/commande/card.php?id=" + data.order_id;
} else {
alert(data.error || "Fehler beim Erstellen der Bestellung");
}
});
});
});
</script>';
// CSS für Autocomplete
print '<style>
.product-autocomplete-dropdown {
position: absolute;
z-index: 1000;
background: var(--colorbackbody, #fff);
border: 1px solid #555;
border-radius: 4px;
max-height: 300px;
overflow-y: auto;
min-width: 300px;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.product-autocomplete-item {
padding: 8px 12px;
cursor: pointer;
border-bottom: 1px solid #333;
}
.product-autocomplete-item:hover {
background: var(--colorbacklinepairhover, #333);
}
.product-autocomplete-item:last-child {
border-bottom: none;
}
</style>';
}
llxFooter(); llxFooter();
$db->close(); $db->close();

View file

@ -29,6 +29,7 @@ dol_include_once('/kundenkarte/class/anlagefile.class.php');
dol_include_once('/kundenkarte/class/equipmentpanel.class.php'); dol_include_once('/kundenkarte/class/equipmentpanel.class.php');
dol_include_once('/kundenkarte/class/equipmentcarrier.class.php'); dol_include_once('/kundenkarte/class/equipmentcarrier.class.php');
dol_include_once('/kundenkarte/class/equipment.class.php'); dol_include_once('/kundenkarte/class/equipment.class.php');
dol_include_once('/kundenkarte/class/anlageaccessory.class.php');
dol_include_once('/kundenkarte/lib/kundenkarte.lib.php'); dol_include_once('/kundenkarte/lib/kundenkarte.lib.php');
// Load translation files // Load translation files
@ -178,6 +179,7 @@ if ($action == 'add' && $permissiontoadd) {
$anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type'); $anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type');
$anlage->fk_parent = GETPOSTINT('fk_parent'); $anlage->fk_parent = GETPOSTINT('fk_parent');
$anlage->fk_system = $systemId; $anlage->fk_system = $systemId;
$anlage->fk_product = GETPOSTINT('fk_product') > 0 ? GETPOSTINT('fk_product') : null;
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : ''; $anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
$anlage->status = 1; $anlage->status = 1;
@ -220,6 +222,7 @@ if ($action == 'update' && $permissiontoadd) {
$anlage->label = GETPOST('label', 'alphanohtml'); $anlage->label = GETPOST('label', 'alphanohtml');
$anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type'); $anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type');
$anlage->fk_parent = GETPOSTINT('fk_parent'); $anlage->fk_parent = GETPOSTINT('fk_parent');
$anlage->fk_product = GETPOSTINT('fk_product') > 0 ? GETPOSTINT('fk_product') : null;
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : ''; $anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
// Get type - but keep current system for GLOBAL types (buildings) // Get type - but keep current system for GLOBAL types (buildings)
@ -588,6 +591,21 @@ if (empty($customerSystems)) {
print '<tr><td class="titlefield">'.$langs->trans('Type').'</td>'; print '<tr><td class="titlefield">'.$langs->trans('Type').'</td>';
print '<td>'.dol_escape_htmltag($anlage->type_label).'</td></tr>'; print '<td>'.dol_escape_htmltag($anlage->type_label).'</td></tr>';
// Zugeordnetes Produkt
if ($anlage->fk_product > 0) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
if ($product->fetch($anlage->fk_product) > 0) {
print '<tr><td>'.$langs->trans('Product').'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/product/card.php?id='.$product->id.'">'.dol_escape_htmltag($product->ref).'</a>';
print ' - '.dol_escape_htmltag($product->label);
if ($product->price > 0) {
print ' <span class="opacitymedium">('.price($product->price).' €)</span>';
}
print '</td></tr>';
}
}
// Dynamic fields - all fields come from type definition // Dynamic fields - all fields come from type definition
$fieldValues = $anlage->getFieldValues(); $fieldValues = $anlage->getFieldValues();
$typeFieldsList = $type->fetchFields(); $typeFieldsList = $type->fetchFields();
@ -795,6 +813,73 @@ if (empty($customerSystems)) {
</script>'; </script>';
} }
// Zubehör-Bereich (nur wenn Typ has_accessories hat)
if (!empty($type->has_accessories)) {
$accessoryObj = new AnlageAccessory($db);
$accessories = $accessoryObj->fetchAllByAnlage($anlageId);
print '<br><h4><i class="fa fa-puzzle-piece"></i> '.$langs->trans('Accessories').'</h4>';
if (!empty($accessories)) {
print '<div class="div-table-responsive">';
print '<table class="tagtable liste">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans('ProductRef').'</th>';
print '<th>'.$langs->trans('Label').'</th>';
print '<th class="right">'.$langs->trans('Qty').'</th>';
print '<th>'.$langs->trans('Note').'</th>';
if ($permissiontodelete) {
print '<th class="right">'.$langs->trans('Action').'</th>';
}
print '</tr>';
foreach ($accessories as $acc) {
print '<tr>';
print '<td><a href="'.DOL_URL_ROOT.'/product/card.php?id='.$acc->fk_product.'">'.dol_escape_htmltag($acc->product_ref).'</a></td>';
print '<td>'.dol_escape_htmltag($acc->product_label).'</td>';
print '<td class="right">'.$acc->qty.'</td>';
print '<td>'.dol_escape_htmltag($acc->note).'</td>';
if ($permissiontodelete) {
print '<td class="right"><a href="#" class="btn-delete-accessory" data-id="'.$acc->id.'" title="'.$langs->trans('Delete').'"><i class="fa fa-trash"></i></a></td>';
}
print '</tr>';
}
print '</table>';
print '</div>';
} else {
print '<p class="opacitymedium">'.$langs->trans('NoAccessories').'</p>';
}
if ($permissiontoadd) {
print '<div id="add-accessory-form" style="margin-top:10px;">';
print '<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">';
print '<input type="text" id="accessory_product_search" class="flat minwidth300" placeholder="'.$langs->trans('SearchProduct').'...">';
print '<input type="hidden" id="accessory_product_id" value="">';
print '<input type="number" id="accessory_qty" class="flat" value="1" min="1" style="width:80px;">';
print '<button type="button" id="btn-add-accessory" class="button small" disabled>'.$langs->trans('Add').'</button>';
print '</div>';
print '</div>';
}
if ($permissiontoadd && !empty($accessories)) {
print '<div style="margin-top:15px;padding:10px;border:1px solid #444;border-radius:4px;">';
print '<h5 style="margin:0 0 10px 0;"><i class="fa fa-shopping-cart"></i> '.$langs->trans('OrderAccessories').'</h5>';
print '<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">';
print '<select id="supplier_select" class="flat minwidth200">';
print '<option value="">'.$langs->trans('SelectSupplier').'</option>';
$sqlSupp = "SELECT s.rowid, s.nom FROM ".MAIN_DB_PREFIX."societe s WHERE s.fournisseur = 1 AND s.status = 1 ORDER BY s.nom";
$resSupp = $db->query($sqlSupp);
if ($resSupp) {
while ($objSupp = $db->fetch_object($resSupp)) {
print '<option value="'.$objSupp->rowid.'">'.dol_escape_htmltag($objSupp->nom).'</option>';
}
}
print '</select>';
print '<button type="button" id="btn-order-accessories" class="button small">'.$langs->trans('CreateSupplierOrder').'</button>';
print '</div>';
print '</div>';
}
}
// Action buttons // Action buttons
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($permissiontoadd) { if ($permissiontoadd) {
@ -927,6 +1012,23 @@ if (empty($customerSystems)) {
printTreeOptions($tree, $selectedParent, $excludeId); printTreeOptions($tree, $selectedParent, $excludeId);
print '</select></td></tr>'; print '</select></td></tr>';
// Produkt-Zuordnung
$productValue = '';
$productId = 0;
if (($isEdit || $isCopy) && $anlage->fk_product > 0) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
if ($product->fetch($anlage->fk_product) > 0) {
$productValue = $product->ref.' - '.$product->label;
$productId = $product->id;
}
}
print '<tr><td>'.$langs->trans('Product').'</td>';
print '<td>';
print '<input type="text" id="product_search" class="flat minwidth300" placeholder="'.$langs->trans('SearchProduct').'..." value="'.dol_escape_htmltag($productValue).'">';
print '<input type="hidden" name="fk_product" id="fk_product" value="'.$productId.'">';
print '</td></tr>';
// Dynamic fields will be inserted here via JavaScript // Dynamic fields will be inserted here via JavaScript
print '<tbody id="dynamic_fields"></tbody>'; print '<tbody id="dynamic_fields"></tbody>';
@ -1120,6 +1222,163 @@ print dol_get_fiche_end();
// Tooltip container // Tooltip container
print '<div id="kundenkarte-tooltip" class="kundenkarte-tooltip"></div>'; print '<div id="kundenkarte-tooltip" class="kundenkarte-tooltip"></div>';
// Produkt-Autocomplete + Zubehör-AJAX (nur wenn Formular oder Detailansicht aktiv)
if (in_array($action, array('create', 'edit', 'copy', 'view'))) {
print '<script>
$(document).ready(function() {
var baseUrl = "'.dol_escape_js(dol_buildpath('/kundenkarte', 1)).'";
function initProductAutocomplete(inputSelector, hiddenSelector) {
var $input = $(inputSelector);
var $hidden = $(hiddenSelector);
if (!$input.length) return;
var searchTimeout;
$input.on("input", function() {
clearTimeout(searchTimeout);
var term = $(this).val();
if (term.length < 2) {
$hidden.val("");
$(".product-autocomplete-dropdown").remove();
return;
}
searchTimeout = setTimeout(function() {
$.get(baseUrl + "/ajax/equipment.php", {
action: "get_products",
term: term,
token: $("input[name=token]").val() || ""
}, function(data) {
$(".product-autocomplete-dropdown").remove();
if (data.success && data.products && data.products.length > 0) {
var $dropdown = $("<div class=\"product-autocomplete-dropdown\"></div>");
$.each(data.products, function(i, p) {
var label = p.ref + " - " + p.label;
if (p.price > 0) label += " (" + p.price + " \u20ac)";
$dropdown.append(
$("<div class=\"product-autocomplete-item\"></div>")
.text(label)
.data("id", p.id)
.data("ref", p.ref)
.data("label", p.label)
);
});
$input.after($dropdown);
$dropdown.on("click", ".product-autocomplete-item", function() {
$input.val($(this).data("ref") + " - " + $(this).data("label"));
$hidden.val($(this).data("id"));
$dropdown.remove();
if (inputSelector === "#accessory_product_search") {
$("#btn-add-accessory").prop("disabled", false);
}
});
}
});
}, 300);
});
$(document).on("click", function(e) {
if (!$(e.target).closest(inputSelector + ", .product-autocomplete-dropdown").length) {
$(".product-autocomplete-dropdown").remove();
}
});
$input.on("change", function() {
if (!$(this).val()) {
$hidden.val("");
if (inputSelector === "#accessory_product_search") {
$("#btn-add-accessory").prop("disabled", true);
}
}
});
}
initProductAutocomplete("#product_search", "#fk_product");
initProductAutocomplete("#accessory_product_search", "#accessory_product_id");
$("#btn-add-accessory").on("click", function() {
var productId = $("#accessory_product_id").val();
var qty = $("#accessory_qty").val() || 1;
var anlageId = '.((int) $anlageId).';
if (!productId || !anlageId) return;
$.post(baseUrl + "/ajax/anlage_accessory.php", {
action: "add",
fk_anlage: anlageId,
fk_product: productId,
qty: qty,
token: $("input[name=token]").val() || ""
}).done(function(data) {
if (data.success) { location.reload(); }
else { alert(data.error || "Fehler"); }
});
});
$(".btn-delete-accessory").on("click", function(e) {
e.preventDefault();
if (!confirm("'.$langs->trans('ConfirmDeleteAccessory').'")) return;
var accId = $(this).data("id");
$.post(baseUrl + "/ajax/anlage_accessory.php", {
action: "delete",
id: accId,
token: $("input[name=token]").val() || ""
}).done(function(data) {
if (data.success) { location.reload(); }
else { alert(data.error || "Fehler"); }
});
});
$("#btn-order-accessories").on("click", function() {
var supplierId = $("#supplier_select").val();
var anlageId = '.((int) $anlageId).';
if (!supplierId) { alert("Bitte Lieferant auswählen"); return; }
var ids = [];
$(".btn-delete-accessory").each(function() { ids.push($(this).data("id")); });
if (ids.length === 0) return;
$.post(baseUrl + "/ajax/anlage_accessory.php", {
action: "order",
fk_anlage: anlageId,
supplier_id: supplierId,
"ids[]": ids,
token: $("input[name=token]").val() || ""
}).done(function(data) {
if (data.success && data.order_id) {
window.location.href = "'.DOL_URL_ROOT.'/fourn/commande/card.php?id=" + data.order_id;
} else {
alert(data.error || "Fehler beim Erstellen der Bestellung");
}
});
});
});
</script>';
print '<style>
.product-autocomplete-dropdown {
position: absolute;
z-index: 1000;
background: var(--colorbackbody, #fff);
border: 1px solid #555;
border-radius: 4px;
max-height: 300px;
overflow-y: auto;
min-width: 300px;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.product-autocomplete-item {
padding: 8px 12px;
cursor: pointer;
border-bottom: 1px solid #333;
}
.product-autocomplete-item:hover {
background: var(--colorbacklinepairhover, #333);
}
.product-autocomplete-item:last-child {
border-bottom: none;
}
</style>';
}
llxFooter(); llxFooter();
$db->close(); $db->close();

View file

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2026 Alles Watt lauft /* Copyright (C) 2026 Alles Watt lauft
* *
* Firmen-Werkzeuge: Baumansicht für eigene Maschinen und Werkzeuge * Mein Betrieb: Baumansicht für eigene Maschinen, Werkzeuge und Geräte
* System-Filter fix auf WERKZEUG * Multi-System mit System-Tabs (wie Kunden-Anlagen)
*/ */
// Load Dolibarr environment // Load Dolibarr environment
@ -32,42 +32,42 @@ $permissiontodelete = $user->hasRight('kundenkarte', 'delete');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$systemId = GETPOSTINT('system');
$anlageId = GETPOSTINT('anlage_id'); $anlageId = GETPOSTINT('anlage_id');
$parentId = GETPOSTINT('parent_id'); $parentId = GETPOSTINT('parent_id');
// Virtuelle Firma-ID für Werkzeuge - braucht keinen echten Societe-Eintrag // Virtuelle Firma-ID für "Mein Betrieb" - braucht keinen echten Societe-Eintrag
// Die Anlage-Tabelle verwendet diese ID nur als Gruppierung // Die Anlage-Tabelle verwendet diese ID nur als Gruppierung
$socId = 99999999; $socId = 99999999;
// WERKZEUG-System ermitteln // ALLE verfügbaren Systeme laden
$werkzeugSystemId = 0; $allSystems = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system WHERE code = 'WERKZEUG' AND active = 1"; $sql = "SELECT rowid, code, label, picto, color FROM ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system WHERE active = 1 ORDER BY position ASC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql && $db->num_rows($resql) > 0) { if ($resql) {
$obj = $db->fetch_object($resql); while ($obj = $db->fetch_object($resql)) {
$werkzeugSystemId = $obj->rowid; $allSystems[$obj->rowid] = $obj;
}
} }
if ($werkzeugSystemId <= 0) { // Für diesen virtuellen Betrieb aktivierte Systeme laden
setEventMessages('System WERKZEUG nicht gefunden. Bitte Modul deaktivieren und wieder aktivieren.', null, 'errors'); $customerSystems = array();
llxHeader('', 'Firmen-Werkzeuge'); $sql = "SELECT ss.rowid, ss.fk_system, s.code, s.label, s.picto, s.color";
llxFooter(); $sql .= " FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system ss";
exit; $sql .= " JOIN ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system s ON s.rowid = ss.fk_system";
$sql .= " WHERE ss.fk_soc = ".((int) $socId)." AND (ss.fk_contact IS NULL OR ss.fk_contact = 0) AND ss.active = 1 AND s.active = 1";
$sql .= " AND s.code != 'GLOBAL'";
$sql .= " ORDER BY s.position ASC";
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$customerSystems[$obj->fk_system] = $obj;
}
} }
$systemId = $werkzeugSystemId; // Standard: Erstes aktiviertes System falls nicht angegeben
if (empty($systemId) && !empty($customerSystems)) {
// Sicherstellen dass WERKZEUG für eigene Firma aktiviert ist $systemId = array_key_first($customerSystems);
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system";
$sql .= " WHERE fk_soc = ".((int) $socId)." AND fk_system = ".((int) $systemId);
$sql .= " AND (fk_contact IS NULL OR fk_contact = 0) AND active = 1";
$resql = $db->query($sql);
if (!$resql || $db->num_rows($resql) == 0) {
// Automatisch aktivieren
$sql = "INSERT INTO ".MAIN_DB_PREFIX."kundenkarte_societe_system";
$sql .= " (entity, fk_soc, fk_contact, fk_system, date_creation, fk_user_creat, active)";
$sql .= " VALUES (".$conf->entity.", ".((int) $socId).", 0, ".((int) $systemId).", NOW(), ".((int) $user->id).", 1)";
$db->query($sql);
} }
// Objekte initialisieren // Objekte initialisieren
@ -79,6 +79,53 @@ $anlageType = new AnlageType($db);
* Actions * Actions
*/ */
// System hinzufügen
if ($action == 'add_system' && $permissiontoadd) {
$newSystemId = GETPOSTINT('new_system_id');
if ($newSystemId > 0 && !isset($customerSystems[$newSystemId])) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."kundenkarte_societe_system";
$sql .= " (entity, fk_soc, fk_contact, fk_system, date_creation, fk_user_creat, active)";
$sql .= " VALUES (".$conf->entity.", ".((int) $socId).", 0, ".((int) $newSystemId).", NOW(), ".((int) $user->id).", 1)";
$result = $db->query($sql);
if ($result) {
setEventMessages($langs->trans('SystemAdded'), null, 'mesgs');
header('Location: '.$_SERVER['PHP_SELF'].'?system='.$newSystemId);
exit;
} else {
setEventMessages($db->lasterror(), null, 'errors');
}
}
$action = '';
}
// System entfernen
if ($action == 'confirm_remove_system' && $confirm == 'yes' && $permissiontodelete) {
$removeSystemId = GETPOSTINT('remove_system_id');
if ($removeSystemId > 0) {
// Prüfen ob System noch Elemente hat
$sql = "SELECT COUNT(*) as cnt FROM ".MAIN_DB_PREFIX."kundenkarte_anlage WHERE fk_soc = ".((int) $socId)." AND (fk_contact IS NULL OR fk_contact = 0) AND fk_system = ".((int) $removeSystemId);
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj->cnt > 0) {
setEventMessages($langs->trans('ErrorSystemHasElements'), null, 'errors');
} else {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system WHERE fk_soc = ".((int) $socId)." AND (fk_contact IS NULL OR fk_contact = 0) AND fk_system = ".((int) $removeSystemId);
$db->query($sql);
setEventMessages($langs->trans('SystemRemoved'), null, 'mesgs');
unset($customerSystems[$removeSystemId]);
if (!empty($customerSystems)) {
$systemId = array_key_first($customerSystems);
} else {
$systemId = 0;
}
}
}
header('Location: '.$_SERVER['PHP_SELF'].($systemId ? '?system='.$systemId : ''));
exit;
}
if ($action == 'add' && $permissiontoadd) { if ($action == 'add' && $permissiontoadd) {
$anlage->label = GETPOST('label', 'alphanohtml'); $anlage->label = GETPOST('label', 'alphanohtml');
$anlage->fk_soc = $socId; $anlage->fk_soc = $socId;
@ -107,7 +154,7 @@ if ($action == 'add' && $permissiontoadd) {
$result = $anlage->create($user); $result = $anlage->create($user);
if ($result > 0) { if ($result > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.$_SERVER['PHP_SELF']); header('Location: '.$_SERVER['PHP_SELF'].'?system='.$systemId);
exit; exit;
} else { } else {
setEventMessages($anlage->error, $anlage->errors, 'errors'); setEventMessages($anlage->error, $anlage->errors, 'errors');
@ -141,7 +188,7 @@ if ($action == 'update' && $permissiontoadd) {
$result = $anlage->update($user); $result = $anlage->update($user);
if ($result > 0) { if ($result > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.$_SERVER['PHP_SELF']); header('Location: '.$_SERVER['PHP_SELF'].'?system='.$systemId);
exit; exit;
} else { } else {
setEventMessages($anlage->error, $anlage->errors, 'errors'); setEventMessages($anlage->error, $anlage->errors, 'errors');
@ -175,10 +222,10 @@ print load_fiche_titre($title, '', 'fa-wrench');
print '<div class="fichecenter">'; print '<div class="fichecenter">';
// Bestätigungsdialog // Bestätigungsdialoge
if ($action == 'delete') { if ($action == 'delete') {
print $form->formconfirm( print $form->formconfirm(
$_SERVER['PHP_SELF'].'?anlage_id='.$anlageId, $_SERVER['PHP_SELF'].'?system='.$systemId.'&anlage_id='.$anlageId,
$langs->trans('DeleteElement'), $langs->trans('DeleteElement'),
$langs->trans('ConfirmDeleteElement'), $langs->trans('ConfirmDeleteElement'),
'confirm_delete', 'confirm_delete',
@ -188,8 +235,109 @@ if ($action == 'delete') {
); );
} }
// Typen für WERKZEUG-System laden if ($action == 'remove_system') {
$types = $anlageType->fetchAllBySystem($systemId, 1, 1); // excludeGlobal=1, nur WERKZEUG-Typen $removeSystemId = GETPOSTINT('remove_system_id');
$sysLabel = isset($customerSystems[$removeSystemId]) ? $customerSystems[$removeSystemId]->label : '';
print $form->formconfirm(
$_SERVER['PHP_SELF'].'?remove_system_id='.$removeSystemId,
$langs->trans('RemoveSystem'),
$langs->trans('ConfirmRemoveSystem', $sysLabel),
'confirm_remove_system',
'',
'yes',
1
);
}
// System-Tabs
print '<div class="kundenkarte-system-tabs-wrapper">';
print '<div class="kundenkarte-system-tabs">';
foreach ($customerSystems as $sysId => $sys) {
$activeClass = ($sysId == $systemId) ? ' active' : '';
print '<div class="kundenkarte-system-tab'.$activeClass.'" data-system="'.$sysId.'">';
print '<a href="'.$_SERVER['PHP_SELF'].'?system='.$sysId.'" style="text-decoration:none;color:inherit;display:flex;align-items:center;gap:8px;">';
if ($sys->picto) {
print '<span class="kundenkarte-system-tab-icon" style="color:'.$sys->color.';">'.kundenkarte_render_icon($sys->picto).'</span>';
}
print '<span>'.dol_escape_htmltag($sys->label).'</span>';
print '</a>';
// Entfernen-Button (nur beim aktiven Tab)
if ($permissiontodelete && $sysId == $systemId) {
print ' <a href="'.$_SERVER['PHP_SELF'].'?action=remove_system&remove_system_id='.$sysId.'" class="kundenkarte-system-remove" title="'.$langs->trans('RemoveSystem').'"><i class="fa fa-times"></i></a>';
}
print '</div>';
}
// System hinzufügen Button
if ($permissiontoadd) {
$availableSystems = array_diff_key($allSystems, $customerSystems);
// GLOBAL ausschließen
foreach ($availableSystems as $k => $v) {
if ($v->code === 'GLOBAL') unset($availableSystems[$k]);
}
if (!empty($availableSystems)) {
print '<button type="button" class="button small kundenkarte-add-system-btn" onclick="document.getElementById(\'add-system-form\').style.display=\'block\';">';
print '<i class="fa fa-plus"></i> '.$langs->trans('AddSystem');
print '</button>';
}
}
print '</div>';
// Steuerungs-Buttons (nur in Baumansicht)
$isTreeView = !in_array($action, array('create', 'edit', 'view'));
if ($isTreeView && $systemId > 0) {
print '<div class="kundenkarte-tree-controls">';
print '<button type="button" class="kundenkarte-view-toggle" id="btn-compact-mode" title="Kompakte Ansicht">';
print '<i class="fa fa-compress"></i> <span>Kompakt</span>';
print '</button>';
print '<button type="button" class="button small" id="btn-expand-all" title="'.$langs->trans('ExpandAll').'">';
print '<i class="fa fa-expand"></i> '.$langs->trans('ExpandAll');
print '</button>';
print '<button type="button" class="button small" id="btn-collapse-all" title="'.$langs->trans('CollapseAll').'">';
print '<i class="fa fa-compress"></i> '.$langs->trans('CollapseAll');
print '</button>';
print '<button type="button" class="button small" id="btn-toggle-decommissioned" title="'.$langs->trans('ShowDecommissioned').'">';
print '<i class="fa fa-eye-slash"></i> <span>'.$langs->trans('Decommissioned').'</span>';
print '</button>';
print '</div>';
}
print '</div>'; // End system-tabs-wrapper
// System-Hinzufügen-Formular (versteckt)
if ($permissiontoadd && !empty($availableSystems)) {
print '<div id="add-system-form" class="kundenkarte-add-system-form" style="display:none;margin-bottom:15px;">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add_system">';
print '<strong>'.$langs->trans('SelectSystemToAdd').':</strong> ';
print '<select name="new_system_id" class="flat">';
print '<option value="">'.$langs->trans('Select').'</option>';
foreach ($availableSystems as $avSys) {
print '<option value="'.$avSys->rowid.'">'.dol_escape_htmltag($avSys->label).'</option>';
}
print '</select>';
print ' <button type="submit" class="button small">'.$langs->trans('Add').'</button>';
print ' <button type="button" class="button small" onclick="document.getElementById(\'add-system-form\').style.display=\'none\';">'.$langs->trans('Cancel').'</button>';
print '</form>';
print '</div>';
}
// Prüfen ob Systeme konfiguriert sind
if (empty($customerSystems)) {
print '<div class="opacitymedium" style="padding:20px;text-align:center;">';
print '<i class="fa fa-info-circle" style="font-size:24px;margin-bottom:10px;"></i><br>';
print $langs->trans('NoSystemsConfigured').'<br><br>';
if ($permissiontoadd && !empty($allSystems)) {
print $langs->trans('ClickAddSystemToStart');
} else {
print $langs->trans('ContactAdminToAddSystems');
}
print '</div>';
} elseif ($systemId > 0) {
// Typen für ausgewähltes System laden
$types = $anlageType->fetchAllBySystem($systemId, 1, 1);
if (in_array($action, array('create', 'edit', 'view'))) { if (in_array($action, array('create', 'edit', 'view'))) {
// Formular oder Detail-Ansicht // Formular oder Detail-Ansicht
@ -337,12 +485,12 @@ if (in_array($action, array('create', 'edit', 'view'))) {
// Aktions-Buttons // Aktions-Buttons
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($permissiontoadd) { if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&anlage_id='.$anlageId.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=edit&anlage_id='.$anlageId.'">'.$langs->trans('Modify').'</a>';
} }
if ($permissiontodelete) { if ($permissiontodelete) {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&anlage_id='.$anlageId.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=delete&anlage_id='.$anlageId.'">'.$langs->trans('Delete').'</a>';
} }
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'">'.$langs->trans('Back').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'">'.$langs->trans('Back').'</a>';
print '</div>'; print '</div>';
} else { } else {
@ -350,9 +498,10 @@ if (in_array($action, array('create', 'edit', 'view'))) {
$isEdit = ($action == 'edit'); $isEdit = ($action == 'edit');
$formAction = $isEdit ? 'update' : 'add'; $formAction = $isEdit ? 'update' : 'add';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.$formAction.'">'; print '<input type="hidden" name="action" value="'.$formAction.'">';
print '<input type="hidden" name="system" value="'.$systemId.'">';
if ($isEdit) { if ($isEdit) {
print '<input type="hidden" name="anlage_id" value="'.$anlageId.'">'; print '<input type="hidden" name="anlage_id" value="'.$anlageId.'">';
} }
@ -417,7 +566,7 @@ if (in_array($action, array('create', 'edit', 'view'))) {
print '<div class="center" style="margin-top:20px;">'; print '<div class="center" style="margin-top:20px;">';
print '<button type="submit" class="button button-save">'.$langs->trans('Save').'</button>'; print '<button type="submit" class="button button-save">'.$langs->trans('Save').'</button>';
print ' <a class="button button-cancel" href="'.$_SERVER['PHP_SELF'].'">'.$langs->trans('Cancel').'</a>'; print ' <a class="button button-cancel" href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'">'.$langs->trans('Cancel').'</a>';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -430,28 +579,12 @@ if (in_array($action, array('create', 'edit', 'view'))) {
if ($permissiontoadd) { if ($permissiontoadd) {
print '<div style="margin-bottom:15px;">'; print '<div style="margin-bottom:15px;">';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=create">'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=create">';
print '<i class="fa fa-plus"></i> '.$langs->trans('AddElement'); print '<i class="fa fa-plus"></i> '.$langs->trans('AddElement');
print '</a>'; print '</a>';
print '</div>'; print '</div>';
} }
// Steuerungs-Buttons
print '<div class="kundenkarte-tree-controls" style="margin-bottom:10px;">';
print '<button type="button" class="kundenkarte-view-toggle" id="btn-compact-mode" title="Kompakte Ansicht">';
print '<i class="fa fa-compress"></i> <span>Kompakt</span>';
print '</button>';
print '<button type="button" class="button small" id="btn-expand-all" title="'.$langs->trans('ExpandAll').'">';
print '<i class="fa fa-expand"></i> '.$langs->trans('ExpandAll');
print '</button>';
print '<button type="button" class="button small" id="btn-collapse-all" title="'.$langs->trans('CollapseAll').'">';
print '<i class="fa fa-compress"></i> '.$langs->trans('CollapseAll');
print '</button>';
print '<button type="button" class="button small" id="btn-toggle-decommissioned" title="'.$langs->trans('ShowDecommissioned').'">';
print '<i class="fa fa-eye-slash"></i> <span>'.$langs->trans('Decommissioned').'</span>';
print '</button>';
print '</div>';
// Baum laden // Baum laden
$tree = $anlage->fetchTree($socId, $systemId); $tree = $anlage->fetchTree($socId, $systemId);
@ -478,12 +611,14 @@ if (in_array($action, array('create', 'edit', 'view'))) {
print '<i class="fa fa-wrench" style="font-size:48px;margin-bottom:15px;color:#666;"></i><br>'; print '<i class="fa fa-wrench" style="font-size:48px;margin-bottom:15px;color:#666;"></i><br>';
print $langs->trans('NoToolsYet').'<br><br>'; print $langs->trans('NoToolsYet').'<br><br>';
if ($permissiontoadd) { if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=create"><i class="fa fa-plus"></i> '.$langs->trans('AddFirstTool').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=create"><i class="fa fa-plus"></i> '.$langs->trans('AddFirstTool').'</a>';
} }
print '</div>'; print '</div>';
} }
} }
} // Ende elseif ($systemId > 0)
print '</div>'; // fichecenter print '</div>'; // fichecenter
// Tooltip Container // Tooltip Container
@ -739,7 +874,7 @@ function werkzeuge_printTree($nodes, $socid, $systemId, $canEdit, $canDelete, $l
print '<span class="kundenkarte-tree-icon">'.kundenkarte_render_icon($picto).'</span>'; print '<span class="kundenkarte-tree-icon">'.kundenkarte_render_icon($picto).'</span>';
// Label // Label
$viewUrl = $_SERVER['PHP_SELF'].'?action=view&anlage_id='.$node->id; $viewUrl = $_SERVER['PHP_SELF'].'?system='.$systemId.'&action=view&anlage_id='.$node->id;
print '<span class="kundenkarte-tree-label">'.dol_escape_htmltag($node->label); print '<span class="kundenkarte-tree-label">'.dol_escape_htmltag($node->label);
if (!empty($treeInfoParentheses)) { if (!empty($treeInfoParentheses)) {
$infoValues = array(); $infoValues = array();
@ -790,14 +925,14 @@ function werkzeuge_printTree($nodes, $socid, $systemId, $canEdit, $canDelete, $l
print '<span class="kundenkarte-tree-actions">'; print '<span class="kundenkarte-tree-actions">';
print '<a href="'.$viewUrl.'" title="'.$langs->trans('View').'"><i class="fa fa-eye"></i></a>'; print '<a href="'.$viewUrl.'" title="'.$langs->trans('View').'"><i class="fa fa-eye"></i></a>';
if ($canEdit) { if ($canEdit) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=create&parent_id='.$node->id.'" title="'.$langs->trans('AddChild').'"><i class="fa fa-plus"></i></a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=create&parent_id='.$node->id.'" title="'.$langs->trans('AddChild').'"><i class="fa fa-plus"></i></a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=edit&anlage_id='.$node->id.'" title="'.$langs->trans('Edit').'"><i class="fa fa-edit"></i></a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=edit&anlage_id='.$node->id.'" title="'.$langs->trans('Edit').'"><i class="fa fa-edit"></i></a>';
$decommLabel = $node->decommissioned ? $langs->trans('Recommission') : $langs->trans('Decommission'); $decommLabel = $node->decommissioned ? $langs->trans('Recommission') : $langs->trans('Decommission');
$decommIcon = $node->decommissioned ? 'fa-plug' : 'fa-power-off'; $decommIcon = $node->decommissioned ? 'fa-plug' : 'fa-power-off';
print '<a href="#" class="btn-toggle-decommissioned" data-anlage-id="'.$node->id.'" title="'.$decommLabel.'"><i class="fa '.$decommIcon.'"></i></a>'; print '<a href="#" class="btn-toggle-decommissioned" data-anlage-id="'.$node->id.'" title="'.$decommLabel.'"><i class="fa '.$decommIcon.'"></i></a>';
} }
if ($canDelete) { if ($canDelete) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&anlage_id='.$node->id.'" title="'.$langs->trans('Delete').'" class="deletelink"><i class="fa fa-trash"></i></a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?system='.$systemId.'&action=delete&anlage_id='.$node->id.'" title="'.$langs->trans('Delete').'" class="deletelink"><i class="fa fa-trash"></i></a>';
} }
print '</span>'; print '</span>';